コード例 #1
0
        public void DonateStartTimeEntry(IWorkspace workspace, ITimeEntry timeEntry)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new StartTimerIntent();

            intent.Workspace = new INObject(workspace.Id.ToString(), workspace.Name);
            if (!string.IsNullOrEmpty(timeEntry.Description))
            {
                // If any of the tags or the project id were just created and haven't sync we ignore this action until the user repeats it
                if (timeEntry.ProjectId < 0 || timeEntry.TagIds.Any(tagId => tagId < 0))
                {
                    return;
                }

                intent.EntryDescription          = timeEntry.Description;
                intent.ProjectId                 = new INObject(timeEntry.ProjectId.ToString(), timeEntry.ProjectId.ToString());
                intent.Tags                      = timeEntry.TagIds.Select(tag => new INObject(tag.ToString(), tag.ToString())).ToArray();
                intent.Billable                  = new INObject(timeEntry.Billable.ToString(), timeEntry.Billable.ToString());
                intent.SuggestedInvocationPhrase = timeEntry.Description;
            }
            else
            {
                intent.SuggestedInvocationPhrase = "Start timer";
            }

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(onCompletion);
        }
コード例 #2
0
        public void DonateStartTimeEntry(IThreadSafeTimeEntry timeEntry)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var relevantShortcuts = new List <INRelevantShortcut>();

            var startTimerIntent = new StartTimerIntent();

            startTimerIntent.Workspace = new INObject(timeEntry.Workspace.Id.ToString(), timeEntry.Workspace.Name);

            if (!string.IsNullOrEmpty(timeEntry.Description))
            {
                // If any of the tags or the project id were just created and haven't sync we ignore this action until the user repeats it
                if (timeEntry.ProjectId < 0 || timeEntry.TagIds.Any(tagId => tagId < 0))
                {
                    return;
                }

                if (timeEntry.ProjectId is long projectId)
                {
                    var projectINObject = new INObject(timeEntry.ProjectId.ToString(), timeEntry.Project.Name);
                    startTimerIntent.ProjectId = projectINObject;
                }

                startTimerIntent.EntryDescription = timeEntry.Description;

                var tags = timeEntry.TagIds.Select(tag => new INObject(tag.ToString(), tag.ToString())).ToArray();
                startTimerIntent.Tags = tags;

                var billable = new INObject(timeEntry.Billable.ToString(), timeEntry.Billable.ToString());
                startTimerIntent.Billable = billable;
                startTimerIntent.SuggestedInvocationPhrase = string.Format(Resources.SiriTrackEntrySuggestedInvocationPhrase, timeEntry.Description);


                // Relevant shortcut for the Siri Watch Face
                relevantShortcuts.Add(createRelevantShortcut(startTimerIntent));
            }
            else
            {
                startTimerIntent.SuggestedInvocationPhrase = Resources.StartTimerInvocationPhrase;
            }

            var startTimerInteraction = new INInteraction(startTimerIntent, null);

            startTimerInteraction.DonateInteraction(trackError);

            // Descriptionless Relevant Shortcut. Always added even if the intent has one
            var descriptionlessIntent = new StartTimerIntent();

            descriptionlessIntent.Workspace = new INObject(timeEntry.Workspace.Id.ToString(), timeEntry.Workspace.Name);
            var descriptionlessShortcut = createRelevantShortcut(descriptionlessIntent);

            relevantShortcuts.Add(descriptionlessShortcut);

            donateRelevantShortcuts(relevantShortcuts.ToArray());
        }
コード例 #3
0
        public void DonateShowReport(ReportPeriod period)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new ShowReportPeriodIntent();

            switch (period)
            {
            case ReportPeriod.Today:
                intent.Period = ShowReportPeriodReportPeriod.Today;
                intent.SuggestedInvocationPhrase = $"Show {Resources.Today.ToLower()}'s time";
                break;

            case ReportPeriod.Yesterday:
                intent.Period = ShowReportPeriodReportPeriod.Yesterday;
                intent.SuggestedInvocationPhrase = $"Show {Resources.Yesterday.ToLower()}'s time";
                break;

            case ReportPeriod.LastWeek:
                intent.Period = ShowReportPeriodReportPeriod.LastWeek;
                intent.SuggestedInvocationPhrase = $"Show {Resources.LastWeek.ToLower()}'s time";
                break;

            case ReportPeriod.LastMonth:
                intent.Period = ShowReportPeriodReportPeriod.LastMonth;
                intent.SuggestedInvocationPhrase = $"Show {Resources.LastMonth.ToLower()}'s time";
                break;

            case ReportPeriod.ThisMonth:
                intent.Period = ShowReportPeriodReportPeriod.ThisMonth;
                intent.SuggestedInvocationPhrase = $"Show {Resources.ThisMonth.ToLower()}'s time";
                break;

            case ReportPeriod.ThisWeek:
                intent.Period = ShowReportPeriodReportPeriod.ThisWeek;
                intent.SuggestedInvocationPhrase = $"Show {Resources.ThisWeek.ToLower()}'s time";
                break;

            case ReportPeriod.ThisYear:
                intent.Period = ShowReportPeriodReportPeriod.ThisYear;
                intent.SuggestedInvocationPhrase = $"Show {Resources.ThisYear.ToLower()}'s time";
                break;

            case ReportPeriod.Unknown:
                intent.Period = ShowReportPeriodReportPeriod.Unknown;
                break;
            }

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(trackError);
        }
