CanAutoFill logic for extension

This commit is contained in:
Kyle Spearrin 2016-08-02 19:56:51 -04:00
parent ae37c634ef
commit 009006fa70

View file

@ -10,6 +10,8 @@ using XLabs.Ioc;
using Plugin.Settings.Abstractions;
using Bit.iOS.Core.Utilities;
using System.Threading.Tasks;
using Bit.iOS.Core;
using MobileCoreServices;
namespace Bit.iOS.Extension
{
@ -31,8 +33,7 @@ namespace Bit.iOS.Extension
public async override void ViewDidLoad()
{
base.ViewDidLoad();
if(!Context?.Details?.HasPasswordField ?? false)
if(!CanAutoFill())
{
CancelBarButton.Title = "Close";
}
@ -43,6 +44,19 @@ namespace Bit.iOS.Extension
await ((TableSource)TableView.Source).LoadItemsAsync();
}
public bool CanAutoFill()
{
if(Context.ProviderType != Constants.UTTypeAppExtensionFillBrowserAction
&& Context.ProviderType != Constants.UTTypeAppExtensionFillWebViewAction
&& Context.ProviderType != UTType.PropertyList)
{
return true;
}
return Context.Details?.HasPasswordField ?? false;
}
partial void CancelBarButton_Activated(UIBarButtonItem sender)
{
LoadingController.CompleteRequest(null);
@ -168,7 +182,7 @@ namespace Bit.iOS.Extension
return;
}
if(_context?.Details?.HasPasswordField ?? false && !string.IsNullOrWhiteSpace(item.Password))
if(_controller.CanAutoFill() && !string.IsNullOrWhiteSpace(item.Password))
{
_controller.LoadingController.CompleteUsernamePasswordRequest(item.Username, item.Password);
}