Esempio n. 1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            LoadApplication(new App());

            // Get possible shortcut item
            if (options != null)
            {
                LaunchedShortcutItem = options[UIApplication.LaunchOptionsShortcutItemKey] as UIApplicationShortcutItem;
            }

            // Add dynamic shortcut items
            var shortcut_continue = new UIMutableApplicationShortcutItem(ShortcutIdentifier.Continue, "Continue Book")
            {
                LocalizedSubtitle = "Continue to read you'r book",
                Icon = UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Bookmark)
            };

            var shortcut_search = new UIMutableApplicationShortcutItem(ShortcutIdentifier.Search, "Search store")
            {
                LocalizedSubtitle = "Search for a new book",
                Icon = UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Search)
            };

            // Update the application providing the initial 'dynamic' shortcut items.
            app.ShortcutItems = new UIApplicationShortcutItem[] { shortcut_continue, shortcut_search };

            return(base.FinishedLaunching(app, options));
        }
Esempio n. 2
0
        internal static UIApplicationShortcutItem ToShortcutItem(this JumpListItem jumpListItem)
        {
            var dictionary = new Dictionary <string, string>()
            {
                { JumpListItem.UnoShortcutKey, "true" }
            };

            if (jumpListItem.Logo != null)
            {
                dictionary[JumpListItem.ImagePathKey] = jumpListItem.Logo.ToString();
            }

            var displayName = jumpListItem.DisplayName;

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = " ";                 //use single space to make sure item is displayed
            }

            var shortcut =
                new UIApplicationShortcutItem(
                    jumpListItem.Arguments,
                    displayName,
                    jumpListItem.Description,
                    jumpListItem.Logo != null ? UIApplicationShortcutIcon.FromTemplateImageName(jumpListItem.Logo.LocalPath) : null,
                    NSDictionary <NSString, NSObject> .FromObjectsAndKeys(
                        dictionary.Values.Cast <object>().ToArray(),
                        dictionary.Keys.Cast <object>().ToArray()));

            return(shortcut);
        }
 private IReadOnlyDictionary <ShortcutType, UIApplicationShortcutIcon> createIcons()
 => new Dictionary <ShortcutType, UIApplicationShortcutIcon>
 {
     { ShortcutType.Reports, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Time) },
     { ShortcutType.StopTimeEntry, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Pause) },
     { ShortcutType.StartTimeEntry, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Play) },
     { ShortcutType.ContinueLastTimeEntry, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Play) }
 };
Esempio n. 4
0
        private void CreateDynamicShortcuts(UIApplication application)
        {
            var dynamicShortcut = new UIMutableApplicationShortcutItem(MenuActions.ShowPage3, "Dynamic - Page 3")
            {
                LocalizedSubtitle = "Open Page 3",
                Icon = UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Play)
            };

            application.ShortcutItems = new UIApplicationShortcutItem[] { dynamicShortcut };
        }
Esempio n. 5
0
        public async Task <object> CreatePlatformIcon(IShortcutIcon shortcutIcon)
        {
            if (string.IsNullOrWhiteSpace(shortcutIcon.IconName))
            {
                return(null);
            }

            UIApplicationShortcutIcon icon = null;

            new NSObject().BeginInvokeOnMainThread(() =>
            {
                icon = UIApplicationShortcutIcon.FromTemplateImageName(shortcutIcon.IconName);
            });

            await Task.Delay(200);

            return(icon);
        }
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            var selectedShortcutItem = ShortcutItem;

            if (selectedShortcutItem == null)
            {
                throw new InvalidProgramException("The `selectedShortcutItem` was not set.");
            }

            if (segue.Identifier == "ShortcutDetailUpdated")
            {
                // In the updated case, create a shortcut item to represent the final state of the view controller.
                UIApplicationShortcutIconType iconType = IconTypeForSelectedRow((int)PickerView.SelectedRowInComponent(0));
                var icon = UIApplicationShortcutIcon.FromType(iconType);

                var userInfo = new NSDictionary <NSString, NSObject> (AppDelegate.ApplicationShortcutUserInfoIconKey, new NSNumber(PickerView.SelectedRowInComponent(0)));
                ShortcutItem = new UIApplicationShortcutItem(selectedShortcutItem.Type, TitleTextField.Text ?? string.Empty, SubtitleTextField.Text, icon, userInfo);
            }
        }
