autofill service page

This commit is contained in:
Kyle Spearrin 2019-06-03 12:19:42 -04:00
parent 22f16ea514
commit c27e44a7d2
8 changed files with 171 additions and 9 deletions

View File

@ -51,6 +51,9 @@
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
</Compile>
<Compile Update="Pages\Settings\AutofillServicePage.xaml.cs">
<DependentUpon>AutofillServicePage.xaml</DependentUpon>
</Compile>
<Compile Update="Pages\Settings\FolderAddEditPage.xaml.cs">
<DependentUpon>FolderAddEditPage.xaml</DependentUpon>
</Compile>

View File

@ -27,7 +27,8 @@
LineBreakMode="WordWrap" />
<StackLayout IsVisible="{Binding Enabled, Converter={StaticResource inverseBool}}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center">
HorizontalOptions="Center"
Spacing="20">
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Label Text="{u:I18n Status}" />
<Label Text="{u:I18n Disabled}"
@ -54,7 +55,8 @@
</StackLayout>
<StackLayout IsVisible="{Binding Enabled}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center">
HorizontalOptions="Center"
Spacing="20">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="{u:I18n Status}" />
<Label Text="{u:I18n Enabled}"

View File

@ -1,6 +1,5 @@
using Bit.App.Abstractions;
using Bit.App.Resources;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
namespace Bit.App.Pages
@ -8,14 +7,12 @@ namespace Bit.App.Pages
public class AccessibilityServicePageViewModel : BaseViewModel
{
private readonly IDeviceActionService _deviceActionService;
private readonly IPlatformUtilsService _platformUtilsService;
private bool _enabled;
public AccessibilityServicePageViewModel()
{
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
PageTitle = AppResources.AutofillAccessibilityService;
}

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<pages:BaseContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.AutofillServicePage"
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:u="clr-namespace:Bit.App.Utilities"
x:DataType="pages:AutofillServicePageViewModel"
Title="{Binding PageTitle}">
<ContentPage.BindingContext>
<pages:AutofillServicePageViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<u:InverseBoolConverter x:Key="inverseBool" />
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<StackLayout Spacing="20"
Padding="10, 30"
VerticalOptions="FillAndExpand">
<Label Text="{u:I18n AutofillServiceDescription}"
VerticalOptions="Start"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap" />
<StackLayout IsVisible="{Binding Enabled, Converter={StaticResource inverseBool}}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Spacing="20">
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Label Text="{u:I18n Status}" />
<Label Text="{u:I18n Disabled}"
StyleClass="text-danger, text-bold" />
</StackLayout>
<Image Source="autofill_enable.png"
HorizontalOptions="Center"
Margin="0, 20, 0, 0"
WidthRequest="300"
HeightRequest="118" />
</StackLayout>
<StackLayout IsVisible="{Binding Enabled}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Spacing="20">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="{u:I18n Status}" />
<Label Text="{u:I18n Enabled}"
StyleClass="text-success, text-bold" />
</StackLayout>
<Image Source="autofill_use.png"
HorizontalOptions="Center"
Margin="0, 20, 0, 0"
WidthRequest="300"
HeightRequest="128" />
</StackLayout>
<Button Text="{u:I18n BitwardenAutofillServiceOpenAutofillSettings}"
Clicked="Settings_Clicked"
HorizontalOptions="Fill"
VerticalOptions="End"></Button>
</StackLayout>
</ScrollView>
</pages:BaseContentPage>

View File

@ -0,0 +1,52 @@
using System;
using Xamarin.Forms;
namespace Bit.App.Pages
{
public partial class AutofillServicePage : BaseContentPage
{
private readonly AutofillServicePageViewModel _vm;
private readonly SettingsPage _settingsPage;
private DateTime? _timerStarted = null;
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(5);
public AutofillServicePage(SettingsPage settingsPage)
{
InitializeComponent();
_vm = BindingContext as AutofillServicePageViewModel;
_vm.Page = this;
_settingsPage = settingsPage;
}
protected override void OnAppearing()
{
_vm.UpdateEnabled();
_timerStarted = DateTime.UtcNow;
Device.StartTimer(new TimeSpan(0, 0, 2), () =>
{
if(_timerStarted == null || (DateTime.UtcNow - _timerStarted) > _timerMaxLength)
{
return false;
}
_vm.UpdateEnabled();
return true;
});
base.OnAppearing();
}
protected override void OnDisappearing()
{
_timerStarted = null;
_settingsPage.BuildList();
base.OnDisappearing();
}
private void Settings_Clicked(object sender, EventArgs e)
{
if(DoOnce())
{
_vm.OpenSettings();
}
}
}
}

View File

@ -0,0 +1,35 @@
using Bit.App.Abstractions;
using Bit.App.Resources;
using Bit.Core.Utilities;
namespace Bit.App.Pages
{
public class AutofillServicePageViewModel : BaseViewModel
{
private readonly IDeviceActionService _deviceActionService;
private bool _enabled;
public AutofillServicePageViewModel()
{
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
PageTitle = AppResources.AutofillService;
}
public bool Enabled
{
get => _enabled;
set => SetProperty(ref _enabled, value);
}
public void OpenSettings()
{
_deviceActionService.OpenAutofillSettings();
}
public void UpdateEnabled()
{
Enabled = _deviceActionService.AutofillServiceEnabled();
}
}
}

View File

@ -63,7 +63,7 @@ namespace Bit.App.Pages
}
else if(item.Name == AppResources.AutofillService)
{
// await Navigation.PushModalAsync(new NavigationPage(new OptionsPage()));
await Navigation.PushModalAsync(new NavigationPage(new AutofillServicePage(this)));
}
else if(item.Name == AppResources.PasswordAutofill)
{

View File

@ -15,11 +15,15 @@
Value="{StaticResource TextColor}" />
</Style>
<Style TargetType="Label"
Class="text-default"
x:Key="text-default">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
</Style>
<Style TargetType="Label"
Class="text-default">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
</Style>
<Style TargetType="Label"
Class="text-muted"
ApplyToDerivedTypes="True">
@ -27,11 +31,15 @@
Value="{StaticResource MutedColor}" />
</Style>
<Style TargetType="Label"
Class="text-danger"
x:Key="text-danger">
<Setter Property="TextColor"
Value="{StaticResource DangerColor}" />
</Style>
<Style TargetType="Label"
Class="text-danger">
<Setter Property="TextColor"
Value="{StaticResource DangerColor}" />
</Style>
<Style TargetType="Label"
Class="text-success">
<Setter Property="TextColor"
@ -63,7 +71,7 @@
<Setter Property="ThumbBorderColor"
Value="{StaticResource SliderThumbBorderColor}" />
</Style>
<!-- Pages -->
<Style TargetType="TabbedPage"
ApplyToDerivedTypes="True">