コード例 #4
0
        public void DonateShowReport()
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent      = new ShowReportIntent();
            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(onCompletion);
        }
コード例 #5
0
        public void DonateShowReport(ReportPeriod period)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new ShowReportPeriodIntent();

            switch (period)
            {
            case ReportPeriod.Today:
                intent.Period = ShowReportPeriodReportPeriod.Today;
                break;

            case ReportPeriod.Yesterday:
                intent.Period = ShowReportPeriodReportPeriod.Yesterday;
                break;

            case ReportPeriod.LastWeek:
                intent.Period = ShowReportPeriodReportPeriod.LastWeek;
                break;

            case ReportPeriod.LastMonth:
                intent.Period = ShowReportPeriodReportPeriod.LastMonth;
                break;

            case ReportPeriod.ThisMonth:
                intent.Period = ShowReportPeriodReportPeriod.ThisMonth;
                break;

            case ReportPeriod.ThisWeek:
                intent.Period = ShowReportPeriodReportPeriod.ThisWeek;
                break;

            case ReportPeriod.ThisYear:
                intent.Period = ShowReportPeriodReportPeriod.ThisYear;
                break;

            case ReportPeriod.Unknown:
                intent.Period = ShowReportPeriodReportPeriod.Unknown;
                break;
            }

            intent.SuggestedInvocationPhrase = string.Format(
                Resources.SiriShowReportSuggestedInvocationPhrase,
                period.ToHumanReadableString().ToLower());

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(trackError);
        }
コード例 #6
0
        public void DonateShowReport()
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new ShowReportIntent();

            intent.SuggestedInvocationPhrase = Resources.ShowReportsInvocationPhrase;
            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(trackError);
        }
        private void siriButtonHandler(object sender, EventArgs args)
        {
            var intent = constructStartTimerIntent(ViewModel.PasteFromClipboard.Value);

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(null);

            var vc = new INUIAddVoiceShortcutViewController(new INShortcut(intent));

            vc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
            vc.Delegate = this;
            PresentViewController(vc, true, null);
        }
コード例 #8
0
        public void DonateStopCurrentTimeEntry()
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new StopTimerIntent();

            intent.SuggestedInvocationPhrase = "Stop timer";

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(onCompletion);
        }
コード例 #9
0
 private void DonateInteraction(INInteraction interaction)
 {
     interaction.DonateInteraction(
         error =>
     {
         if (error != null)
         {
             _logger.Error($"Interaction donation failed: {error}");
         }
         else
         {
             _logger.Info("Successfully donated interaction.");
         }
     });
 }
コード例 #10
0
        public void DonateShowReport(ReportPeriod period)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new ShowReportPeriodIntent();

            switch (period)
            {
            case ReportPeriod.Today:
                intent.Period = ShowReportPeriodReportPeriod.Today;
                break;

            case ReportPeriod.Yesterday:
                intent.Period = ShowReportPeriodReportPeriod.Yesterday;
                break;

            case ReportPeriod.LastWeek:
                intent.Period = ShowReportPeriodReportPeriod.LastWeek;
                break;

            case ReportPeriod.LastMonth:
                intent.Period = ShowReportPeriodReportPeriod.LastMonth;
                break;

            case ReportPeriod.ThisMonth:
                intent.Period = ShowReportPeriodReportPeriod.ThisMonth;
                break;

            case ReportPeriod.ThisWeek:
                intent.Period = ShowReportPeriodReportPeriod.ThisWeek;
                break;

            case ReportPeriod.ThisYear:
                intent.Period = ShowReportPeriodReportPeriod.ThisYear;
                break;

            case ReportPeriod.Unknown:
                intent.Period = ShowReportPeriodReportPeriod.Unknown;
                break;
            }

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(onCompletion);
        }
コード例 #11
0
        public void DonateStopCurrentTimeEntry()
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
            {
                return;
            }

            var intent = new StopTimerIntent();

            intent.SuggestedInvocationPhrase = Resources.StopTimerInvocationPhrase;

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(trackError);

            var shortcut = createRelevantShortcut(intent);

            donateRelevantShortcuts(shortcut);
        }
コード例 #12
0
        private void siriButtonHandler(object sender, EventArgs args)
        {
            if (!(ViewModel.SelectedWorkspace.Value is IThreadSafeWorkspace workspace))
            {
                return;
            }

            var intent = new ShowReportPeriodIntent();

            intent.Period    = ViewModel.SelectReportPeriod.Value.ToShowReportPeriodReportPeriod();
            intent.Workspace = new INObject(workspace.Id.ToString(), workspace.Name);

            var interaction = new INInteraction(intent, null);

            interaction.DonateInteraction(null);

            var vc = new INUIAddVoiceShortcutViewController(new INShortcut(intent));

            vc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
            vc.Delegate = this;
            PresentViewController(vc, true, null);
        }