autofill rows on settings page

This commit is contained in:
Kyle Spearrin 2019-05-30 22:45:48 -04:00
parent e3dcf4aed1
commit b356627afd
3 changed files with 49 additions and 8 deletions

View File

@ -498,7 +498,7 @@ namespace Bit.Droid.Services
var manager = activity.GetSystemService(Context.ActivityService) as ActivityManager; var manager = activity.GetSystemService(Context.ActivityService) as ActivityManager;
var services = manager.GetRunningServices(int.MaxValue); var services = manager.GetRunningServices(int.MaxValue);
return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") && return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") &&
s.Service.ClassName.ToLowerInvariant().Contains("autofill")); s.Service.ClassName.ToLowerInvariant().Contains("accessibilityservice"));
} }
public bool AutofillServiceEnabled() public bool AutofillServiceEnabled()

View File

@ -1,21 +1,20 @@
using Bit.App.Resources; using Bit.App.Abstractions;
using System; using Bit.App.Resources;
using System.Collections.Generic; using Bit.Core.Utilities;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
public partial class SettingsPage : BaseContentPage public partial class SettingsPage : BaseContentPage
{ {
private readonly IDeviceActionService _deviceActionService;
private SettingsPageViewModel _vm; private SettingsPageViewModel _vm;
public SettingsPage() public SettingsPage()
{ {
InitializeComponent(); InitializeComponent();
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_vm = BindingContext as SettingsPageViewModel; _vm = BindingContext as SettingsPageViewModel;
_vm.Page = this; _vm.Page = this;
} }
@ -42,6 +41,22 @@ namespace Bit.App.Pages
{ {
await Navigation.PushModalAsync(new NavigationPage(new SyncPage())); 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) else if(item.Name == AppResources.Options)
{ {
await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); await Navigation.PushModalAsync(new NavigationPage(new OptionsPage()));

View File

@ -259,6 +259,31 @@ namespace Bit.App.Pages
private void BuildList() private void BuildList()
{ {
var doUpper = Device.RuntimePlatform != Device.Android; var doUpper = Device.RuntimePlatform != Device.Android;
var autofillItems = new List<SettingsPageListItem>();
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<SettingsPageListItem> var manageItems = new List<SettingsPageListItem>
{ {
new SettingsPageListItem { Name = AppResources.Folders }, new SettingsPageListItem { Name = AppResources.Folders },
@ -302,6 +327,7 @@ namespace Bit.App.Pages
}; };
GroupedItems.ResetWithRange(new List<SettingsPageListGroup> GroupedItems.ResetWithRange(new List<SettingsPageListGroup>
{ {
new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper),
new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper), new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
new SettingsPageListGroup(securityItems, AppResources.Security, doUpper), new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
new SettingsPageListGroup(accountItems, AppResources.Account, doUpper), new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),