From 2928abc98f0f130d170aa9a3389c73d166973456 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Tue, 18 Jun 2013 14:43:27 -0700 Subject: [PATCH] Catch attempts to dial on devices with no dialer. --- res/values/strings.xml | 3 ++- .../securesms/ConversationActivity.java | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 804b63e844..0c37c3a38c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -82,6 +82,8 @@ %d recipients in group Saving draft... Invalid recipient! + Calls Not Supported + This device does not appear to support dial actions. Message details @@ -525,7 +527,6 @@ Verified - diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 664617bd63..48d60417a5 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -18,6 +18,7 @@ package org.thoughtcrime.securesms; import android.app.Activity; import android.app.AlertDialog; +import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -379,11 +380,18 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi } private void handleDial(Recipient recipient) { - if (recipient == null) return; + try { + if (recipient == null) return; - Intent dialIntent = new Intent(Intent.ACTION_DIAL, - Uri.parse("tel:" + recipient.getNumber())); - startActivity(dialIntent); + Intent dialIntent = new Intent(Intent.ACTION_DIAL, + Uri.parse("tel:" + recipient.getNumber())); + startActivity(dialIntent); + } catch (ActivityNotFoundException anfe) { + Log.w("ConversationActivity", anfe); + Util.showAlertDialog(this, + getString(R.string.ConversationActivity_calls_not_supported), + getString(R.string.ConversationActivity_this_device_does_not_appear_to_support_dial_actions)); + } } private void handleDisplayGroupRecipients() {