mirror of
https://github.com/bitwarden/mobile
synced 2025-12-16 08:13:20 +00:00
autofill extension project
This commit is contained in:
71
src/iOS.Autofill/ActionViewController.cs
Normal file
71
src/iOS.Autofill/ActionViewController.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
|
||||
using MobileCoreServices;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace iOS.Autofill
|
||||
{
|
||||
public partial class ActionViewController : UIViewController
|
||||
{
|
||||
public ActionViewController(IntPtr handle) : base(handle)
|
||||
{
|
||||
}
|
||||
|
||||
public override void DidReceiveMemoryWarning()
|
||||
{
|
||||
// Releases the view if it doesn't have a superview.
|
||||
base.DidReceiveMemoryWarning();
|
||||
|
||||
// Release any cached data, images, etc that aren't in use.
|
||||
}
|
||||
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
|
||||
// Get the item[s] we're handling from the extension context.
|
||||
|
||||
// For example, look for an image and place it into an image view.
|
||||
// Replace this with something appropriate for the type[s] your extension supports.
|
||||
bool imageFound = false;
|
||||
|
||||
foreach(var item in ExtensionContext.InputItems)
|
||||
{
|
||||
foreach(var itemProvider in item.Attachments)
|
||||
{
|
||||
if(itemProvider.HasItemConformingTo(UTType.Image))
|
||||
{
|
||||
// This is an image. We'll load it, then place it in our image view.
|
||||
itemProvider.LoadItem(UTType.Image, null, delegate (NSObject image, NSError error)
|
||||
{
|
||||
if(image != null)
|
||||
{
|
||||
NSOperationQueue.MainQueue.AddOperation(delegate
|
||||
{
|
||||
imageView.Image = (UIImage)image;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
imageFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(imageFound)
|
||||
{
|
||||
// We only handle one image, so stop looking for more.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partial void DoneClicked(NSObject sender)
|
||||
{
|
||||
// Return any edited content to the host app.
|
||||
// This template doesn't do anything, so we just echo the passed-in items.
|
||||
ExtensionContext.CompleteRequest(ExtensionContext.InputItems, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user