diff --git a/src/App/Pages/Settings/OptionsPage.xaml b/src/App/Pages/Settings/OptionsPage.xaml index 969d5fffa..3b8120ab4 100644 --- a/src/App/Pages/Settings/OptionsPage.xaml +++ b/src/App/Pages/Settings/OptionsPage.xaml @@ -90,54 +90,94 @@ Text="{u:I18n DisableWebsiteIconsDescription}" StyleClass="box-footer-label" /> - - - - + + + + + + - - - + + + - - - + + + + + + + + + + + + + - diff --git a/src/App/Pages/Settings/OptionsPage.xaml.cs b/src/App/Pages/Settings/OptionsPage.xaml.cs index 5928ff37f..f4ed5551a 100644 --- a/src/App/Pages/Settings/OptionsPage.xaml.cs +++ b/src/App/Pages/Settings/OptionsPage.xaml.cs @@ -19,6 +19,7 @@ namespace Bit.App.Pages _clearClipboardPicker.ItemDisplayBinding = new Binding("Value"); if(Device.RuntimePlatform == Device.Android) { + _vm.AndroidOptions = true; _themeDescriptionLabel.Text = string.Concat(_themeDescriptionLabel.Text, " ", AppResources.RestartIsRequired); } @@ -29,5 +30,16 @@ namespace Bit.App.Pages base.OnAppearing(); await _vm.InitAsync(); } + + protected async override void OnDisappearing() + { + base.OnDisappearing(); + await _vm.UpdateAutofillBlacklistedUris(); + } + + private async void BlacklistedUrisEditor_Unfocused(object sender, FocusEventArgs e) + { + await _vm.UpdateAutofillBlacklistedUris(); + } } } diff --git a/src/App/Pages/Settings/OptionsPageViewModel.cs b/src/App/Pages/Settings/OptionsPageViewModel.cs index ad50cc194..4059f6e52 100644 --- a/src/App/Pages/Settings/OptionsPageViewModel.cs +++ b/src/App/Pages/Settings/OptionsPageViewModel.cs @@ -24,6 +24,8 @@ namespace Bit.App.Pages private bool _autofillAlwaysScan; private bool _autofillPersistNotification; private bool _autofillPasswordField; + private bool _autofillDisableSavePrompt; + private string _autofillBlacklistedUris; private bool _disableFavicon; private bool _disableAutoTotpCopy; private int _clearClipboardSelectedIndex; @@ -31,6 +33,7 @@ namespace Bit.App.Pages private int _uriMatchSelectedIndex; private bool _inited; private bool _updatingAutofill; + private bool _androidOptions; public OptionsPageViewModel() { @@ -174,8 +177,37 @@ namespace Bit.App.Pages } } + public bool AutofillDisableSavePrompt + { + get => _autofillDisableSavePrompt; + set + { + if(SetProperty(ref _autofillDisableSavePrompt, value)) + { + var task = UpdateAutofillDisableSavePromptAsync(); + } + } + } + + public string AutofillBlacklistedUris + { + get => _autofillBlacklistedUris; + set => SetProperty(ref _autofillBlacklistedUris, value); + } + + public bool AndroidOptions + { + get => _androidOptions; + set => SetProperty(ref _androidOptions, value); + } + public async Task InitAsync() { + AutofillDisableSavePrompt = (await _storageService.GetAsync( + Constants.AutofillDisableSavePromptKey)).GetValueOrDefault(); + var blacklistedUrisList = await _storageService.GetAsync>( + Constants.AutofillBlacklistedUrisKey); + AutofillBlacklistedUris = blacklistedUrisList != null ? string.Join(", ", blacklistedUrisList) : null; AutofillPersistNotification = (await _storageService.GetAsync( Constants.AccessibilityAutofillPersistNotificationKey)).GetValueOrDefault(); AutofillPasswordField = (await _storageService.GetAsync( @@ -271,5 +303,43 @@ namespace Bit.App.Pages (int?)UriMatchOptions[UriMatchSelectedIndex].Key); } } + + private async Task UpdateAutofillDisableSavePromptAsync() + { + if(_inited) + { + await _storageService.SaveAsync(Constants.AutofillDisableSavePromptKey, AutofillDisableSavePrompt); + } + } + + public async Task UpdateAutofillBlacklistedUris() + { + if(_inited) + { + if(string.IsNullOrWhiteSpace(AutofillBlacklistedUris)) + { + await _storageService.RemoveAsync(Constants.AutofillBlacklistedUrisKey); + AutofillBlacklistedUris = null; + return; + } + try + { + var csv = AutofillBlacklistedUris; + var urisList = new List(); + foreach(var uri in csv.Split(',')) + { + if(!uri.StartsWith("http://") && !uri.StartsWith("https://") && + !uri.StartsWith(Constants.AndroidAppProtocol)) + { + continue; + } + urisList.Add(uri.Replace("\\n", string.Empty).Trim()); + } + await _storageService.SaveAsync(Constants.AutofillBlacklistedUrisKey, urisList); + AutofillBlacklistedUris = string.Join(", ", urisList); + } + catch { } + } + } } } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 6ba0da97a..a6bd7d970 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -735,6 +735,24 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Blacklisted URIs. + /// + public static string BlacklistedUris { + get { + return ResourceManager.GetString("BlacklistedUris", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to URIs that are blacklisted will not offer auto-fill. The list of apps should be comma separated. Ex: "https://twitter.com, androidapp://com.twitter.android".. + /// + public static string BlacklistedUrisDescription { + get { + return ResourceManager.GetString("BlacklistedUrisDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to Brand. /// @@ -1230,6 +1248,24 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Disable Save Prompt. + /// + public static string DisableSavePrompt { + get { + return ResourceManager.GetString("DisableSavePrompt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The "Save Prompt" automatically prompts you to save new items to your vault whenever you enter them for the first time.. + /// + public static string DisableSavePromptDescription { + get { + return ResourceManager.GetString("DisableSavePromptDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to Disable Website Icons. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 04434072d..3505b418a 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1580,4 +1580,16 @@ Black The color black + + Blacklisted URIs + + + URIs that are blacklisted will not offer auto-fill. The list of apps should be comma separated. Ex: "https://twitter.com, androidapp://com.twitter.android". + + + Disable Save Prompt + + + The "Save Prompt" automatically prompts you to save new items to your vault whenever you enter them for the first time. + \ No newline at end of file diff --git a/src/Core/Constants.cs b/src/Core/Constants.cs index 961ccd159..b4f14b225 100644 --- a/src/Core/Constants.cs +++ b/src/Core/Constants.cs @@ -15,6 +15,8 @@ public static string LastFileCacheClearKey = "lastFileCacheClear"; public static string AccessibilityAutofillPasswordFieldKey = "accessibilityAutofillPasswordField"; public static string AccessibilityAutofillPersistNotificationKey = "accessibilityAutofillPersistNotification"; + public static string AutofillDisableSavePromptKey = "autofillDisableSavePrompt"; + public static string AutofillBlacklistedUrisKey = "autofillBlacklistedUris"; public static string DisableFaviconKey = "disableFavicon"; public static string PushRegisteredTokenKey = "pushRegisteredToken"; public static string PushCurrentTokenKey = "pushCurrentToken";