Added setup view controller to app extension.

This commit is contained in:
Kyle Spearrin 2016-07-26 22:28:02 -04:00
parent 6371343dc5
commit 669385df0f
8 changed files with 213 additions and 28 deletions

View File

@ -27,5 +27,6 @@
public const string UTTypeAppExtensionChangePasswordAction = "org.appextension.change-password-action";
public const string UTTypeAppExtensionFillWebViewAction = "org.appextension.fill-webview-action";
public const string UTTypeAppExtensionFillBrowserAction = "org.appextension.fill-browser-action";
public const string UTTypeAppExtensionSetup = "com.8bit.bitwarden.extension-setup";
}
}

View File

@ -26,7 +26,7 @@ namespace Bit.iOS.Extension
{
private Context _context = new Context();
private bool _setupHockeyApp = false;
private readonly JsonSerializerSettings _jsonSettings =
private readonly JsonSerializerSettings _jsonSettings =
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
public LoadingViewController(IntPtr handle) : base(handle)
@ -39,10 +39,6 @@ namespace Bit.iOS.Extension
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
_context.ExtContext = ExtensionContext;
var descriptor = UIFontDescriptor.PreferredBody;
DecryptingLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize);
DecryptingLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
if(!Resolver.IsSet)
{
SetIoc();
@ -69,7 +65,8 @@ namespace Bit.iOS.Extension
|| ProcessFindLoginBrowserProvider(itemProvider, Constants.UTTypeAppExtensionFillBrowserAction)
|| ProcessFindLoginBrowserProvider(itemProvider, Constants.UTTypeAppExtensionFillWebViewAction)
|| ProcessSaveLoginProvider(itemProvider)
|| ProcessChangePasswordProvider(itemProvider))
|| ProcessChangePasswordProvider(itemProvider)
|| ProcessExtensionSetupProvider(itemProvider))
{
processed = true;
break;
@ -116,6 +113,10 @@ namespace Bit.iOS.Extension
{
PerformSegue("newSiteSegue", this);
}
else if(_context.ProviderType == Constants.UTTypeAppExtensionSetup)
{
PerformSegue("setupSegue", this);
}
else
{
PerformSegue("siteListSegue", this);
@ -134,6 +135,7 @@ namespace Bit.iOS.Extension
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(listSiteController != null)
{
@ -160,6 +162,11 @@ namespace Bit.iOS.Extension
passwordViewController.Context = _context;
passwordViewController.LoadingController = this;
}
else if(setupViewController != null)
{
setupViewController.Context = _context;
setupViewController.LoadingController = this;
}
}
}
@ -403,6 +410,17 @@ namespace Bit.iOS.Extension
});
}
private bool ProcessExtensionSetupProvider(NSItemProvider itemProvider)
{
if(itemProvider.HasItemConformingTo(Constants.UTTypeAppExtensionSetup))
{
_context.ProviderType = Constants.UTTypeAppExtensionSetup;
return true;
}
return false;
}
private T DeserializeDictionary<T>(NSDictionary dict)
{
if(dict != null)

View File

@ -14,16 +14,8 @@ namespace Bit.iOS.Extension
[Register ("LoadingViewController")]
partial class LoadingViewController
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UILabel DecryptingLabel { get; set; }
void ReleaseDesignerOutlets ()
{
if (DecryptingLabel != null) {
DecryptingLabel.Dispose ();
DecryptingLabel = null;
}
}
}
}

View File

