From 0a664c47b7f0d0aaa894279206db570fe700b92a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 4 Jun 2019 10:51:10 -0400 Subject: [PATCH] autofill not enabled prompt if migrated --- src/App/Migration/MigrationHelpers.cs | 1 + .../Vault/GroupingsPage/GroupingsPage.xaml.cs | 26 ++++++++++++++++--- src/App/Resources/AppResources.Designer.cs | 9 +++++++ src/App/Resources/AppResources.resx | 3 +++ src/Core/Constants.cs | 2 ++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/App/Migration/MigrationHelpers.cs b/src/App/Migration/MigrationHelpers.cs index 0e7783ebf..30a5d98e9 100644 --- a/src/App/Migration/MigrationHelpers.cs +++ b/src/App/Migration/MigrationHelpers.cs @@ -183,6 +183,7 @@ namespace Bit.App.Migration // Remove "needs migration" flag settingsShim.Remove(Constants.OldUserIdKey); + await storageService.SaveAsync(Constants.MigratedFromV1, true); Migrating = false; messagingService.Send("migrated"); if(Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.None) diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index 09999fb61..e3af2e972 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -17,6 +17,7 @@ namespace Bit.App.Pages private readonly IPushNotificationService _pushNotificationService; private readonly IStorageService _storageService; private readonly ILockService _lockService; + private readonly IDeviceActionService _deviceActionService; private readonly GroupingsPageViewModel _vm; private readonly string _pageName; @@ -31,6 +32,7 @@ namespace Bit.App.Pages _pushNotificationService = ServiceContainer.Resolve("pushNotificationService"); _storageService = ServiceContainer.Resolve("storageService"); _lockService = ServiceContainer.Resolve("lockService"); + _deviceActionService = ServiceContainer.Resolve("deviceActionService"); _vm = BindingContext as GroupingsPageViewModel; _vm.Page = this; _vm.MainPage = mainPage; @@ -104,10 +106,28 @@ namespace Bit.App.Pages await _pushNotificationService.RegisterAsync(); } } - else if(Device.RuntimePlatform == Device.Android && - DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) + else if(Device.RuntimePlatform == Device.Android) { - await _pushNotificationService.RegisterAsync(); + if(DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) + { + await _pushNotificationService.RegisterAsync(); + } + if(!_deviceActionService.AutofillAccessibilityServiceRunning() + && !_deviceActionService.AutofillServiceEnabled()) + { + var migratedFromV1 = await _storageService.GetAsync(Constants.MigratedFromV1); + if(migratedFromV1.GetValueOrDefault()) + { + var migratedFromV1AutofillPromptShown = await _storageService.GetAsync( + Constants.MigratedFromV1AutofillPromptShown); + if(!migratedFromV1AutofillPromptShown.GetValueOrDefault()) + { + await DisplayAlert(AppResources.Autofill, + AppResources.AutofillServiceNotEnabled, AppResources.Ok); + } + } + } + await _storageService.SaveAsync(Constants.MigratedFromV1AutofillPromptShown, true); } } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index a9df0a2c4..37dc1e7c7 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -420,6 +420,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Auto-fill makes it easy to securely access your Bitwarden vault from other websites and apps. It looks like you have not enabled an auto-fill service for Bitwarden. Enable auto-fill for Bitwarden from the "Settings" screen.. + /// + public static string AutofillServiceNotEnabled { + get { + return ResourceManager.GetString("AutofillServiceNotEnabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Your logins are now easily accessible right from your keyboard while logging into apps and websites.. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index f85e8becb..d23cf8ee8 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1553,4 +1553,7 @@ On App Restart + + Auto-fill makes it easy to securely access your Bitwarden vault from other websites and apps. It looks like you have not enabled an auto-fill service for Bitwarden. Enable auto-fill for Bitwarden from the "Settings" screen. + \ No newline at end of file diff --git a/src/Core/Constants.cs b/src/Core/Constants.cs index dbb546c99..d7a9d468e 100644 --- a/src/Core/Constants.cs +++ b/src/Core/Constants.cs @@ -28,6 +28,8 @@ public static string LastBuildKey = "lastBuild"; public static string OldUserIdKey = "userId"; public static string AddSitePromptShownKey = "addSitePromptShown"; + public static string MigratedFromV1 = "migratedFromV1"; + public static string MigratedFromV1AutofillPromptShown = "migratedV1AutofillPromptShown"; public const int SelectFileRequestCode = 42; public const int SelectFilePermissionRequestCode = 43; }