bitwarden-android/src/iOS.Extension/ActionViewController.cs

68 lines
1.9 KiB
C#
Raw Normal View History

using System;
using MobileCoreServices;
using Foundation;
using UIKit;
namespace Bit.iOS.Extension
{
public partial class ActionViewController : UIViewController
{
public ActionViewController(IntPtr handle) : base(handle)
{
}
public string Content { get; set; }
public Uri Uri { get; set; }
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
foreach(var item in ExtensionContext.InputItems)
{
foreach(var itemProvider in item.Attachments)
{
2016-05-25 07:09:11 +03:00
if(!itemProvider.HasItemConformingTo(UTType.PropertyList))
{
2016-05-25 07:09:11 +03:00
continue;
}
2016-05-25 07:09:11 +03:00
itemProvider.LoadItem(UTType.PropertyList, null, (NSObject list, NSError error) =>
{
if(list == null)
{
return;
}
var dict = list as NSDictionary;
var result = dict[NSJavaScriptExtension.PreprocessingResultsKey];
if(result == null)
{
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);
});
break;
}
}
}
partial void DoneClicked(NSObject sender)
{
}
}
}