@ -18,23 +18,13 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="1713" translatesAutoresizingMaskIntoConstraints="NO" image="logo.png">
<rect key="frame" x="159" y="223" width="282" height="44"/>
<rect key="frame" x="159" y="248" width="282" height="44"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Decrypting data..." lineBreakMode="tailTruncation" minimumFontSize="10" id="10537" translatesAutoresizingMaskIntoConstraints="NO" textAlignment="center">
<rect key="frame" x="15" y="287" 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>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint id="1763" firstItem="1713" firstAttribute="centerY" secondItem="44" secondAttribute="centerY" constant="-55"/>
<constraint id="1763" firstItem="1713" firstAttribute="centerY" secondItem="44" secondAttribute="centerY" constant="-30"/>
<constraint id="1764" firstItem="1713" firstAttribute="centerX" secondItem="44" secondAttribute="centerX"/>
<constraint id="10538" firstItem="10537" firstAttribute="top" secondItem="1713" secondAttribute="bottom" constant="20"/>
<constraint id="10539" firstItem="10537" firstAttribute="leading" secondItem="44" secondAttribute="leading" constant="15"/>
<constraint id="10540" firstItem="44" firstAttribute="trailing" secondItem="10537" secondAttribute="trailing" constant="15"/>
</constraints>
</view>
<connections>
@ -43,7 +33,7 @@
<segue id="8924" destination="6815" kind="presentation" identifier="lockPinSegue"/>
<segue id="9874" destination="6855" kind="presentation" identifier="lockPasswordSegue"/>
<segue id="10498" destination="1845" kind="presentation" identifier="newSiteSegue" modalPresentationStyle="fullScreen" modalTransitionStyle="coverVertical"/>
<outlet property="DecryptingLabel" destination="10537" id="name-outlet-10537"/>
<segue id="11089" destination="10580" kind="presentation" modalTransitionStyle="coverVertical" identifier="setupSegue"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="45" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -78,6 +68,7 @@
<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="calibratedRGB" red="0" green="0.52549019607843139" blue="1" alpha="1"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
@ -512,6 +503,87 @@
</objects>
<point key="canvasLocation" x="977" y="2775"/>
</scene>
<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" text="Your logins are now instantly accessable from Safari, Chrome, and other supported apps." lineBreakMode="wordWrap" minimumFontSize="10" id="11093" translatesAutoresizingMaskIntoConstraints="NO" numberOfLines="0" textAlignment="center">
<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="Icon.png">
<rect key="frame" x="271.5" y="205.5" width="57" height="57"/>
</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"/>
</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="logo.png" width="282" height="44"/>

View File

@ -0,0 +1,38 @@
using System;
using Bit.iOS.Extension.Models;
using UIKit;
using Plugin.Settings.Abstractions;
namespace Bit.iOS.Extension
{
public partial class SetupViewController : UIViewController
{
public SetupViewController(IntPtr handle) : base(handle)
{ }
public Context Context { get; set; }
public LoadingViewController LoadingController { 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.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize);
DescriptionLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f);
base.ViewDidLoad();
}
partial void BackButton_Activated(UIBarButtonItem sender)
{
LoadingController.CompleteRequest(null);
}
}
}

View File

@ -0,0 +1,60 @@
// 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.Extension
{
[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; }
[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;
}
}
}
}

View File

@ -99,6 +99,10 @@
<Compile Include="LockPasswordViewController.designer.cs">
<DependentUpon>LockPasswordViewController.cs</DependentUpon>
</Compile>
<Compile Include="SetupViewController.cs" />
<Compile Include="SetupViewController.designer.cs">
<DependentUpon>SetupViewController.cs</DependentUpon>
</Compile>
<Compile Include="LockPinViewController.cs" />
<Compile Include="LockPinViewController.designer.cs">
<DependentUpon>LockPinViewController.cs</DependentUpon>

View File

@ -75,7 +75,7 @@ namespace Bit.iOS
MessagingCenter.Subscribe<Xamarin.Forms.Application, ToolsExtensionPage>(Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) =>
{
var itemProvider = new NSItemProvider(new NSDictionary(), "com.8bit.bitwarden.extension-setup");
var itemProvider = new NSItemProvider(new NSDictionary(), iOS.Core.Constants.UTTypeAppExtensionSetup);
var extensionItem = new NSExtensionItem();
extensionItem.Attachments = new NSItemProvider[] { itemProvider };
var activityViewController = new UIActivityViewController(new NSExtensionItem[] { extensionItem }, null);