Esempio n. 7
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Core.ViewModels.ViewModelBase.Init();
            ServiceLocator.Instance.Add <IAppInsights, AppInsights>();
            ServiceLocator.Instance.Add <IDeviceSearchProvider, SpotlightService>();

#if DEBUG
            Utils.Helpers.Settings.UserId = string.Empty;

            Xamarin.Calabash.Start();
            #endif

            //Windows Azure
            CurrentPlatform.Init();
            SQLitePCL.CurrentPlatform.Init();

            SetupGlobalAppearances();
            ConfigureJudoPayments();

            var shouldPerformAdditionalDelegateHandling = true;

            // Get possible shortcut item
            if (launchOptions != null)
            {
                LaunchedShortcutItem = launchOptions [UIApplication.LaunchOptionsShortcutItemKey] as UIApplicationShortcutItem;
                shouldPerformAdditionalDelegateHandling = (LaunchedShortcutItem == null);
            }

            // Add dynamic shortcut items
            if (application.ShortcutItems.Length == 0)
            {
                var shortcut3 = new UIMutableApplicationShortcutItem(ShortcutIdentifier.MyBeers, "My Beer")
                {
                    LocalizedSubtitle = "See the beers you've already had",
                    Icon = UIApplicationShortcutIcon.FromTemplateImageName("quickAction.myBeers.png")
                };

                // Update the application providing the initial 'dynamic' shortcut items.
                application.ShortcutItems = new UIApplicationShortcutItem[] { shortcut3 };
            }
            return(shouldPerformAdditionalDelegateHandling);
        }
Esempio n. 8
0
        public async Task <object> CreatePlatformIcon(IShortcutIcon shortcutIcon)
        {
            var isParseSuccessful = Enum.TryParse(shortcutIcon.IconName, out UIApplicationShortcutIconType type);

            if (!isParseSuccessful)
            {
                type = UIApplicationShortcutIconType.Favorite;
            }

            UIApplicationShortcutIcon icon = null;

            new NSObject().BeginInvokeOnMainThread(() =>
            {
                icon = UIApplicationShortcutIcon.FromType(type);
            });

            await Task.Delay(200);

            return(icon);
        }
Esempio n. 9
0
        internal static UIApplicationShortcutItem ToShortcutItem(this AppAction action)
        {
            var keys   = new List <NSString>();
            var values = new List <NSObject>();

            // id
            keys.Add((NSString)"id");
            values.Add((NSString)action.Id);

            // icon
            if (!string.IsNullOrEmpty(action.Icon))
            {
                keys.Add((NSString)"icon");
                values.Add((NSString)action.Icon);
            }

            return(new UIApplicationShortcutItem(
                       action.Type,
                       action.Title,
                       action.Subtitle,
                       action.Icon != null ? UIApplicationShortcutIcon.FromTemplateImageName(action.Icon) : null,
                       new NSDictionary <NSString, NSObject>(keys.ToArray(), values.ToArray())));
        }
Esempio n. 10
0
 private void CreateQuickActions()
 {
     if (TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available)
     {
         var bundleIdentifier = NSBundle.MainBundle.BundleIdentifier;
         if (bundleIdentifier != null)
         {
             var shortcutItem1 = new UIApplicationShortcutItem("(com.companyname.FoodPinn).OpenFavorites", "Show Favorites", null, UIApplicationShortcutIcon.FromTemplateImageName("favorite"), null);
             var shortcutItem2 = new UIApplicationShortcutItem("(com.companyname.FoodPinn).OpenDiscover", "Discover Restaurants", null, UIApplicationShortcutIcon.FromTemplateImageName("discover"), null);
             var shortcutItem3 = new UIApplicationShortcutItem("(com.companyname.FoodPinn).NewRestaurant", "New Restaurant", null, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Add), null);
             UIApplication.SharedApplication.ShortcutItems = new[] { shortcutItem1, shortcutItem2, shortcutItem3 };
         }
     }
 }
Esempio n. 11
0
 static UIApplicationShortcutIcon CreateIcon(UIApplicationShortcutIconType type)
 {
     return(UIApplicationShortcutIcon.FromType(type));
 }