From 2574e0cba5aa4f09835eb53595b7d9a42f3abe69 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 3 Jun 2019 23:00:48 -0400 Subject: [PATCH] Add Site Prompt --- src/App/Migration/MigrationHelpers.cs | 2 ++ src/App/Pages/Vault/AddEditPage.xaml.cs | 42 ++++++++++++++++++++-- src/App/Resources/AppResources.Designer.cs | 12 +++---- src/App/Resources/AppResources.resx | 6 ++-- src/Core/Constants.cs | 1 + 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/App/Migration/MigrationHelpers.cs b/src/App/Migration/MigrationHelpers.cs index 1a6a33fcf..31a8f6ed5 100644 --- a/src/App/Migration/MigrationHelpers.cs +++ b/src/App/Migration/MigrationHelpers.cs @@ -93,6 +93,8 @@ namespace Bit.App.Migration settingsShim.GetValueOrDefault("setting:disableAutoCopyTotp", false)); await storageService.SaveAsync(Constants.DisableFaviconKey, settingsShim.GetValueOrDefault("setting:disableWebsiteIcons", false)); + await storageService.SaveAsync(Constants.AddSitePromptShownKey, + settingsShim.GetValueOrDefault("addedSiteAlert", false)); await storageService.SaveAsync(Constants.PushInitialPromptShownKey, settingsShim.GetValueOrDefault("push:initialPromptShown", false)); await storageService.SaveAsync(Constants.PushCurrentTokenKey, diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs index 88f502ef3..a62cf8ced 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml.cs +++ b/src/App/Pages/Vault/AddEditPage.xaml.cs @@ -1,5 +1,10 @@ -using Bit.App.Models; +using Bit.App.Abstractions; +using Bit.App.Models; +using Bit.App.Resources; +using Bit.Core; +using Bit.Core.Abstractions; using Bit.Core.Enums; +using Bit.Core.Utilities; using System.Collections.Generic; using Xamarin.Forms; @@ -7,8 +12,11 @@ namespace Bit.App.Pages { public partial class AddEditPage : BaseContentPage { - private AddEditPageViewModel _vm; private readonly AppOptions _appOptions; + private readonly IStorageService _storageService; + private readonly IDeviceActionService _deviceActionService; + + private AddEditPageViewModel _vm; private bool _fromAutofill; public AddEditPage( @@ -21,6 +29,8 @@ namespace Bit.App.Pages bool fromAutofill = false, AppOptions appOptions = null) { + _storageService = ServiceContainer.Resolve("storageService"); + _deviceActionService = ServiceContainer.Resolve("deviceActionService"); _appOptions = appOptions; _fromAutofill = fromAutofill; FromAutofillFramework = _appOptions?.FromAutofillFramework ?? false; @@ -147,6 +157,34 @@ namespace Bit.App.Pages } } } + if(!_vm.EditMode) + { + var addLoginShown = await _storageService.GetAsync(Constants.AddSitePromptShownKey); + if(_vm.Cipher.Type == CipherType.Login && !_fromAutofill && !addLoginShown.GetValueOrDefault()) + { + await _storageService.SaveAsync(Constants.AddSitePromptShownKey, true); + if(Device.RuntimePlatform == Device.iOS) + { + if(_deviceActionService.SystemMajorVersion() < 12) + { + await DisplayAlert(AppResources.BitwardenAppExtension, + AppResources.BitwardenAppExtensionAlert2, AppResources.Ok); + } + else + { + await DisplayAlert(AppResources.PasswordAutofill, + AppResources.BitwardenAutofillAlert2, AppResources.Ok); + } + } + else if(Device.RuntimePlatform == Device.Android && + !_deviceActionService.AutofillAccessibilityServiceRunning() && + !_deviceActionService.AutofillServiceEnabled()) + { + await DisplayAlert(AppResources.BitwardenAutofillService, + AppResources.BitwardenAutofillServiceAlert2, AppResources.Ok); + } + } + } } protected override void OnDisappearing() diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index d5c5bcf78..13fa93738 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -558,9 +558,9 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to The easiest way to add new logins to your vault is from the Bitwarden App Extension. Learn more about using the Bitwarden App Extension by navigating to the "Tools" screen.. /// - public static string BitwardenAppExtensionAlert { + public static string BitwardenAppExtensionAlert2 { get { - return ResourceManager.GetString("BitwardenAppExtensionAlert", resourceCulture); + return ResourceManager.GetString("BitwardenAppExtensionAlert2", resourceCulture); } } @@ -594,9 +594,9 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to The easiest way to add new logins to your vault is by using the Bitwarden Password AutoFill extension. Learn more about using the Bitwarden Password AutoFill extension by navigating to the "Tools" screen.. /// - public static string BitwardenAutofillAlert { + public static string BitwardenAutofillAlert2 { get { - return ResourceManager.GetString("BitwardenAutofillAlert", resourceCulture); + return ResourceManager.GetString("BitwardenAutofillAlert2", resourceCulture); } } @@ -630,9 +630,9 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to The easiest way to add new logins to your vault is from the Bitwarden Auto-fill Service. Learn more about using the Bitwarden Auto-fill Service by navigating to the "Tools" screen.. /// - public static string BitwardenAutofillServiceAlert { + public static string BitwardenAutofillServiceAlert2 { get { - return ResourceManager.GetString("BitwardenAutofillServiceAlert", resourceCulture); + return ResourceManager.GetString("BitwardenAutofillServiceAlert2", resourceCulture); } } diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index b9a42be38..51f29a9f1 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -411,7 +411,7 @@ Bitwarden App Extension - + The easiest way to add new logins to your vault is from the Bitwarden App Extension. Learn more about using the Bitwarden App Extension by navigating to the "Tools" screen. @@ -779,7 +779,7 @@ Beta - + The easiest way to add new logins to your vault is from the Bitwarden Auto-fill Service. Learn more about using the Bitwarden Auto-fill Service by navigating to the "Tools" screen. @@ -1343,7 +1343,7 @@ Password AutoFill - + The easiest way to add new logins to your vault is by using the Bitwarden Password AutoFill extension. Learn more about using the Bitwarden Password AutoFill extension by navigating to the "Tools" screen. diff --git a/src/Core/Constants.cs b/src/Core/Constants.cs index b4f14b225..dbb546c99 100644 --- a/src/Core/Constants.cs +++ b/src/Core/Constants.cs @@ -27,6 +27,7 @@ public static string LastClipboardValueKey = "lastClipboardValue"; public static string LastBuildKey = "lastBuild"; public static string OldUserIdKey = "userId"; + public static string AddSitePromptShownKey = "addSitePromptShown"; public const int SelectFileRequestCode = 42; public const int SelectFilePermissionRequestCode = 43; }