mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 09:58:27 +03:00
integrating ios extension with onepassword-app-extension
This commit is contained in:
parent
48db0e8d13
commit
72c1a987c9
4 changed files with 109 additions and 43 deletions
|
@ -17,6 +17,14 @@ namespace Bit.iOS.Extension
|
|||
{
|
||||
public partial class ActionViewController : UIViewController
|
||||
{
|
||||
private const string AppExtensionVersionNumberKey = "version_number";
|
||||
private const string AppExtensionUrlStringKey = "url_string";
|
||||
private const string UTTypeAppExtensionFindLoginAction = "org.appextension.find-login-action";
|
||||
private const string UTTypeAppExtensionSaveLoginAction = "org.appextension.save-login-action";
|
||||
private const string UTTypeAppExtensionChangePasswordAction = "org.appextension.change-password-action";
|
||||
private const string UTTypeAppExtensionFillWebViewAction = "org.appextension.fill-webview-action";
|
||||
private const string UTTypeAppExtensionFillBrowserAction = "org.appextension.fill-browser-action";
|
||||
|
||||
public ActionViewController() : base("ActionViewController", null)
|
||||
{
|
||||
if(!Resolver.IsSet)
|
||||
|
@ -96,10 +104,24 @@ namespace Bit.iOS.Extension
|
|||
foreach(var item in ExtensionContext.InputItems)
|
||||
{
|
||||
foreach(var itemProvider in item.Attachments)
|
||||
{
|
||||
if(ProcessWebUrlProvider(itemProvider))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(ProcessFindLoginProvider(itemProvider))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool ProcessWebUrlProvider(NSItemProvider itemProvider)
|
||||
{
|
||||
if(!itemProvider.HasItemConformingTo(UTType.PropertyList))
|
||||
{
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
itemProvider.LoadItem(UTType.PropertyList, null, (NSObject list, NSError error) =>
|
||||
|
@ -121,10 +143,35 @@ namespace Bit.iOS.Extension
|
|||
Url = new Uri(result.ValueForKey(new NSString("url")) as NSString);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessFindLoginProvider(NSItemProvider itemProvider)
|
||||
{
|
||||
if(!itemProvider.HasItemConformingTo(UTTypeAppExtensionFindLoginAction))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
itemProvider.LoadItem(UTTypeAppExtensionFindLoginAction, null, (NSObject list, NSError error) =>
|
||||
{
|
||||
if(list == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dict = list as NSDictionary;
|
||||
var version = dict[AppExtensionVersionNumberKey] as NSNumber;
|
||||
var url = dict[AppExtensionUrlStringKey] as NSString;
|
||||
if(url == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Url = new Uri(url);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,18 +29,20 @@
|
|||
<key>NSExtensionJavaScriptPreprocessingFile</key>
|
||||
<string>extension</string>
|
||||
<key>NSExtensionActivationRule</key>
|
||||
<dict>
|
||||
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
|
||||
<integer>0</integer>
|
||||
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
|
||||
<integer>0</integer>
|
||||
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
|
||||
<integer>0</integer>
|
||||
<key>NSExtensionActivationSupportsText</key>
|
||||
<false/>
|
||||
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<string>SUBQUERY (
|
||||
extensionItems,
|
||||
$extensionItem,
|
||||
SUBQUERY (
|
||||
$extensionItem.attachments,
|
||||
$attachment,
|
||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
|
||||
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.find-login-action"
|
||||
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.save-login-action"
|
||||
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.change-password-action"
|
||||
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.fill-webview-action"
|
||||
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.fill-browser-action"
|
||||
).@count == $extensionItem.attachments.@count
|
||||
).@count == 1</string>
|
||||
<key>NSExtensionPointName</key>
|
||||
<string>com.apple.ui-services</string>
|
||||
<key>NSExtensionPointVersion</key>
|
||||
|
|
|
@ -107,6 +107,11 @@ namespace Bit.iOS
|
|||
Debug.WriteLine("WillEnterForeground");
|
||||
}
|
||||
|
||||
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SendLockMessage()
|
||||
{
|
||||
MessagingCenter.Send(Xamarin.Forms.Application.Current, "Lock", false);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>9.3</string>
|
||||
<string>9.0</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>bitwarden</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
|
@ -57,8 +57,20 @@
|
|||
<key>UIMainStoryboardFile~ipad</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIStatusBarStyle</key>
|
||||
+ <string>UIStatusBarStyleLightContent</string>
|
||||
+ <key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
+ <false/>
|
||||
<string>UIStatusBarStyleLightContent</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>bitwarden</string>
|
||||
<string>org-appextension-feature-password-management</string>
|
||||
</array>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.bitwarden.vault.url</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Loading…
Reference in a new issue