.vs/HDL_APP_Project/xs/UserPrefs.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/HDL-ON_iOS.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/Info.plist | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/Other/Siri/SiriBaseView.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/Other/Siri/SiriScene.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/Other/Siri/VoiceShortcutDataManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/Other/SkipControl.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
SiriIntents/Info.plist | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
SiriIntentsUI/Info.plist | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -3,32 +3,33 @@ <MonoDevelop.MacDev.AppleDevelopmentTeam /> </MonoDevelop.Ide.ItemProperties.SiriIntentUI> <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.6242be7109c740c6cb8999a8904b6e0ea8d45192" /> <MonoDevelop.Ide.ItemProperties.SiriIntents FirstBuild="True"> <MonoDevelop.Ide.ItemProperties.SiriIntents> <MonoDevelop.MacDev.AppleDevelopmentTeam /> </MonoDevelop.Ide.ItemProperties.SiriIntents> <MonoDevelop.Ide.Workbench ActiveDocument="SiriIntents/IntentHandler.cs"> <MonoDevelop.Ide.Workbench ActiveDocument="SiriBinding/obj/Debug/iOS/HdlSiri/HDLRunSceneIntent.g.cs"> <Files> <File FileName="HDL_ON/UI/UI1-Login/LoginPage.cs" Line="203" Column="35" /> <File FileName="HDL-ON_iOS/Other/SkipControl.cs" Line="35" Column="1" /> <File FileName="HDL-ON_iOS/Other/Siri/SiriBaseView.cs" Line="25" Column="2" /> <File FileName="SiriBinding/ApiDefinition.cs" Line="8" Column="18" /> <File FileName="SiriBinding/Structs.cs" Line="19" Column="1" /> <File FileName="SiriIntents/IntentHandler.cs" Line="1" Column="1" /> <File FileName="HDL-ON_iOS/Other/SkipControl.cs" Line="18" Column="36" /> <File FileName="HDL-ON_iOS/Other/Siri/SiriBaseView.cs" Line="34" Column="101" /> <File FileName="SiriBinding/Structs.cs" /> <File FileName="SiriIntents/IntentHandler.cs" /> <File FileName="HDL-ON_iOS/Other/Siri/VoiceShortcutDataManager.cs" Line="23" Column="45" /> <File FileName="SiriBinding/obj/Debug/iOS/HdlSiri/HDLRunSceneIntent.g.cs" Line="63" Column="1" /> </Files> <Pads> <Pad Id="ProjectPad"> <State name="__root__"> <Node name="HDL_APP_Project" expanded="True"> <Node name="SiriIntents" expanded="True"> <Node name="IntentHandler.cs" selected="True" /> <Node name="HDL-ON_iOS" selected="True" /> <Node name="SiriBinding" expanded="True"> <Node name="NativeReferenceFolder" expanded="True" /> </Node> <Node name="SiriIntentsUI" expanded="True" /> </Node> </State> </Pad> </Pads> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.ItemProperties.SiriIntentsUI FirstBuild="True"> <MonoDevelop.Ide.ItemProperties.SiriIntentsUI> <MonoDevelop.MacDev.AppleDevelopmentTeam /> </MonoDevelop.Ide.ItemProperties.SiriIntentsUI> <MonoDevelop.Ide.DebuggingService.PinnedWatches /> @@ -37,7 +38,6 @@ <String>Shared.Droid.TouchID/Shared.Droid.TouchID.csproj</String> <String>Shared.IOS/Shared.IOS.csproj</String> <String>SiriIntent/SiriIntent.csproj</String> <String>SiriBinding/SiriBinding.csproj</String> </DisabledProjects> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> <MonoDevelop.Ide.ItemProperties.HDL-ON__Android PreferredExecutionTarget="Android.SelectDevice" /> HDL-ON_iOS/HDL-ON_iOS.csproj
@@ -497,6 +497,8 @@ <Compile Include="Other\Siri\SiriBaseView.designer.cs"> <DependentUpon>SiriBaseView.cs</DependentUpon> </Compile> <Compile Include="Other\Siri\VoiceShortcutDataManager.cs" /> <Compile Include="Other\Siri\SiriScene.cs" /> </ItemGroup> <ItemGroup> <BundleResource Include="Resources\Phone\LoginIcon\ShowPasswordIcon.png" /> HDL-ON_iOS/Info.plist
@@ -135,5 +135,9 @@ <string>Make audio/video calls</string> <key>NSSiriUsageDescription</key> <string>On Pro data will be send to Siri.</string> <key>NSUserActivityTypes</key> <array> <string>HDLRunSceneIntent</string> </array> </dict> </plist> HDL-ON_iOS/Other/Siri/SiriBaseView.cs
@@ -1,10 +1,13 @@ using System; using CoreGraphics; using Foundation; using Intents; using IntentsUI; using UIKit; namespace Other.Siri { public partial class SiriBaseView : UIViewController public partial class SiriBaseView : UIViewController, IINUIAddVoiceShortcutViewControllerDelegate, IINUIEditVoiceShortcutViewControllerDelegate { public SiriBaseView() : base("SiriBaseView", null) { @@ -14,6 +17,43 @@ { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. var btn = UIButton.FromType(UIButtonType.System); btn.Frame = new CGRect(20, 200, 280, 44); btn.SetTitle("Click Me", UIControlState.Normal); VoiceShortcutDataManager VoiceShortcutDataManager = new VoiceShortcutDataManager(); btn.TouchUpInside += (sender, e) => { //HDL_ON_iOS.AppDelegate.rootViewController.SetNavigationBarHidden(HDL_ON_iOS.AppDelegate.rootViewController.NavigationBarHidden ? false : true, true); var ss = new SiriScene() { Id = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString() }; //INVoiceShortcut existingShortcut = VoiceShortcutDataManager?.VoiceShortcutForOrder(ss); //if (!(existingShortcut is null)) //{ // var editVoiceShortcutViewController = new INUIEditVoiceShortcutViewController(existingShortcut); // editVoiceShortcutViewController.Delegate = this; // PresentViewController(editVoiceShortcutViewController, true, null); //} //else { // Since the app isn't yet managing a voice shortcut for // this order, present the add view controller INShortcut newShortcut = new INShortcut(ss.Intent); if (!(newShortcut is null)) { var addVoiceShortcutVC = new INUIAddVoiceShortcutViewController(newShortcut); addVoiceShortcutVC.Delegate = this; PresentViewController(addVoiceShortcutVC, true, null); } } }; View.AddSubview(btn); } public override void DidReceiveMemoryWarning() @@ -21,6 +61,31 @@ base.DidReceiveMemoryWarning(); // Release any cached data, images, etc that aren't in use. } public void DidFinish(INUIAddVoiceShortcutViewController controller, INVoiceShortcut voiceShortcut, NSError error) { Console.WriteLine("didF"); } public void DidCancel(INUIAddVoiceShortcutViewController controller) { Console.WriteLine("didC"); } public void DidUpdate(INUIEditVoiceShortcutViewController controller, INVoiceShortcut voiceShortcut, NSError error) { Console.WriteLine("didU"); } public void DidDelete(INUIEditVoiceShortcutViewController controller, NSUuid deletedVoiceShortcutIdentifier) { Console.WriteLine("didD"); } public void DidCancel(INUIEditVoiceShortcutViewController controller) { Console.WriteLine("didC"); } } } HDL-ON_iOS/Other/Siri/SiriScene.cs
New file @@ -0,0 +1,100 @@ using System; using Foundation; using HdlSiri; using Intents; using UIKit; namespace Other.Siri { public class SiriScene : NSObject , INSCoding { public SiriScene() { } public string Id; public string Name; public void EncodeTo(NSCoder encoder) { Console.WriteLine("nscoder"); } public HDLRunSceneIntent Intent { get { var orderSoupIntent = new HDLRunSceneIntent() { SceneId = Id, SceneName = Name }; //orderSoupIntent.Quantity = new NSNumber(Quantity); //orderSoupIntent.Soup = new INObject(MenuItem.ItemNameKey, MenuItem.LocalizedString); //var image = UIImage.FromBundle(MenuItem.IconImageName); //if (!(image is null)) //{ // var data = image.AsPNG(); // orderSoupIntent.SetImage(INImage.FromData(data), "soup"); //} //orderSoupIntent.Options = MenuItemOptions // .ToArray<MenuItemOption>() // .Select<MenuItemOption, INObject>(arg => new INObject(arg.Value, arg.LocalizedString)) // .ToArray<INObject>(); //var comment = "Suggested phrase for ordering a specific soup"; //var phrase = NSBundleHelper.SoupKitBundle.GetLocalizedString("ORDER_SOUP_SUGGESTED_PHRASE", comment); //orderSoupIntent.SuggestedInvocationPhrase = String.Format(phrase, MenuItem.LocalizedString); return orderSoupIntent; } } public static SiriScene FromOrderSoupIntent(HDLRunSceneIntent intent) { //var menuManager = new SoupMenuManager(); //var soupID = intent.Soup?.Identifier; //if (soupID is null) //{ // return null; //} //var menuItem = menuManager.FindItem(soupID); //if (menuItem is null) //{ // return null; //} //var quantity = intent.Quantity; //if (menuItem is null) //{ // return null; //} //MenuItemOption[] rawOptions; //if (intent.Options is null) //{ // rawOptions = new MenuItemOption[0]; //} //else //{ // // For the equivalent code in Apple's Swift sample, compactMap // // is used. This eliminates nil values from the final result. // // Here, LINQ's Where method is used to filter out the null // // values. // rawOptions = intent.Options.Select<INObject, MenuItemOption>((option) => // { // var optionID = option.Identifier; // return (optionID is null) ? null : new MenuItemOption(optionID); // }).Where((option) => !(option is null)).ToArray<MenuItemOption>(); //} //var order = new Order(quantity.Int32Value, menuItem, new NSMutableSet<MenuItemOption>(rawOptions)); //return order; return null; } } } HDL-ON_iOS/Other/Siri/VoiceShortcutDataManager.cs
New file @@ -0,0 +1,57 @@ /* See LICENSE folder for this sample’s licensing information. Abstract: A data manager that surfaces INVoiceShortcuts managed by INVoiceShortcutCenter. */ using System; using Intents; using System.Linq; namespace Other.Siri { public class VoiceShortcutDataManager { INVoiceShortcut[] VoiceShortcuts; public VoiceShortcutDataManager() { UpdateVoiceShortcuts(null); } public INVoiceShortcut VoiceShortcutForOrder(SiriScene ss) { var voiceShortcut = VoiceShortcuts.FirstOrDefault((shortcut) => { var intent = shortcut.Shortcut.Intent as HdlSiri.HDLRunSceneIntent; if (intent is null) { return false; } var orderFromIntent = SiriScene.FromOrderSoupIntent(intent); if (orderFromIntent is null) { return false; } return ss.IsEqual(orderFromIntent); }); return voiceShortcut; } public void UpdateVoiceShortcuts(Action completion) { INVoiceShortcutCenter.SharedCenter.GetAllVoiceShortcuts((voiceShortcutsFromCenter, error) => { if (voiceShortcutsFromCenter is null) { if (!(error is null)) { Console.WriteLine($"Failed to fetch voice shortcuts with error {error}"); } return; } VoiceShortcuts = voiceShortcutsFromCenter; if (!(completion is null)) { completion(); } }); } } } HDL-ON_iOS/Other/SkipControl.cs
@@ -1,5 +1,7 @@ using System; using CoreGraphics; using Intents; using IntentsUI; using Other.Siri; using UIKit; @@ -16,21 +18,11 @@ var user = new SiriBaseView(); user.View.BackgroundColor = UIColor.Magenta; var btn = UIButton.FromType(UIButtonType.System); btn.Frame = new CGRect(20, 200, 280, 44); btn.SetTitle("Click Me", UIControlState.Normal); HDL_ON_iOS.AppDelegate.rootViewController.NavigationBarHidden = true; HDL_ON_iOS.AppDelegate.rootViewController.NavigationBarHidden = false; HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(user, true); btn.TouchUpInside += (sender, e) => { HDL_ON_iOS.AppDelegate.rootViewController.SetNavigationBarHidden(HDL_ON_iOS.AppDelegate.rootViewController.NavigationBarHidden ? false : true, true); }; user.View.AddSubview(btn); } } } SiriIntents/Info.plist
@@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> @@ -31,6 +31,7 @@ <string>INSendMessageIntent</string> <string>INSearchForMessagesIntent</string> <string>INSetMessageAttributeIntent</string> <string>HDLRunSceneIntent</string> </array> </dict> <key>NSExtensionPointIdentifier</key> SiriIntentsUI/Info.plist
@@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> @@ -27,6 +27,7 @@ <key>IntentsSupported</key> <array> <string>INSendMessageIntent</string> <string>HDLRunSceneIntent</string> </array> </dict> <key>NSExtensionMainStoryboard</key>