bitwarden-android/src/App/Pages/Settings/OptionsPage.xaml.cs

66 lines
2.3 KiB
C#
Raw Normal View History

using Bit.App.Abstractions;
using Bit.App.Resources;
using Bit.Core.Utilities;
2019-05-29 21:11:15 +03:00
using Xamarin.Forms;
2019-06-25 00:32:24 +03:00
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
2019-05-29 16:08:47 +03:00
namespace Bit.App.Pages
{
public partial class OptionsPage : BaseContentPage
{
private readonly IDeviceActionService _deviceActionService;
2019-05-29 16:08:47 +03:00
private readonly OptionsPageViewModel _vm;
public OptionsPage()
{
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
2019-05-29 16:08:47 +03:00
InitializeComponent();
_vm = BindingContext as OptionsPageViewModel;
_vm.Page = this;
2019-05-29 21:11:15 +03:00
_themePicker.ItemDisplayBinding = new Binding("Value");
_uriMatchPicker.ItemDisplayBinding = new Binding("Value");
_clearClipboardPicker.ItemDisplayBinding = new Binding("Value");
2019-05-30 06:02:30 +03:00
if(Device.RuntimePlatform == Device.Android)
{
2019-06-12 04:31:51 +03:00
ToolbarItems.RemoveAt(0);
_vm.ShowAndroidAccessibilitySettings = true;
_vm.ShowAndroidAutofillSettings = _deviceActionService.SupportsAutofillService();
2019-05-30 06:02:30 +03:00
_themeDescriptionLabel.Text = string.Concat(_themeDescriptionLabel.Text, " ",
AppResources.RestartIsRequired);
}
2019-06-25 00:32:24 +03:00
else
{
_themePicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
_uriMatchPicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
_clearClipboardPicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
}
2019-05-29 16:08:47 +03:00
}
2019-05-29 16:36:57 +03:00
protected async override void OnAppearing()
2019-05-29 16:08:47 +03:00
{
base.OnAppearing();
2019-05-29 16:36:57 +03:00
await _vm.InitAsync();
2019-05-29 16:08:47 +03:00
}
2019-06-03 17:45:27 +03:00
protected async override void OnDisappearing()
{
base.OnDisappearing();
await _vm.UpdateAutofillBlacklistedUris();
}
private async void BlacklistedUrisEditor_Unfocused(object sender, FocusEventArgs e)
{
await _vm.UpdateAutofillBlacklistedUris();
}
2019-06-12 04:31:51 +03:00
private async void Close_Clicked(object sender, System.EventArgs e)
{
if(DoOnce())
{
await Navigation.PopModalAsync();
}
}
2019-05-29 16:08:47 +03:00
}
}