Пример #1
0
        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            var intent = userActivity.GetInteraction()?.Intent;

            if (intent is AddMeasureIntent adMeasureIntent)
            {
                HandleIntent(adMeasureIntent);

                return(true);
            }
            else if (intent is AddShortInsulinIntent addShortInsulinIntent)
            {
                HandleIntent(addShortInsulinIntent);

                return(true);
            }
            else if (userActivity.ActivityType == NSUserActivityHelper.AddMeasureActivityType)
            {
                HandleAddMeasureUserActivity();

                return(true);
            }

            return(false);
        }
Пример #2
0
        public static string CallHandleFromActivity(NSUserActivity activity)
        {
            // Is this a start call activity?
            if (activity.ActivityType == ActivityType)
            {
                // Yes, trap any errors
                try
                {
                    // Get first contact
                    var interaction          = activity.GetInteraction();
                    var startAudioCallIntent = interaction.Intent as INStartAudioCallIntent;
                    var contact = startAudioCallIntent.Contacts[0];

                    // Get the person handle
                    return(contact.PersonHandle.Value);
                }
                catch
                {
                    // Error, report null
                    return(null);
                }
            }
            else
            {
                // Not handled
                return(null);
            }
        }
Пример #3
0
        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            var intent = userActivity.GetInteraction()?.Intent as OrderSoupIntent;

            if (!(intent is null))
            {
                HandleIntent(intent);
                return(true);
            }
Пример #4
0
        public override bool ContinueUserActivity(
            UIApplication application,
            NSUserActivity userActivity,
            UIApplicationRestorationHandler completionHandler)
        {
            var navigationService = IosDependencyContainer.Instance.NavigationService;

            var interaction = userActivity.GetInteraction();

            if (interaction == null ||
                (interaction.IntentHandlingStatus != INIntentHandlingStatus.DeferredToApplication &&
                 interaction.IntentHandlingStatus != INIntentHandlingStatus.Unspecified))
            {
                return(false);
            }

            var intent = interaction?.Intent;

            switch (intent)
            {
            case StopTimerIntent _:
                handleDeeplink(new Uri(ApplicationUrls.TimeEntry.Stop.FromSiri));
                return(true);

            case ShowReportIntent _:
                handleDeeplink(new Uri(ApplicationUrls.Reports.Default));
                return(true);

            case ShowReportPeriodIntent periodIntent:
                long?parseLong(string val) => long.TryParse(val, out var i) ? i : (long?)null;

                long?workspaceId   = parseLong(periodIntent.Workspace?.Identifier);
                var  period        = periodIntent.Period.ToReportPeriod();
                var  viewPresenter = IosDependencyContainer.Instance.ViewPresenter;
                var  change        = new ShowReportsPresentationChange(workspaceId, period);
                viewPresenter.ChangePresentation(change);
                return(true);

            case StartTimerIntent startTimerIntent:
                var timeEntryParams = createStartTimeEntryParameters(startTimerIntent);
                navigationService.Navigate <MainViewModel>(null);
                navigationService.Navigate <StartTimeEntryViewModel, StartTimeEntryParameters>(timeEntryParams, null);
                return(true);

            default:
                return(false);
            }
        }
Пример #5
0
        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity,
                                                  UIApplicationRestorationHandler completionHandler)
        {
            var interaction = userActivity.GetInteraction();

            if (interaction == null || interaction.IntentHandlingStatus != INIntentHandlingStatus.DeferredToApplication)
            {
                return(false);
            }

            var intent = interaction?.Intent;

            switch (intent)
            {
            case StopTimerIntent _:
                navigationService.Navigate(ApplicationUrls.Main.StopTimeEntry);
                return(true);

            case ShowReportIntent _:
                navigationService.Navigate(ApplicationUrls.Reports);
                return(true);

            case ShowReportPeriodIntent periodIntent:
                var tabbarVC        = (MainTabBarController)UIApplication.SharedApplication.KeyWindow.RootViewController;
                var reportViewModel = (ReportsViewModel)tabbarVC.ViewModel.Tabs.Single(viewModel => viewModel is ReportsViewModel);
                navigationService.Navigate(reportViewModel, periodIntent.Period.ToReportPeriod());
                return(true);

            case StartTimerIntent startTimerIntent:
                var workspaceId     = (long)Convert.ToDouble(startTimerIntent.Workspace.Identifier);
                var timeEntryParams = createStartTimeEntryParameters(startTimerIntent);
                navigationService.Navigate <MainViewModel>();
                navigationService.Navigate <StartTimeEntryViewModel, StartTimeEntryParameters>(timeEntryParams);
                return(true);

            default:
                return(false);
            }
        }