mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
setup view controller during config
This commit is contained in:
parent
eee96bf8cf
commit
3e240c4d2f
5 changed files with 250 additions and 49 deletions
|
@ -122,23 +122,7 @@ namespace Bit.iOS.Autofill
|
|||
}
|
||||
|
||||
_context.CredentialIdentity = credentialIdentity;
|
||||
var lockService = Resolver.Resolve<ILockService>();
|
||||
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<IAuthService>();
|
||||
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<ILockService>();
|
||||
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<ICipherService>());
|
||||
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<ICipherService>());
|
||||
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<ILockService>();
|
||||
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();
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<segue destination="6815" kind="presentation" identifier="lockPinSegue" id="8924"/>
|
||||
<segue destination="6855" kind="presentation" identifier="lockPasswordSegue" id="9874"/>
|
||||
<segue destination="1845" kind="presentation" identifier="newLoginSegue" modalPresentationStyle="fullScreen" modalTransitionStyle="coverVertical" id="10498"/>
|
||||
<segue id="11089" destination="10580" kind="presentation" modalTransitionStyle="coverVertical" identifier="setupSegue"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="45" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
@ -521,6 +522,88 @@
|
|||
</scene>
|
||||
<!--Setup View Controller-->
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="10573">
|
||||
<objects>
|
||||
<viewController id="10570" sceneMemberID="viewController" customClass="SetupViewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="10565"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="10566"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="10575">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Extension Activated!" lineBreakMode="tailTruncation" minimumFontSize="10" id="11092" translatesAutoresizingMaskIntoConstraints="NO" textAlignment="center">
|
||||
<rect key="frame" x="15" y="94" width="570" height="20.5"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" lineBreakMode="wordWrap" minimumFontSize="10" id="11093" translatesAutoresizingMaskIntoConstraints="NO" numberOfLines="0" textAlignment="center" misplaced="YES">
|
||||
<rect key="frame" x="15" y="134.5" width="570" height="41"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="11094" translatesAutoresizingMaskIntoConstraints="NO" image="ext-icon.png" misplaced="YES">
|
||||
<rect key="frame" x="255" y="205.5" width="90" height="90"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint id="11114" firstItem="11092" firstAttribute="leading" secondItem="10575" secondAttribute="leading" constant="15"/>
|
||||
<constraint id="11115" firstItem="10575" firstAttribute="trailing" secondItem="11092" secondAttribute="trailing" constant="15"/>
|
||||
<constraint id="11116" firstItem="11092" firstAttribute="top" secondItem="10565" secondAttribute="bottom" constant="30"/>
|
||||
<constraint id="11119" firstItem="11093" firstAttribute="leading" secondItem="10575" secondAttribute="leading" constant="15"/>
|
||||
<constraint id="11120" firstItem="10575" firstAttribute="trailing" secondItem="11093" secondAttribute="trailing" constant="15"/>
|
||||
<constraint id="11121" firstItem="11093" firstAttribute="top" secondItem="11092" secondAttribute="bottom" constant="20"/>
|
||||
<constraint id="11122" firstItem="11094" firstAttribute="centerX" secondItem="10575" secondAttribute="centerX"/>
|
||||
<constraint id="11123" firstItem="11094" firstAttribute="top" secondItem="11093" secondAttribute="bottom" constant="30"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="10574">
|
||||
<barButtonItem key="leftBarButtonItem" title="Back" id="11091">
|
||||
<connections>
|
||||
<action selector="BackButton_Activated:" destination="10570" id="11124"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<connections>
|
||||
<outlet property="ActivatedLabel" destination="11092" id="name-outlet-11092"/>
|
||||
<outlet property="BackButton" destination="11091" id="name-outlet-11091"/>
|
||||
<outlet property="DescriptionLabel" destination="11093" id="name-outlet-11093"/>
|
||||
<outlet property="IconImage" destination="11094" id="name-outlet-11094"/>
|
||||
<outlet property="NavItem" destination="10574" id="name-outlet-10574"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="10576" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1129" y="-264"/>
|
||||
</scene>
|
||||
<scene sceneID="10579">
|
||||
<objects>
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="10580" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="10583" translucent="NO">
|
||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textAttributes key="titleTextAttributes">
|
||||
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||
</textAttributes>
|
||||
<color key="barTintColor" colorSpace="calibratedRGB" red="0.23529411764705882" green="0.55294117647058827" blue="0.73725490196078436" alpha="1"/>
|
||||
<color key="tintColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||
</navigationBar>
|
||||
<nil name="viewControllers"/>
|
||||
<connections>
|
||||
<segue id="10939" destination="10570" kind="relationship" relationship="rootViewController"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="10584" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="362" y="-267"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="fingerprint.png" width="91" height="92"/>
|
||||
|
|
49
src/iOS.Autofill/SetupViewController.cs
Normal file
49
src/iOS.Autofill/SetupViewController.cs
Normal file
|
@ -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<ICipherService>());
|
||||
}
|
||||
|
||||
partial void BackButton_Activated(UIBarButtonItem sender)
|
||||
{
|
||||
CPViewController.CompleteRequest();
|
||||
}
|
||||
}
|
||||
}
|
69
src/iOS.Autofill/SetupViewController.designer.cs
generated
Normal file
69
src/iOS.Autofill/SetupViewController.designer.cs
generated
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,8 @@
|
|||
<AssemblyName>BitwardeniOSAutofill</AssemblyName>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<NuGetPackageImportStamp></NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -72,8 +73,10 @@
|
|||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>True</MtouchDebug>
|
||||
<CodesignProvision></CodesignProvision>
|
||||
<CodesignExtraArgs></CodesignExtraArgs>
|
||||
<CodesignProvision>
|
||||
</CodesignProvision>
|
||||
<CodesignExtraArgs>
|
||||
</CodesignExtraArgs>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchProfiling>False</MtouchProfiling>
|
||||
<MtouchFastDev>False</MtouchFastDev>
|
||||
|
@ -84,7 +87,8 @@
|
|||
<MtouchFloat32>False</MtouchFloat32>
|
||||
<DeviceSpecificBuild>False</DeviceSpecificBuild>
|
||||
<MtouchExtraArgs>--http-message-handler=NSUrlSessionHandler</MtouchExtraArgs>
|
||||
<MtouchSdkVersion></MtouchSdkVersion>
|
||||
<MtouchSdkVersion>
|
||||
</MtouchSdkVersion>
|
||||
<MtouchTlsProvider>Default</MtouchTlsProvider>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
</PropertyGroup>
|
||||
|
@ -205,6 +209,10 @@
|
|||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="Models\Context.cs" />
|
||||
<Compile Include="SetupViewController.cs" />
|
||||
<Compile Include="SetupViewController.designer.cs">
|
||||
<DependentUpon>SetupViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
<Compile Include="PasswordGeneratorViewController.cs" />
|
||||
|
@ -216,22 +224,22 @@
|
|||
</Compile>
|
||||
<Compile Include="LoginListViewController.cs" />
|
||||
<Compile Include="LockFingerprintViewController.designer.cs">
|
||||
<DependentUpon>..\iOS.Extension\LockFingerprintViewController.cs</DependentUpon>
|
||||
<DependentUpon>LockFingerprintViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LockPasswordViewController.designer.cs">
|
||||
<DependentUpon>..\iOS.Extension\LockPasswordViewController.cs</DependentUpon>
|
||||
<DependentUpon>LockPasswordViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LockPinViewController.designer.cs">
|
||||
<DependentUpon>..\iOS.Extension\LockPinViewController.cs</DependentUpon>
|
||||
<DependentUpon>LockPinViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LoginAddViewController.designer.cs">
|
||||
<DependentUpon>..\iOS.Extension\LoginAddViewController.cs</DependentUpon>
|
||||
<DependentUpon>LoginAddViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LoginListViewController.designer.cs">
|
||||
<DependentUpon>..\iOS.Extension\LoginListViewController.cs</DependentUpon>
|
||||
<DependentUpon>LoginListViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="PasswordGeneratorViewController.designer.cs">
|
||||
<DependentUpon>..\iOS.Extension\PasswordGeneratorViewController.cs</DependentUpon>
|
||||
<DependentUpon>PasswordGeneratorViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue