8 changed files with 216 additions and 2 deletions
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
<?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.AccessibilityServicePage" |
||||
xmlns:pages="clr-namespace:Bit.App.Pages" |
||||
xmlns:u="clr-namespace:Bit.App.Utilities" |
||||
x:DataType="pages:AccessibilityServicePageViewModel" |
||||
Title="{Binding PageTitle}"> |
||||
<ContentPage.BindingContext> |
||||
<pages:AccessibilityServicePageViewModel /> |
||||
</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 AutofillAccessibilityDescription}" |
||||
VerticalOptions="Start" |
||||
HorizontalTextAlignment="Center" |
||||
LineBreakMode="WordWrap" /> |
||||
<StackLayout IsVisible="{Binding Enabled, Converter={StaticResource inverseBool}}" |
||||
VerticalOptions="CenterAndExpand" |
||||
HorizontalOptions="Center"> |
||||
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand"> |
||||
<Label Text="{u:I18n Status}" /> |
||||
<Label Text="{u:I18n Disabled}" |
||||
StyleClass="text-danger, text-bold" /> |
||||
</StackLayout> |
||||
<Image Source="accessibility_step1.png" |
||||
HorizontalOptions="Center" |
||||
Margin="0, 20, 0, 0" |
||||
WidthRequest="300" |
||||
HeightRequest="98" /> |
||||
<Label Text="{u:I18n BitwardenAutofillServiceStep1}" |
||||
HorizontalTextAlignment="Center" |
||||
LineBreakMode="WordWrap" |
||||
StyleClass="text-sm" /> |
||||
<Image Source="accessibility_step2.png" |
||||
HorizontalOptions="Center" |
||||
Margin="0, 20, 0, 0" |
||||
WidthRequest="300" |
||||
HeightRequest="67" /> |
||||
<Label Text="{u:I18n BitwardenAutofillServiceStep2}" |
||||
HorizontalTextAlignment="Center" |
||||
LineBreakMode="WordWrap" |
||||
StyleClass="text-sm" /> |
||||
</StackLayout> |
||||
<StackLayout IsVisible="{Binding Enabled}" |
||||
VerticalOptions="CenterAndExpand" |
||||
HorizontalOptions="Center"> |
||||
<StackLayout Orientation="Horizontal" HorizontalOptions="Center"> |
||||
<Label Text="{u:I18n Status}" /> |
||||
<Label Text="{u:I18n Enabled}" |
||||
StyleClass="text-success, text-bold" /> |
||||
</StackLayout> |
||||
<Image Source="accessibility_notification_icon.png" |
||||
HorizontalOptions="Center" |
||||
Margin="0, 20, 0, 0" |
||||
WidthRequest="300" |
||||
HeightRequest="54" /> |
||||
<Image Source="accessibility_notification.png" |
||||
HorizontalOptions="Center" |
||||
Margin="0, 20, 0, 0" |
||||
WidthRequest="300" |
||||
HeightRequest="74" /> |
||||
<Label Text="{u:I18n BitwardenAutofillServiceNotification}" |
||||
HorizontalTextAlignment="Center" |
||||
LineBreakMode="WordWrap" |
||||
StyleClass="text-sm" /> |
||||
</StackLayout> |
||||
<Button Text="{u:I18n BitwardenAutofillServiceOpenAccessibilitySettings}" |
||||
Clicked="Settings_Clicked" |
||||
HorizontalOptions="Fill" |
||||
VerticalOptions="End"></Button> |
||||
</StackLayout> |
||||
</ScrollView> |
||||
|
||||
</pages:BaseContentPage> |
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
using System; |
||||
using Xamarin.Forms; |
||||
|
||||
namespace Bit.App.Pages |
||||
{ |
||||
public partial class AccessibilityServicePage : BaseContentPage |
||||
{ |
||||
private readonly AccessibilityServicePageViewModel _vm; |
||||
private readonly SettingsPage _settingsPage; |
||||
private DateTime? _timerStarted = null; |
||||
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(5); |
||||
|
||||
public AccessibilityServicePage(SettingsPage settingsPage) |
||||
{ |
||||
InitializeComponent(); |
||||
_vm = BindingContext as AccessibilityServicePageViewModel; |
||||
_vm.Page = this; |
||||
_settingsPage = settingsPage; |
||||
} |
||||
|
||||
protected override void OnAppearing() |
||||
{ |
||||
_vm.UpdateEnabled(); |
||||
_timerStarted = DateTime.UtcNow; |
||||
Device.StartTimer(new TimeSpan(0, 0, 3), () => |
||||
{ |
||||
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,38 @@
@@ -0,0 +1,38 @@
|
||||
using Bit.App.Abstractions; |
||||
using Bit.App.Resources; |
||||
using Bit.Core.Abstractions; |
||||
using Bit.Core.Utilities; |
||||
|
||||
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; |
||||
} |
||||
|
||||
public bool Enabled |
||||
{ |
||||
get => _enabled; |
||||
set => SetProperty(ref _enabled, value); |
||||
} |
||||
|
||||
public void OpenSettings() |
||||
{ |
||||
_deviceActionService.OpenAccessibilitySettings(); |
||||
} |
||||
|
||||
public void UpdateEnabled() |
||||
{ |
||||
Enabled = _deviceActionService.AutofillAccessibilityServiceRunning(); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue