public override void ConfirmContinueTimer(ContinueTimerIntent intent, Action <ContinueTimerIntentResponse> completion) { if (togglAPI == null) { completion(new ContinueTimerIntentResponse(ContinueTimerIntentResponseCode.FailureNoApiToken, null)); return; } togglAPI.TimeEntries.GetAll() .ToObservable() .FirstAsync() .Select(timeEntries => timeEntries.First()) .Subscribe( timeEntry => { lastEntry = timeEntry; var userActivity = new NSUserActivity(continueTimerActivityType); userActivity.SetEntryDescription(timeEntry.Description); completion(new ContinueTimerIntentResponse(ContinueTimerIntentResponseCode.Ready, userActivity)); }, exception => { completion(new ContinueTimerIntentResponse(ContinueTimerIntentResponseCode.Failure, null)); }); }
private void setupDefaultShortcuts(IWorkspace workspace) { var startTimerIntent = new StartTimerIntent(); startTimerIntent.Workspace = new INObject(workspace.Id.ToString(), workspace.Name); startTimerIntent.SuggestedInvocationPhrase = Resources.StartTimerInvocationPhrase; var startShortcut = new INShortcut(startTimerIntent); var startRelevantShorcut = new INRelevantShortcut(startShortcut); INRelevanceProvider[] startTimerProviders = { new INDailyRoutineRelevanceProvider(INDailyRoutineSituation.Work), new INDailyRoutineRelevanceProvider(INDailyRoutineSituation.Gym), new INDailyRoutineRelevanceProvider(INDailyRoutineSituation.School) }; startRelevantShorcut.RelevanceProviders = startTimerProviders; var stopTimerIntent = new StopTimerIntent(); stopTimerIntent.SuggestedInvocationPhrase = Resources.StopTimerInvocationPhrase; var stopShortcut = new INShortcut(stopTimerIntent); var stopRelevantShortcut = new INRelevantShortcut(stopShortcut); stopRelevantShortcut.RelevanceProviders = new[] { new INDailyRoutineRelevanceProvider(INDailyRoutineSituation.Home) }; var showReportIntent = new ShowReportIntent(); showReportIntent.SuggestedInvocationPhrase = Resources.ShowReportsInvocationPhrase; var reportShortcut = new INShortcut(showReportIntent); var continueTimerIntent = new ContinueTimerIntent { SuggestedInvocationPhrase = Resources.ContinueTimerInvocationPhrase }; continueTimerIntent.Workspace = new INObject(workspace.Id.ToString(), workspace.Name); var continueTimerShortcut = new INShortcut(continueTimerIntent); var continueTimerRelevantShortcut = new INRelevantShortcut(continueTimerShortcut) { RelevanceProviders = startTimerProviders }; var shortcuts = new[] { startShortcut, stopShortcut, reportShortcut, continueTimerShortcut }; INVoiceShortcutCenter.SharedCenter.SetShortcutSuggestions(shortcuts); var relevantShortcuts = new[] { startRelevantShorcut, stopRelevantShortcut, continueTimerRelevantShortcut }; INRelevantShortcutStore.DefaultStore.SetRelevantShortcuts(relevantShortcuts, trackError); }
public INIntent CreateIntent(SiriShortcutType shortcutType) { switch (shortcutType) { case SiriShortcutType.Start: var startTimerIntent = new StartTimerIntent(); startTimerIntent.SuggestedInvocationPhrase = Resources.StartTimerInvocationPhrase; return(startTimerIntent); case SiriShortcutType.StartFromClipboard: var startTimerWithClipboardIntent = new StartTimerFromClipboardIntent(); return(startTimerWithClipboardIntent); case SiriShortcutType.Continue: var continueTimerIntent = new ContinueTimerIntent(); continueTimerIntent.SuggestedInvocationPhrase = Resources.ContinueTimerInvocationPhrase; return(continueTimerIntent); case SiriShortcutType.Stop: var stopTimerIntent = new StopTimerIntent(); stopTimerIntent.SuggestedInvocationPhrase = Resources.StopTimerInvocationPhrase; return(stopTimerIntent); case SiriShortcutType.ShowReport: var showReportIntent = new ShowReportIntent(); showReportIntent.SuggestedInvocationPhrase = Resources.ShowReportsInvocationPhrase; return(showReportIntent); /* * case SiriShortcutType.CustomStart: * break; * case SiriShortcutType.CustomReport: * break; */ default: throw new ArgumentOutOfRangeException(nameof(shortcutType), shortcutType, null); } }
public override void HandleContinueTimer(ContinueTimerIntent intent, Action <ContinueTimerIntentResponse> completion) { togglAPI.TimeEntries.Create(continueTimeEntry(lastEntry)) .Subscribe( te => { SharedStorage.instance.SetNeedsSync(true); var response = string.IsNullOrEmpty(te.Description) ? new ContinueTimerIntentResponse(ContinueTimerIntentResponseCode.Success, null) : ContinueTimerIntentResponse.SuccessWithEntryDescriptionIntentResponseWithEntryDescription( te.Description ); SharedStorage.instance.AddSiriTrackingEvent(SiriTrackingEvent.StartTimer(te)); completion(response); }, exception => { SharedStorage.instance.AddSiriTrackingEvent(SiriTrackingEvent.Error(exception.Message)); completion(new ContinueTimerIntentResponse(ContinueTimerIntentResponseCode.Failure, null)); }); }