mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
options page
This commit is contained in:
parent
d70de04816
commit
6c6da368dd
3 changed files with 86 additions and 3 deletions
|
@ -7,10 +7,42 @@
|
|||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||
x:DataType="pages:OptionsPageViewModel"
|
||||
Title="{Binding PageTitle}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<pages:OptionsPageViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
|
||||
<StackLayout Padding="0" Spacing="0">
|
||||
<StackLayout StyleClass="box">
|
||||
<StackLayout StyleClass="box-row, box-row-switch">
|
||||
<Label
|
||||
Text="{u:I18n DisableWebsiteIcons}"
|
||||
StyleClass="box-label, box-label-regular"
|
||||
HorizontalOptions="StartAndExpand" />
|
||||
<Switch
|
||||
IsToggled="{Binding DisableFavicon}"
|
||||
StyleClass="box-value"
|
||||
HorizontalOptions="End" />
|
||||
</StackLayout>
|
||||
<Label
|
||||
Text="{u:I18n DisableWebsiteIconsDescription}"
|
||||
StyleClass="box-footer-label" />
|
||||
</StackLayout>
|
||||
<StackLayout StyleClass="box">
|
||||
<StackLayout StyleClass="box-row, box-row-switch">
|
||||
<Label
|
||||
Text="{u:I18n DisableAutoTotpCopy}"
|
||||
StyleClass="box-label, box-label-regular"
|
||||
HorizontalOptions="StartAndExpand" />
|
||||
<Switch
|
||||
IsToggled="{Binding DisableAutoTotpCopy}"
|
||||
StyleClass="box-value"
|
||||
HorizontalOptions="End" />
|
||||
</StackLayout>
|
||||
<Label
|
||||
Text="{u:I18n DisableAutoTotpCopyDescription}"
|
||||
StyleClass="box-footer-label" />
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
|
||||
</pages:BaseContentPage>
|
||||
|
|
|
@ -13,9 +13,10 @@ namespace Bit.App.Pages
|
|||
_vm.Page = this;
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
protected async override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
await _vm.InitAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Bit.App.Abstractions;
|
||||
using Bit.App.Resources;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Utilities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -11,13 +11,63 @@ namespace Bit.App.Pages
|
|||
{
|
||||
private readonly IDeviceActionService _deviceActionService;
|
||||
private readonly IPlatformUtilsService _platformUtilsService;
|
||||
private readonly IStorageService _storageService;
|
||||
private readonly ITotpService _totpService;
|
||||
private readonly IStateService _stateService;
|
||||
|
||||
private bool _disableFavicon;
|
||||
private bool _disableAutoTotpCopy;
|
||||
|
||||
public OptionsPageViewModel()
|
||||
{
|
||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
_totpService = ServiceContainer.Resolve<ITotpService>("totpService");
|
||||
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
|
||||
|
||||
PageTitle = AppResources.Options;
|
||||
}
|
||||
|
||||
public bool DisableFavicon
|
||||
{
|
||||
get => _disableFavicon;
|
||||
set
|
||||
{
|
||||
if(SetProperty(ref _disableFavicon, value))
|
||||
{
|
||||
var task = UpdateDisableFaviconAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool DisableAutoTotpCopy
|
||||
{
|
||||
get => _disableAutoTotpCopy;
|
||||
set
|
||||
{
|
||||
if(SetProperty(ref _disableAutoTotpCopy, value))
|
||||
{
|
||||
var task = UpdateAutoTotpCopyAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task InitAsync()
|
||||
{
|
||||
DisableAutoTotpCopy = !(await _totpService.IsAutoCopyEnabledAsync());
|
||||
DisableFavicon = await _storageService.GetAsync<bool>(Constants.DisableFaviconKey);
|
||||
}
|
||||
|
||||
private async Task UpdateAutoTotpCopyAsync()
|
||||
{
|
||||
await _storageService.SaveAsync(Constants.DisableAutoTotpCopyKey, DisableAutoTotpCopy);
|
||||
}
|
||||
|
||||
private async Task UpdateDisableFaviconAsync()
|
||||
{
|
||||
await _storageService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
|
||||
await _stateService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue