From d32eb9c9bce5fa882a9283f6f2fffff08bd86734 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 20 Sep 2018 22:24:13 -0400 Subject: [PATCH] copy classes to autofill --- .../LockFingerprintViewController.cs | 28 +++++++++ .../LockPasswordViewController.cs | 27 ++++++++ src/iOS.Autofill/LockPinViewController.cs | 24 +++++++ src/iOS.Autofill/LoginAddViewController.cs | 63 +++++++++++++++++++ .../LoginListViewController.designer.cs | 55 ---------------- .../PasswordGeneratorViewController.cs | 31 +++++++++ src/iOS.Autofill/iOS.Autofill.csproj | 8 ++- 7 files changed, 178 insertions(+), 58 deletions(-) create mode 100644 src/iOS.Autofill/LockFingerprintViewController.cs create mode 100644 src/iOS.Autofill/LockPasswordViewController.cs create mode 100644 src/iOS.Autofill/LockPinViewController.cs create mode 100644 src/iOS.Autofill/LoginAddViewController.cs delete mode 100644 src/iOS.Autofill/LoginListViewController.designer.cs create mode 100644 src/iOS.Autofill/PasswordGeneratorViewController.cs diff --git a/src/iOS.Autofill/LockFingerprintViewController.cs b/src/iOS.Autofill/LockFingerprintViewController.cs new file mode 100644 index 000000000..a5a81466a --- /dev/null +++ b/src/iOS.Autofill/LockFingerprintViewController.cs @@ -0,0 +1,28 @@ +using System; +using UIKit; + +namespace Bit.iOS.Extension +{ + public partial class LockFingerprintViewController : Core.Controllers.LockFingerprintViewController + { + public LockFingerprintViewController(IntPtr handle) : base(handle) + { } + + public LoadingViewController LoadingController { get; set; } + public override UINavigationItem BaseNavItem => NavItem; + public override UIBarButtonItem BaseCancelButton => CancelButton; + public override UIButton BaseUseButton => UseButton; + public override UIButton BaseFingerprintButton => FingerprintButton; + public override Action Success => () => LoadingController.DismissLockAndContinue(); + + partial void CancelButton_Activated(UIBarButtonItem sender) + { + LoadingController.CompleteRequest(null); + } + + partial void FingerprintButton_TouchUpInside(UIButton sender) + { + var task = CheckFingerprintAsync(); + } + } +} diff --git a/src/iOS.Autofill/LockPasswordViewController.cs b/src/iOS.Autofill/LockPasswordViewController.cs new file mode 100644 index 000000000..d51531591 --- /dev/null +++ b/src/iOS.Autofill/LockPasswordViewController.cs @@ -0,0 +1,27 @@ +using System; +using UIKit; + +namespace Bit.iOS.Extension +{ + public partial class LockPasswordViewController : Core.Controllers.LockPasswordViewController + { + public LockPasswordViewController(IntPtr handle) : base(handle) + { } + + public LoadingViewController LoadingController { get; set; } + public override UINavigationItem BaseNavItem => NavItem; + public override UIBarButtonItem BaseCancelButton => CancelButton; + public override UIBarButtonItem BaseSubmitButton => SubmitButton; + public override Action Success => () => LoadingController.DismissLockAndContinue(); + + partial void SubmitButton_Activated(UIBarButtonItem sender) + { + CheckPassword(); + } + + partial void CancelButton_Activated(UIBarButtonItem sender) + { + LoadingController.CompleteRequest(null); + } + } +} diff --git a/src/iOS.Autofill/LockPinViewController.cs b/src/iOS.Autofill/LockPinViewController.cs new file mode 100644 index 000000000..2737135be --- /dev/null +++ b/src/iOS.Autofill/LockPinViewController.cs @@ -0,0 +1,24 @@ +using System; +using UIKit; + +namespace Bit.iOS.Extension +{ + public partial class LockPinViewController : Core.Controllers.LockPinViewController + { + public LockPinViewController(IntPtr handle) : base(handle) + { } + + public LoadingViewController LoadingController { get; set; } + public override UINavigationItem BaseNavItem => NavItem; + public override UIBarButtonItem BaseCancelButton => CancelButton; + public override UILabel BasePinLabel => PinLabel; + public override UILabel BaseInstructionLabel => InstructionLabel; + public override UITextField BasePinTextField => PinTextField; + public override Action Success => () => LoadingController.DismissLockAndContinue(); + + partial void CancelButton_Activated(UIBarButtonItem sender) + { + LoadingController.CompleteRequest(null); + } + } +} diff --git a/src/iOS.Autofill/LoginAddViewController.cs b/src/iOS.Autofill/LoginAddViewController.cs new file mode 100644 index 000000000..acaa68a7a --- /dev/null +++ b/src/iOS.Autofill/LoginAddViewController.cs @@ -0,0 +1,63 @@ +using System; +using Foundation; +using UIKit; + +namespace Bit.iOS.Extension +{ + public partial class LoginAddViewController : Core.Controllers.LoginAddViewController + { + public LoginAddViewController(IntPtr handle) : base(handle) + { } + + public LoginListViewController LoginListController { get; set; } + public LoadingViewController LoadingController { get; set; } + + public override UINavigationItem BaseNavItem => NavItem; + public override UIBarButtonItem BaseCancelButton => CancelBarButton; + public override UIBarButtonItem BaseSaveButton => SaveBarButton; + + public override Action Success => () => + { + if(LoginListController != null) + { + LoginListController.DismissModal(); + } + else if(LoadingController != null) + { + LoadingController.CompleteUsernamePasswordRequest(UsernameCell.TextField.Text, + PasswordCell.TextField.Text, null, null); + } + }; + + partial void CancelBarButton_Activated(UIBarButtonItem sender) + { + if(LoginListController != null) + { + DismissViewController(true, null); + } + else + { + LoadingController.CompleteRequest(null); + } + } + + async partial void SaveBarButton_Activated(UIBarButtonItem sender) + { + await this.SaveAsync(); + } + + public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) + { + var navController = segue.DestinationViewController as UINavigationController; + if(navController != null) + { + var passwordGeneratorController = navController.TopViewController as PasswordGeneratorViewController; + if(passwordGeneratorController != null) + { + passwordGeneratorController.PasswordOptions = Context.PasswordOptions; + passwordGeneratorController.Parent = this; + } + } + } + } +} diff --git a/src/iOS.Autofill/LoginListViewController.designer.cs b/src/iOS.Autofill/LoginListViewController.designer.cs deleted file mode 100644 index 3e0636502..000000000 --- a/src/iOS.Autofill/LoginListViewController.designer.cs +++ /dev/null @@ -1,55 +0,0 @@ -// WARNING -// -// This file has been generated automatically by Visual 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 ("LoginListViewController")] - partial class LoginListViewController - { - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UIBarButtonItem AddBarButton { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UIBarButtonItem CancelBarButton { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UINavigationItem NavItem { get; set; } - - [Action ("AddBarButton_Activated:")] - [GeneratedCode ("iOS Designer", "1.0")] - partial void AddBarButton_Activated (UIKit.UIBarButtonItem sender); - - [Action ("CancelBarButton_Activated:")] - [GeneratedCode ("iOS Designer", "1.0")] - partial void CancelBarButton_Activated (UIKit.UIBarButtonItem sender); - - void ReleaseDesignerOutlets () - { - if (AddBarButton != null) { - AddBarButton.Dispose (); - AddBarButton = null; - } - - if (CancelBarButton != null) { - CancelBarButton.Dispose (); - CancelBarButton = null; - } - - if (NavItem != null) { - NavItem.Dispose (); - NavItem = null; - } - } - } -} \ No newline at end of file diff --git a/src/iOS.Autofill/PasswordGeneratorViewController.cs b/src/iOS.Autofill/PasswordGeneratorViewController.cs new file mode 100644 index 000000000..36f3b99aa --- /dev/null +++ b/src/iOS.Autofill/PasswordGeneratorViewController.cs @@ -0,0 +1,31 @@ +using System; +using UIKit; + +namespace Bit.iOS.Extension +{ + public partial class PasswordGeneratorViewController : Core.Controllers.PasswordGeneratorViewController + { + public PasswordGeneratorViewController(IntPtr handle) : base(handle) + { } + + public LoginAddViewController Parent { get; set; } + public override UINavigationItem BaseNavItem => NavItem; + public override UIBarButtonItem BaseCancelButton => CancelBarButton; + public override UIBarButtonItem BaseSelectBarButton => SelectBarButton; + public override UILabel BasePasswordLabel => PasswordLabel; + + partial void SelectBarButton_Activated(UIBarButtonItem sender) + { + GoogleAnalyticsService.TrackExtensionEvent("SelectedGeneratedPassword"); + DismissViewController(true, () => + { + Parent.PasswordCell.TextField.Text = PasswordLabel.Text; + }); + } + + partial void CancelBarButton_Activated(UIBarButtonItem sender) + { + DismissViewController(true, null); + } + } +} diff --git a/src/iOS.Autofill/iOS.Autofill.csproj b/src/iOS.Autofill/iOS.Autofill.csproj index 4ca67e667..55aecf233 100644 --- a/src/iOS.Autofill/iOS.Autofill.csproj +++ b/src/iOS.Autofill/iOS.Autofill.csproj @@ -203,11 +203,16 @@ + + + + + @@ -215,9 +220,6 @@ CredentialProviderViewController.cs - - LoginListViewController.cs -