improvement to lock screen

This commit is contained in:
Kyle Spearrin 2019-06-28 11:47:04 -04:00
parent caa0af1258
commit 9145fa1c48
6 changed files with 45 additions and 15 deletions

View file

@ -97,5 +97,11 @@ namespace Bit.Core.Utilities
}
throw new Exception($"Service {serviceName} is not registered.");
}
public static void Reset()
{
Inited = false;
RegisteredServices.Clear();
}
}
}

View file

@ -39,7 +39,7 @@ namespace Bit.iOS.Core.Controllers
public abstract Action Cancel { get; }
public FormEntryTableViewCell MasterPasswordCell { get; set; } = new FormEntryTableViewCell(
AppResources.MasterPassword, useLabelAsPlaceholder: true);
AppResources.MasterPassword);
public override void ViewWillAppear(bool animated)
{
@ -70,7 +70,7 @@ namespace Bit.iOS.Core.Controllers
var descriptor = UIFontDescriptor.PreferredBody;
MasterPasswordCell.TextField.Placeholder = _pinLock ? AppResources.PIN : AppResources.MasterPassword;
MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword;
MasterPasswordCell.TextField.SecureTextEntry = true;
MasterPasswordCell.TextField.ReturnKeyType = UIReturnKeyType.Go;
MasterPasswordCell.TextField.ShouldReturn += (UITextField tf) =>
@ -78,6 +78,10 @@ namespace Bit.iOS.Core.Controllers
CheckPasswordAsync().GetAwaiter().GetResult();
return true;
};
if(_pinLock)
{
MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad;
}
TableView.RowHeight = UITableView.AutomaticDimension;
TableView.EstimatedRowHeight = 70;
@ -94,7 +98,7 @@ namespace Bit.iOS.Core.Controllers
var tasks = Task.Run(async () =>
{
await Task.Delay(500);
PromptFingerprintAsync().GetAwaiter().GetResult();
NSRunLoop.Main.BeginInvokeOnMainThread(async () => await PromptFingerprintAsync());
});
}
}
@ -108,8 +112,6 @@ namespace Bit.iOS.Core.Controllers
}
}
// TODO: Try fingerprint again button action
protected async Task CheckPasswordAsync()
{
if(string.IsNullOrWhiteSpace(MasterPasswordCell.TextField.Text))
@ -254,6 +256,16 @@ namespace Bit.iOS.Core.Controllers
return _controller.MasterPasswordCell;
}
}
else if(indexPath.Section == 1)
{
if(indexPath.Row == 0)
{
var cell = new UITableViewCell();
cell.TextLabel.TextColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
cell.TextLabel.Text = AppResources.UseFingerprintToUnlock;
return cell;
}
}
return new UITableViewCell();
}
@ -264,12 +276,12 @@ namespace Bit.iOS.Core.Controllers
public override nint NumberOfSections(UITableView tableView)
{
return 1;
return _controller._fingerprintLock ? 2 : 1;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
if(section == 0)
if(section <= 1)
{
return 1;
}
@ -278,7 +290,7 @@ namespace Bit.iOS.Core.Controllers
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
{
return UITableView.AutomaticDimension;
return section == 1 ? 0.00001f : UITableView.AutomaticDimension;
}
public override string TitleForHeader(UITableView tableView, nint section)
@ -290,6 +302,11 @@ namespace Bit.iOS.Core.Controllers
{
tableView.DeselectRow(indexPath, true);
tableView.EndEditing(true);
if(indexPath.Section == 1 && indexPath.Row == 0)
{
var task = _controller.PromptFingerprintAsync();
return;
}
var cell = tableView.CellAt(indexPath);
if(cell == null)
{

View file

@ -22,9 +22,9 @@ namespace Bit.iOS.Core.Controllers
private IFolderService _folderService;
private IEnumerable<FolderView> _folders;
public LoginAddViewController(IntPtr handle) : base(handle)
{
}
public LoginAddViewController(IntPtr handle)
: base(handle)
{ }
public AppExtensionContext Context { get; set; }
public FormEntryTableViewCell NameCell { get; set; } = new FormEntryTableViewCell(AppResources.Name);

View file

@ -182,7 +182,11 @@ namespace Bit.iOS.Extension
var resultsProvider = new NSItemProvider(itemData, UTType.PropertyList);
var resultsItem = new NSExtensionItem { Attachments = new NSItemProvider[] { resultsProvider } };
var returningItems = new NSExtensionItem[] { resultsItem };
NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CompleteRequest(returningItems, null));
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
{
ServiceContainer.Reset();
ExtensionContext?.CompleteRequest(returningItems, null);
});
}
private bool ProcessItemProvider(NSItemProvider itemProvider, string type, Action<NSDictionary> dictAction,

View file

@ -5,7 +5,8 @@ namespace Bit.iOS.Extension
{
public partial class LockPasswordViewController : Core.Controllers.LockPasswordViewController
{
public LockPasswordViewController(IntPtr handle) : base(handle)
public LockPasswordViewController(IntPtr handle)
: base(handle)
{ }
public LoadingViewController LoadingController { get; set; }

View file

@ -276,8 +276,10 @@ namespace Bit.iOS
private void ShowAppExtension()
{
var itemProvider = new NSItemProvider(new NSDictionary(), Core.Constants.UTTypeAppExtensionSetup);
var extensionItem = new NSExtensionItem();
extensionItem.Attachments = new NSItemProvider[] { itemProvider };
var extensionItem = new NSExtensionItem
{
Attachments = new NSItemProvider[] { itemProvider }
};
var activityViewController = new UIActivityViewController(new NSExtensionItem[] { extensionItem }, null);
activityViewController.CompletionHandler = (activityType, completed) =>
{