mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
autofill service page
This commit is contained in:
parent
22f16ea514
commit
c27e44a7d2
8 changed files with 171 additions and 9 deletions
|
@ -51,6 +51,9 @@
|
||||||
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
|
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
|
||||||
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
|
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Pages\Settings\AutofillServicePage.xaml.cs">
|
||||||
|
<DependentUpon>AutofillServicePage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Pages\Settings\FolderAddEditPage.xaml.cs">
|
<Compile Update="Pages\Settings\FolderAddEditPage.xaml.cs">
|
||||||
<DependentUpon>FolderAddEditPage.xaml</DependentUpon>
|
<DependentUpon>FolderAddEditPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
LineBreakMode="WordWrap" />
|
LineBreakMode="WordWrap" />
|
||||||
<StackLayout IsVisible="{Binding Enabled, Converter={StaticResource inverseBool}}"
|
<StackLayout IsVisible="{Binding Enabled, Converter={StaticResource inverseBool}}"
|
||||||
VerticalOptions="CenterAndExpand"
|
VerticalOptions="CenterAndExpand"
|
||||||
HorizontalOptions="Center">
|
HorizontalOptions="Center"
|
||||||
|
Spacing="20">
|
||||||
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
|
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
|
||||||
<Label Text="{u:I18n Status}" />
|
<Label Text="{u:I18n Status}" />
|
||||||
<Label Text="{u:I18n Disabled}"
|
<Label Text="{u:I18n Disabled}"
|
||||||
|
@ -54,7 +55,8 @@
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout IsVisible="{Binding Enabled}"
|
<StackLayout IsVisible="{Binding Enabled}"
|
||||||
VerticalOptions="CenterAndExpand"
|
VerticalOptions="CenterAndExpand"
|
||||||
HorizontalOptions="Center">
|
HorizontalOptions="Center"
|
||||||
|
Spacing="20">
|
||||||
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
|
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
|
||||||
<Label Text="{u:I18n Status}" />
|
<Label Text="{u:I18n Status}" />
|
||||||
<Label Text="{u:I18n Enabled}"
|
<Label Text="{u:I18n Enabled}"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
using Bit.App.Resources;
|
using Bit.App.Resources;
|
||||||
using Bit.Core.Abstractions;
|
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
|
@ -8,14 +7,12 @@ namespace Bit.App.Pages
|
||||||
public class AccessibilityServicePageViewModel : BaseViewModel
|
public class AccessibilityServicePageViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
private readonly IPlatformUtilsService _platformUtilsService;
|
|
||||||
|
|
||||||
private bool _enabled;
|
private bool _enabled;
|
||||||
|
|
||||||
public AccessibilityServicePageViewModel()
|
public AccessibilityServicePageViewModel()
|
||||||
{
|
{
|
||||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
|
||||||
PageTitle = AppResources.AutofillAccessibilityService;
|
PageTitle = AppResources.AutofillAccessibilityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
65
src/App/Pages/Settings/AutofillServicePage.xaml
Normal file
65
src/App/Pages/Settings/AutofillServicePage.xaml
Normal 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>
|
52
src/App/Pages/Settings/AutofillServicePage.xaml.cs
Normal file
52
src/App/Pages/Settings/AutofillServicePage.xaml.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,7 +63,7 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
else if(item.Name == AppResources.AutofillService)
|
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)
|
else if(item.Name == AppResources.PasswordAutofill)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,11 +15,15 @@
|
||||||
Value="{StaticResource TextColor}" />
|
Value="{StaticResource TextColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
Class="text-default"
|
|
||||||
x:Key="text-default">
|
x:Key="text-default">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource TextColor}" />
|
Value="{StaticResource TextColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style TargetType="Label"
|
||||||
|
Class="text-default">
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource TextColor}" />
|
||||||
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
Class="text-muted"
|
Class="text-muted"
|
||||||
ApplyToDerivedTypes="True">
|
ApplyToDerivedTypes="True">
|
||||||
|
@ -27,11 +31,15 @@
|
||||||
Value="{StaticResource MutedColor}" />
|
Value="{StaticResource MutedColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
Class="text-danger"
|
|
||||||
x:Key="text-danger">
|
x:Key="text-danger">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource DangerColor}" />
|
Value="{StaticResource DangerColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style TargetType="Label"
|
||||||
|
Class="text-danger">
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource DangerColor}" />
|
||||||
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
Class="text-success">
|
Class="text-success">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
|
@ -63,7 +71,7 @@
|
||||||
<Setter Property="ThumbBorderColor"
|
<Setter Property="ThumbBorderColor"
|
||||||
Value="{StaticResource SliderThumbBorderColor}" />
|
Value="{StaticResource SliderThumbBorderColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!-- Pages -->
|
<!-- Pages -->
|
||||||
<Style TargetType="TabbedPage"
|
<Style TargetType="TabbedPage"
|
||||||
ApplyToDerivedTypes="True">
|
ApplyToDerivedTypes="True">
|
||||||
|
|
Loading…
Reference in a new issue