diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 826ecafcf..ab09a781c 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -122,23 +122,7 @@ namespace Bit.iOS.Autofill } _context.CredentialIdentity = credentialIdentity; - var lockService = Resolver.Resolve(); - var lockType = lockService.GetLockTypeAsync(false).GetAwaiter().GetResult(); - switch(lockType) - { - case App.Enums.LockType.Fingerprint: - PerformSegue("lockFingerprintSegue", this); - break; - case App.Enums.LockType.PIN: - PerformSegue("lockPinSegue", this); - break; - case App.Enums.LockType.Password: - PerformSegue("lockPasswordSegue", this); - break; - default: - ProvideCredential(); - break; - } + CheckLock(() => ProvideCredential()); } public override void PrepareInterfaceForExtensionConfiguration() @@ -147,34 +131,17 @@ namespace Bit.iOS.Autofill _context.Configuring = true; var authService = Resolver.Resolve(); - if (!authService.IsAuthenticated) + if(!authService.IsAuthenticated) { var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainApp, AppResources.Ok, (a) => { - ExtensionContext.CompleteExtensionConfigurationRequest(); + CompleteRequest(); }); PresentViewController(alert, true, null); return; } - var lockService = Resolver.Resolve(); - var lockType = lockService.GetLockTypeAsync(false).GetAwaiter().GetResult(); - switch (lockType) - { - case App.Enums.LockType.Fingerprint: - PerformSegue("lockFingerprintSegue", this); - break; - case App.Enums.LockType.PIN: - PerformSegue("lockPinSegue", this); - break; - case App.Enums.LockType.Password: - PerformSegue("lockPasswordSegue", this); - break; - default: - var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve()); - ExtensionContext.CompleteExtensionConfigurationRequest(); - break; - } + CheckLock(() => PerformSegue("setupSegue", this)); } public void CompleteRequest(string username = null, string password = null, string totp = null) @@ -225,6 +192,7 @@ namespace Bit.iOS.Autofill var fingerprintViewController = navController.TopViewController as LockFingerprintViewController; var pinViewController = navController.TopViewController as LockPinViewController; var passwordViewController = navController.TopViewController as LockPasswordViewController; + var setupViewController = navController.TopViewController as SetupViewController; if(listLoginController != null) { @@ -243,6 +211,10 @@ namespace Bit.iOS.Autofill { passwordViewController.CPViewController = this; } + else if(setupViewController != null) + { + setupViewController.CPViewController = this; + } } } @@ -257,8 +229,7 @@ namespace Bit.iOS.Autofill } if(_context.Configuring) { - var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve()); - ExtensionContext.CompleteExtensionConfigurationRequest(); + PerformSegue("setupSegue", this); return; } PerformSegue("loginListSegue", this); @@ -282,6 +253,27 @@ namespace Bit.iOS.Autofill cipher.Login.Totp?.Decrypt(cipher.OrganizationId)); } + private void CheckLock(Action notLockedAction) + { + var lockService = Resolver.Resolve(); + var lockType = lockService.GetLockTypeAsync(false).GetAwaiter().GetResult(); + switch(lockType) + { + case App.Enums.LockType.Fingerprint: + PerformSegue("lockFingerprintSegue", this); + break; + case App.Enums.LockType.PIN: + PerformSegue("lockPinSegue", this); + break; + case App.Enums.LockType.Password: + PerformSegue("lockPasswordSegue", this); + break; + default: + notLockedAction(); + break; + } + } + private void SetIoc() { var container = new Container(); diff --git a/src/iOS.Autofill/MainInterface.storyboard b/src/iOS.Autofill/MainInterface.storyboard index d5f7b0484..2429a5475 100644 --- a/src/iOS.Autofill/MainInterface.storyboard +++ b/src/iOS.Autofill/MainInterface.storyboard @@ -33,6 +33,7 @@ + @@ -521,6 +522,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/iOS.Autofill/SetupViewController.cs b/src/iOS.Autofill/SetupViewController.cs new file mode 100644 index 000000000..fbd6604bb --- /dev/null +++ b/src/iOS.Autofill/SetupViewController.cs @@ -0,0 +1,49 @@ +using System; +using UIKit; +using Bit.iOS.Core.Controllers; +using Bit.App.Resources; +using Bit.iOS.Core.Utilities; +using XLabs.Ioc; +using Bit.App.Abstractions; + +namespace Bit.iOS.Autofill +{ + public partial class SetupViewController : ExtendedUIViewController + { + public SetupViewController(IntPtr handle) : base(handle) + { } + + public CredentialProviderViewController CPViewController { get; set; } + + public override void ViewWillAppear(bool animated) + { + UINavigationBar.Appearance.ShadowImage = new UIImage(); + UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); + base.ViewWillAppear(animated); + } + + public override void ViewDidLoad() + { + View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + var descriptor = UIFontDescriptor.PreferredBody; + DescriptionLabel.Text = $@"{AppResources.ExtensionSetup} + +{AppResources.ExtensionSetup2}"; + DescriptionLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize); + DescriptionLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); + + ActivatedLabel.Text = AppResources.ExtensionActivated; + ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f); + + BackButton.Title = AppResources.Back; + base.ViewDidLoad(); + + var tasks = ASHelpers.ReplaceAllIdentities(Resolver.Resolve()); + } + + partial void BackButton_Activated(UIBarButtonItem sender) + { + CPViewController.CompleteRequest(); + } + } +} diff --git a/src/iOS.Autofill/SetupViewController.designer.cs b/src/iOS.Autofill/SetupViewController.designer.cs new file mode 100644 index 000000000..01769480d --- /dev/null +++ b/src/iOS.Autofill/SetupViewController.designer.cs @@ -0,0 +1,69 @@ +// WARNING +// +// This file has been generated automatically by Xamarin Studio from the outlets and +// actions declared in your storyboard file. +// Manual changes to this file will not be maintained. +// +using Foundation; +using System; +using System.CodeDom.Compiler; +using UIKit; + +namespace Bit.iOS.Autofill +{ + [Register ("SetupViewController")] + partial class SetupViewController + { + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UILabel ActivatedLabel { get; set; } + + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UIBarButtonItem BackButton { get; set; } + + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UILabel DescriptionLabel { get; set; } + + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UIImageView IconImage { get; set; } + + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UINavigationItem NavItem { get; set; } + + [Action ("BackButton_Activated:")] + [GeneratedCode ("iOS Designer", "1.0")] + partial void BackButton_Activated (UIKit.UIBarButtonItem sender); + + void ReleaseDesignerOutlets () + { + if (ActivatedLabel != null) { + ActivatedLabel.Dispose (); + ActivatedLabel = null; + } + + if (BackButton != null) { + BackButton.Dispose (); + BackButton = null; + } + + if (DescriptionLabel != null) { + DescriptionLabel.Dispose (); + DescriptionLabel = null; + } + + if (IconImage != null) { + IconImage.Dispose (); + IconImage = null; + } + + if (NavItem != null) { + NavItem.Dispose (); + NavItem = null; + } + } + } +} \ No newline at end of file diff --git a/src/iOS.Autofill/iOS.Autofill.csproj b/src/iOS.Autofill/iOS.Autofill.csproj index b523706fe..d1974f1d4 100644 --- a/src/iOS.Autofill/iOS.Autofill.csproj +++ b/src/iOS.Autofill/iOS.Autofill.csproj @@ -9,7 +9,8 @@ BitwardeniOSAutofill Resources Properties - + + true @@ -72,8 +73,10 @@ Entitlements.plist iPhone Developer True - - + + + + None False False @@ -84,7 +87,8 @@ False False --http-message-handler=NSUrlSessionHandler - + + Default NSUrlSessionHandler @@ -205,6 +209,10 @@ + + + SetupViewController.cs + @@ -216,22 +224,22 @@ - ..\iOS.Extension\LockFingerprintViewController.cs + LockFingerprintViewController.cs - ..\iOS.Extension\LockPasswordViewController.cs + LockPasswordViewController.cs - ..\iOS.Extension\LockPinViewController.cs + LockPinViewController.cs - ..\iOS.Extension\LoginAddViewController.cs + LoginAddViewController.cs - ..\iOS.Extension\LoginListViewController.cs + LoginListViewController.cs - ..\iOS.Extension\PasswordGeneratorViewController.cs + PasswordGeneratorViewController.cs