diff --git a/src/iOS.Extension/ActionViewController.cs b/src/iOS.Extension/ActionViewController.cs index 4be6d004f..f40c785ad 100644 --- a/src/iOS.Extension/ActionViewController.cs +++ b/src/iOS.Extension/ActionViewController.cs @@ -1,25 +1,56 @@ -using System; - -using MobileCoreServices; +using System; +using CoreGraphics; using Foundation; +using MobileCoreServices; using UIKit; namespace Bit.iOS.Extension { public partial class ActionViewController : UIViewController { - public ActionViewController(IntPtr handle) : base(handle) + public ActionViewController() : base("ActionViewController", null) { } - public string Content { get; set; } - public Uri Uri { get; set; } + public string HtmlContent { get; set; } + public Uri BaseUri { get; set; } + public Uri Url { get; set; } public override void DidReceiveMemoryWarning() { base.DidReceiveMemoryWarning(); } + public override void LoadView() + { + View = new UIView(new CGRect(x: 0.0, y: 0, width: 320.0, height: 200.0)); + var button = new UIButton(new CGRect(x: 10.0, y: 50.0, width: 200.0, height: 30.0)); + button.SetTitle("Done", UIControlState.Normal); + button.TouchUpInside += Button_TouchUpInside; + View.AddSubview(button); + } + + private void Button_TouchUpInside(object sender, EventArgs e) + { + var itemData = new NSDictionary( + new NSString("username"), + new NSString("myusername"), + new NSString("password"), + new NSString("mypassword")); + + var resultsProvider = new NSItemProvider( + new NSDictionary(NSJavaScriptExtension.FinalizeArgumentKey, itemData), + UTType.PropertyList); + + var resultsItem = new NSExtensionItem + { + Attachments = new NSItemProvider[] { resultsProvider } + }; + + var returningItems = new NSExtensionItem[] { resultsItem }; + ExtensionContext.CompleteRequest(returningItems, null); + } + public override void ViewDidLoad() { base.ViewDidLoad(); @@ -47,11 +78,9 @@ namespace Bit.iOS.Extension return; } - Content = result.ValueForKey(new NSString("content")) as NSString; - Uri = new Uri(result.ValueForKey(new NSString("uri")) as NSString); - - Console.WriteLine("BITWARDEN LOG, Content: {0}", Content); - Console.WriteLine("BITWARDEN LOG, Uri: {0}", Uri); + HtmlContent = result.ValueForKey(new NSString("htmlContent")) as NSString; + BaseUri = new Uri(result.ValueForKey(new NSString("baseUri")) as NSString); + Url = new Uri(result.ValueForKey(new NSString("url")) as NSString); }); break; @@ -59,9 +88,5 @@ namespace Bit.iOS.Extension } } - partial void DoneClicked(NSObject sender) - { - - } } -} +} \ No newline at end of file diff --git a/src/iOS.Extension/ActionViewController.designer.cs b/src/iOS.Extension/ActionViewController.designer.cs index 0292e4c52..6d132dfe9 100644 --- a/src/iOS.Extension/ActionViewController.designer.cs +++ b/src/iOS.Extension/ActionViewController.designer.cs @@ -1,9 +1,9 @@ +// WARNING // -// This file has been generated automatically to store outlets and -// actions made in the Xcode designer. If it is removed, they will be lost. -// Manual changes to this file may not be handled correctly. +// 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 UIKit; using Foundation; namespace Bit.iOS.Extension @@ -11,14 +11,8 @@ namespace Bit.iOS.Extension [Register("ActionViewController")] partial class ActionViewController { - [Outlet] - UIImageView imageView { get; set; } - - [Action("DoneClicked:")] - partial void DoneClicked(NSObject sender); - void ReleaseDesignerOutlets() { } } -} +} \ No newline at end of file diff --git a/src/iOS.Extension/ActionViewController.xib b/src/iOS.Extension/ActionViewController.xib new file mode 100644 index 000000000..cd6490b78 --- /dev/null +++ b/src/iOS.Extension/ActionViewController.xib @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/iOS.Extension/Info.plist b/src/iOS.Extension/Info.plist index b1d7a481f..d14a48ce2 100644 --- a/src/iOS.Extension/Info.plist +++ b/src/iOS.Extension/Info.plist @@ -46,8 +46,8 @@ NSExtensionPointVersion 1.0 - NSExtensionMainStoryboard - MainInterface + NSExtensionPrincipalClass + ActionViewController NSExtensionPointIdentifier com.apple.ui-services diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard deleted file mode 100644 index c93012146..000000000 --- a/src/iOS.Extension/MainInterface.storyboard +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/iOS.Extension/extension.js b/src/iOS.Extension/extension.js index b5984f120..8bd4fe544 100644 --- a/src/iOS.Extension/extension.js +++ b/src/iOS.Extension/extension.js @@ -6,8 +6,9 @@ BitwardenExtension.prototype = { console.log(arguments); var args = { - content: document.body.innerHTML, - uri: document.baseURI + baseUri: document.baseURI, + url: document.URL, + htmlContent: document.body.innerHTML }; arguments.completionFunction(args); }, diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj index 6a090c44b..113a1917b 100644 --- a/src/iOS.Extension/iOS.Extension.csproj +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -87,16 +87,16 @@ iPhone Distribution + ActionViewController.cs + - -