From b356627afdea46f8e892f0f54f88486be63f9cb3 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 30 May 2019 22:45:48 -0400 Subject: [PATCH] autofill rows on settings page --- src/Android/Services/DeviceActionService.cs | 2 +- .../SettingsPage/SettingsPage.xaml.cs | 29 ++++++++++++++----- .../SettingsPage/SettingsPageViewModel.cs | 26 +++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index 2e97fdec3..3f649ad96 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -498,7 +498,7 @@ namespace Bit.Droid.Services var manager = activity.GetSystemService(Context.ActivityService) as ActivityManager; var services = manager.GetRunningServices(int.MaxValue); return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") && - s.Service.ClassName.ToLowerInvariant().Contains("autofill")); + s.Service.ClassName.ToLowerInvariant().Contains("accessibilityservice")); } public bool AutofillServiceEnabled() diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml.cs b/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml.cs index cac5f1983..792f142d4 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml.cs @@ -1,21 +1,20 @@ -using Bit.App.Resources; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Bit.App.Abstractions; +using Bit.App.Resources; +using Bit.Core.Utilities; using Xamarin.Forms; -using Xamarin.Forms.Xaml; namespace Bit.App.Pages { public partial class SettingsPage : BaseContentPage { + private readonly IDeviceActionService _deviceActionService; + private SettingsPageViewModel _vm; public SettingsPage() { InitializeComponent(); + _deviceActionService = ServiceContainer.Resolve("deviceActionService"); _vm = BindingContext as SettingsPageViewModel; _vm.Page = this; } @@ -42,6 +41,22 @@ namespace Bit.App.Pages { await Navigation.PushModalAsync(new NavigationPage(new SyncPage())); } + else if(item.Name == AppResources.AutofillAccessibilityService) + { + // await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); + } + else if(item.Name == AppResources.AutofillService) + { + // await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); + } + else if(item.Name == AppResources.PasswordAutofill) + { + // await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); + } + else if(item.Name == AppResources.AppExtension) + { + // await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); + } else if(item.Name == AppResources.Options) { await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs index a7c1adb68..e65dc8b93 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs @@ -259,6 +259,31 @@ namespace Bit.App.Pages private void BuildList() { var doUpper = Device.RuntimePlatform != Device.Android; + var autofillItems = new List(); + if(Device.RuntimePlatform == Device.Android) + { + if(_deviceActionService.SupportsAutofillService()) + { + autofillItems.Add(new SettingsPageListItem + { + Name = AppResources.AutofillService, + SubLabel = _deviceActionService.AutofillServiceEnabled() ? "✓" : null + }); + } + autofillItems.Add(new SettingsPageListItem + { + Name = AppResources.AutofillAccessibilityService, + SubLabel = _deviceActionService.AutofillAccessibilityServiceRunning() ? "✓" : null + }); + } + else + { + if(_deviceActionService.SystemMajorVersion() >= 12) + { + autofillItems.Add(new SettingsPageListItem { Name = AppResources.PasswordAutofill }); + } + autofillItems.Add(new SettingsPageListItem { Name = AppResources.AppExtension }); + } var manageItems = new List { new SettingsPageListItem { Name = AppResources.Folders }, @@ -302,6 +327,7 @@ namespace Bit.App.Pages }; GroupedItems.ResetWithRange(new List { + new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper), new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper), new SettingsPageListGroup(securityItems, AppResources.Security, doUpper), new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),