From c5a9f27c31dd880a9e41c0ce28a54f80bfa105c5 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Thu, 16 Nov 2017 12:31:42 -0800 Subject: [PATCH] Catch some activity not found exceptions for expired builds --- res/values/strings.xml | 1 + .../reminder/ExpiredBuildReminder.java | 9 ++++++++- .../reminder/OutdatedBuildReminder.java | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index c1c4873a1..45b2a3f31 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1248,6 +1248,7 @@ Search Device no longer registered This is likely because you registered your phone number with Signal on a different device. Tap to re-register. + No web browser installed! diff --git a/src/org/thoughtcrime/securesms/components/reminder/ExpiredBuildReminder.java b/src/org/thoughtcrime/securesms/components/reminder/ExpiredBuildReminder.java index 08f69da6c..66ed65724 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/ExpiredBuildReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/ExpiredBuildReminder.java @@ -3,6 +3,8 @@ package org.thoughtcrime.securesms.components.reminder; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.util.Log; +import android.widget.Toast; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.util.Util; @@ -18,7 +20,12 @@ public class ExpiredBuildReminder extends Reminder { try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName()))); } catch (android.content.ActivityNotFoundException anfe) { - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + context.getPackageName()))); + try { + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + context.getPackageName()))); + } catch (android.content.ActivityNotFoundException anfe2) { + Log.w(TAG, anfe2); + Toast.makeText(context, R.string.OutdatedBuildReminder_no_web_browser_installed, Toast.LENGTH_SHORT).show(); + } } }); } diff --git a/src/org/thoughtcrime/securesms/components/reminder/OutdatedBuildReminder.java b/src/org/thoughtcrime/securesms/components/reminder/OutdatedBuildReminder.java index 40a0c30fd..b1ec4ee31 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/OutdatedBuildReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/OutdatedBuildReminder.java @@ -1,25 +1,32 @@ package org.thoughtcrime.securesms.components.reminder; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.util.Log; import android.view.View; +import android.widget.Toast; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.util.Util; public class OutdatedBuildReminder extends Reminder { + private static final String TAG = OutdatedBuildReminder.class.getSimpleName(); + public OutdatedBuildReminder(final Context context) { super(context.getString(R.string.reminder_header_outdated_build), getPluralsText(context)); - setOkListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + setOkListener(v -> { + try { + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName()))); + } catch (ActivityNotFoundException anfe) { try { - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName()))); - } catch (android.content.ActivityNotFoundException anfe) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + context.getPackageName()))); + } catch (ActivityNotFoundException anfe2) { + Log.w(TAG, anfe2); + Toast.makeText(context, R.string.OutdatedBuildReminder_no_web_browser_installed, Toast.LENGTH_LONG).show(); } } });