diff --git a/res/values/strings.xml b/res/values/strings.xml index e31215873a..fd5d26b20d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -147,6 +147,7 @@ Camera unavailable Unable to record audio! Error sending voice message... + There is no app available to handle this link on your device. Message details @@ -189,6 +190,7 @@ Search... + There is no browser installed on your device. @@ -429,6 +431,7 @@ Rate now! No thanks Later + Whoops, the Play Store app does not appear to be installed on your device. Block this contact? @@ -766,6 +769,7 @@ Thanks for your help! Submitting Posting logs to gist… + No browser installed Would you like to import your existing text messages into Signal\'s encrypted database? diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index f050cadf40..135d311fe1 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -36,7 +36,6 @@ import android.os.Vibrator; import android.provider.Browser; import android.provider.ContactsContract; import android.support.annotation.NonNull; -import android.support.v4.view.MenuItemCompat; import android.support.v4.view.WindowCompat; import android.support.v7.app.AlertDialog; import android.text.Editable; @@ -128,7 +127,6 @@ import org.thoughtcrime.securesms.util.DirectoryHelper.UserCapabilities; import org.thoughtcrime.securesms.util.DirectoryHelper.UserCapabilities.Capability; import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; -import org.thoughtcrime.securesms.util.ExpirationUtil; import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.TextSecurePreferences; @@ -375,7 +373,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) { intent.removeExtra(Browser.EXTRA_APPLICATION_ID); } - super.startActivity(intent); + + try { + super.startActivity(intent); + } catch (ActivityNotFoundException e) { + Log.w(TAG, e); + Toast.makeText(this, R.string.ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device, Toast.LENGTH_LONG).show(); + } } @Override diff --git a/src/org/thoughtcrime/securesms/ConversationListActivity.java b/src/org/thoughtcrime/securesms/ConversationListActivity.java index 0fc53dcedc..7ec9d40409 100644 --- a/src/org/thoughtcrime/securesms/ConversationListActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationListActivity.java @@ -16,6 +16,7 @@ */ package org.thoughtcrime.securesms; +import android.content.ActivityNotFoundException; import android.content.Intent; import android.database.ContentObserver; import android.net.Uri; @@ -30,6 +31,7 @@ import android.support.v7.widget.SearchView; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.widget.Toast; import org.thoughtcrime.securesms.components.RatingManager; import org.thoughtcrime.securesms.crypto.MasterSecret; @@ -212,7 +214,11 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit } private void handleHelp() { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://support.whispersystems.org"))); + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://support.whispersystems.org"))); + } catch (ActivityNotFoundException e) { + Toast.makeText(this, R.string.ConversationListActivity_there_is_no_browser_installed_on_your_device, Toast.LENGTH_LONG).show(); + } } private void initializeContactUpdatesReceiver() { diff --git a/src/org/thoughtcrime/securesms/LogSubmitActivity.java b/src/org/thoughtcrime/securesms/LogSubmitActivity.java index ffb9ecf010..b020b9cb5f 100644 --- a/src/org/thoughtcrime/securesms/LogSubmitActivity.java +++ b/src/org/thoughtcrime/securesms/LogSubmitActivity.java @@ -1,8 +1,11 @@ package org.thoughtcrime.securesms; +import android.content.ActivityNotFoundException; +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBarActivity; +import android.util.Log; import android.view.MenuItem; import android.widget.Toast; @@ -58,4 +61,14 @@ public class LogSubmitActivity extends BaseActionBarActivity implements SubmitLo public void onCancel() { finish(); } + + @Override + public void startActivity(Intent intent) { + try { + super.startActivity(intent); + } catch (ActivityNotFoundException e) { + Log.w(TAG, e); + Toast.makeText(this, R.string.log_submit_activity__no_browser_installed, Toast.LENGTH_LONG).show(); + } + } } diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index c4cb065148..6d41793ba4 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms; +import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; @@ -41,6 +42,7 @@ import org.whispersystems.signalservice.api.util.PhoneNumberFormatter; public class RegistrationActivity extends BaseActionBarActivity { private static final int PICK_COUNTRY = 1; + private static final String TAG = RegistrationActivity.class.getSimpleName(); private AsYouTypeFormatter countryFormatter; private ArrayAdapter countrySpinnerAdapter; @@ -99,7 +101,11 @@ public class RegistrationActivity extends BaseActionBarActivity { intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse("https://twilio.com")); - startActivity(intent); + try { + startActivity(intent); + } catch (ActivityNotFoundException e) { + Log.w(TAG,e); + } } }); } @@ -154,7 +160,7 @@ public class RegistrationActivity extends BaseActionBarActivity { } } } catch (NumberParseException npe) { - Log.w("CreateAccountActivity", npe); + Log.w(TAG, npe); } } diff --git a/src/org/thoughtcrime/securesms/components/RatingManager.java b/src/org/thoughtcrime/securesms/components/RatingManager.java index 30505d9154..e06cbb98a0 100644 --- a/src/org/thoughtcrime/securesms/components/RatingManager.java +++ b/src/org/thoughtcrime/securesms/components/RatingManager.java @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms.components; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -7,6 +8,7 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.support.v7.app.AlertDialog; import android.util.Log; +import android.widget.Toast; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.util.TextSecurePreferences; @@ -62,7 +64,12 @@ public class RatingManager { private static void startPlayStore(Context context) { Uri uri = Uri.parse("market://details?id=" + context.getPackageName()); - context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); + try { + context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); + } catch (ActivityNotFoundException e) { + Log.w(TAG, e); + Toast.makeText(context, R.string.RatingManager_whoops_the_play_store_app_does_not_appear_to_be_installed, Toast.LENGTH_LONG).show(); + } } private static long getDaysSinceInstalled(Context context) {