From 23159c22014cd602591afb3332d8e75d5eaeb361 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 14 Feb 2018 17:11:27 -0500 Subject: [PATCH] catch ActivityNotFoundException with alert --- src/Android/Resources/Resource.Designer.cs | 33 ++++----------------- src/Android/Services/DeviceActionService.cs | 22 +++++++++++--- src/App/Resources/AppResources.Designer.cs | 9 ++++++ src/App/Resources/AppResources.resx | 3 ++ 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index c937e355e..3ffd358ea 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -6475,17 +6475,17 @@ namespace Bit.Android // aapt resource value: 0x7f090051 public const int ApplicationName = 2131296337; - // aapt resource value: 0x7f0900b2 - public const int AutoFillServiceDescription = 2131296434; + // aapt resource value: 0x7f0900ab + public const int AutoFillServiceDescription = 2131296427; - // aapt resource value: 0x7f0900b1 - public const int AutoFillServiceSummary = 2131296433; + // aapt resource value: 0x7f0900aa + public const int AutoFillServiceSummary = 2131296426; // aapt resource value: 0x7f090050 public const int Hello = 2131296336; - // aapt resource value: 0x7f0900b3 - public const int MyVault = 2131296435; + // aapt resource value: 0x7f0900ac + public const int MyVault = 2131296428; // aapt resource value: 0x7f090027 public const int abc_action_bar_home_description = 2131296295; @@ -6640,27 +6640,6 @@ namespace Bit.Android // aapt resource value: 0x7f09000f public const int common_signin_button_text_long = 2131296271; - // aapt resource value: 0x7f0900ac - public const int default_web_client_id = 2131296428; - - // aapt resource value: 0x7f0900ad - public const int firebase_database_url = 2131296429; - - // aapt resource value: 0x7f0900aa - public const int gcm_defaultSenderId = 2131296426; - - // aapt resource value: 0x7f0900ae - public const int google_api_key = 2131296430; - - // aapt resource value: 0x7f0900ab - public const int google_app_id = 2131296427; - - // aapt resource value: 0x7f0900af - public const int google_crash_reporting_api_key = 2131296431; - - // aapt resource value: 0x7f0900b0 - public const int google_storage_bucket = 2131296432; - // aapt resource value: 0x7f090052 public const int hockeyapp_crash_dialog_app_name_fallback = 2131296338; diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index 961c22a48..2897bb80d 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -424,10 +424,24 @@ namespace Bit.Android.Services public void OpenAutofillSettings() { - var activity = (MainActivity)CurrentContext; - var intent = new Intent(Settings.ActionRequestSetAutofillService); - intent.SetData(global::Android.Net.Uri.Parse("package:com.x8bit.bitwarden")); - activity.StartActivity(intent); + try + { + var activity = (MainActivity)CurrentContext; + var intent = new Intent(Settings.ActionRequestSetAutofillService); + intent.SetData(global::Android.Net.Uri.Parse("package:com.x8bit.bitwarden")); + activity.StartActivity(intent); + } + catch(ActivityNotFoundException) + { + var alertBuilder = new AlertDialog.Builder((MainActivity)CurrentContext); + alertBuilder.SetMessage(AppResources.BitwardenAutofillGoToSettings); + alertBuilder.SetCancelable(true); + alertBuilder.SetPositiveButton(AppResources.Ok, (sender, args) => + { + (sender as AlertDialog)?.Cancel(); + }); + alertBuilder.Create().Show(); + } } public void ShowLoading(string text) diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index d98da4586..c31a2e079 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -474,6 +474,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to We were unable to automatically open the Android autofill settings menu for you. You can navigate to the autofill settings menu manually from Android Settings > System > Languages and input > Advanced > Autofill service.. + /// + public static string BitwardenAutofillGoToSettings { + get { + return ResourceManager.GetString("BitwardenAutofillGoToSettings", resourceCulture); + } + } + /// /// Looks up a localized string similar to bitwarden Auto-fill Service. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 9d7f4c333..cf9d5e5b1 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1231,4 +1231,7 @@ Windows Hello + + We were unable to automatically open the Android autofill settings menu for you. You can navigate to the autofill settings menu manually from Android Settings > System > Languages and input > Advanced > Autofill service. + \ No newline at end of file