From 515ca9fb76192ac2fd04afc95e8a6fa1b958efa3 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 21 Feb 2023 19:36:49 +0100 Subject: [PATCH] Fixes and start of siri intent --- LeCountdown.xcodeproj/project.pbxproj | 6 + LeCountdown/Conductor.swift | 12 +- LeCountdown/Info.plist | 3 +- LeCountdown/LeCountdownApp.swift | 2 +- LeCountdown/SiriIntents.intentdefinition | 220 ++++++++++++++++++++++ LeCountdown/Views/LiveTimerListView.swift | 1 + LeCountdown/Views/Stats/RecordsView.swift | 6 +- 7 files changed, 241 insertions(+), 9 deletions(-) create mode 100644 LeCountdown/SiriIntents.intentdefinition diff --git a/LeCountdown.xcodeproj/project.pbxproj b/LeCountdown.xcodeproj/project.pbxproj index 9829b0e..c4a1665 100644 --- a/LeCountdown.xcodeproj/project.pbxproj +++ b/LeCountdown.xcodeproj/project.pbxproj @@ -127,6 +127,7 @@ C4BA2B6529A3C37D00CB4FBA /* Filter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2B6429A3C37D00CB4FBA /* Filter.swift */; }; C4BA2B6829A3C4AC00CB4FBA /* Context+Calculations.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2B6729A3C4AC00CB4FBA /* Context+Calculations.swift */; }; C4BA2B6A29A4BE1800CB4FBA /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2B6929A4BE1800CB4FBA /* Date+Extensions.swift */; }; + C4BA2B7129A51CA000CB4FBA /* SiriIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2B7029A51CA000CB4FBA /* SiriIntents.intentdefinition */; }; C4F8B1532987FE6F005C86A5 /* LaunchWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C438C7D72981216200BF3EF9 /* LaunchWidgetLiveActivity.swift */; }; C4F8B15729891271005C86A5 /* Conductor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F8B15629891271005C86A5 /* Conductor.swift */; }; C4F8B15929891528005C86A5 /* forest_stream.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C4F8B15829891528005C86A5 /* forest_stream.mp3 */; }; @@ -323,6 +324,7 @@ C4BA2B6729A3C4AC00CB4FBA /* Context+Calculations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Context+Calculations.swift"; sourceTree = ""; }; C4BA2B6929A4BE1800CB4FBA /* Date+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = ""; }; C4BA2B6B29A4C47100CB4FBA /* LeCountdown.0.6.2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LeCountdown.0.6.2.xcdatamodel; sourceTree = ""; }; + C4BA2B7029A51CA000CB4FBA /* SiriIntents.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = SiriIntents.intentdefinition; sourceTree = ""; }; C4F8B15629891271005C86A5 /* Conductor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Conductor.swift; sourceTree = ""; }; C4F8B15829891528005C86A5 /* forest_stream.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = forest_stream.mp3; sourceTree = ""; }; C4F8B15E298961A7005C86A5 /* ReorderableForEach.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReorderableForEach.swift; sourceTree = ""; }; @@ -436,6 +438,7 @@ C4BA2B55299FFA3700CB4FBA /* Subscription */, C4060DC3297AE73D003FAB80 /* Assets.xcassets */, C438C80429813B3100BF3EF9 /* LeCountdown.entitlements */, + C4BA2B7029A51CA000CB4FBA /* SiriIntents.intentdefinition */, C4060DCD297AE73D003FAB80 /* Info.plist */, C4060DC5297AE73D003FAB80 /* Preview Content */, ); @@ -937,6 +940,7 @@ C438C7C12980228B00BF3EF9 /* CountdownScheduler.swift in Sources */, C498E5A3298D720600E90DE0 /* TestView.swift in Sources */, C4BA2B06299A8F8D00CB4FBA /* PresetsView.swift in Sources */, + C4BA2B7129A51CA000CB4FBA /* SiriIntents.intentdefinition in Sources */, C445FA8F2987B83B0054D761 /* SoundPlayer.swift in Sources */, C4F8B1A7298AC2FC005C86A5 /* AbstractSoundTimer+CoreDataClass.swift in Sources */, C438C7C929803CA000BF3EF9 /* AppDelegate.swift in Sources */, @@ -1234,6 +1238,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = LeCountdown/Info.plist; + INFOPLIST_KEY_NSAppleMusicUsageDescription = NSAppleMusicUsageDescription; INFOPLIST_KEY_NSSupportsLiveActivities = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -1266,6 +1271,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = LeCountdown/Info.plist; + INFOPLIST_KEY_NSAppleMusicUsageDescription = NSAppleMusicUsageDescription; INFOPLIST_KEY_NSSupportsLiveActivities = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/LeCountdown/Conductor.swift b/LeCountdown/Conductor.swift index 5e4c220..da16b08 100644 --- a/LeCountdown/Conductor.swift +++ b/LeCountdown/Conductor.swift @@ -9,6 +9,7 @@ import Foundation import ActivityKit import BackgroundTasks import SwiftUI +//import Intents class Conductor: ObservableObject { @@ -110,6 +111,8 @@ class Conductor: ObservableObject { // self._launchLiveActivity(countdown: countdown, endDate: date) self._cleanupTimers.removeValue(forKey: countdown.stringId) + + } } @@ -135,7 +138,12 @@ class Conductor: ObservableObject { } } - func cleanupCountdowns() { + func cleanup() { + self._cleanupCountdowns() + self._buildLiveTimers() + } + + fileprivate func _cleanupCountdowns() { let now = Date() for (key, value) in self.currentCountdowns { if value.end < now { @@ -151,6 +159,8 @@ class Conductor: ObservableObject { let now = Date() Conductor.maestro.currentStopwatches[stopwatch.stringId] = now self._launchLiveActivity(stopwatch: stopwatch, start: now) + +// LaunchTim } } diff --git a/LeCountdown/Info.plist b/LeCountdown/Info.plist index 472acae..ddc8c6b 100644 --- a/LeCountdown/Info.plist +++ b/LeCountdown/Info.plist @@ -2,14 +2,13 @@ - NSAppleMusicUsageDescription - NSAppleMusicUsageDescription BGTaskSchedulerPermittedIdentifiers com.staxriver.lecountdown.refresh NSUserActivityTypes + LaunchTimerIntent SelectTimerIntent UIApplicationSceneManifest diff --git a/LeCountdown/LeCountdownApp.swift b/LeCountdown/LeCountdownApp.swift index ee3bb52..6ee4ce7 100644 --- a/LeCountdown/LeCountdownApp.swift +++ b/LeCountdown/LeCountdownApp.swift @@ -72,7 +72,7 @@ struct LeCountdownApp: App { } fileprivate func _willEnterForegroundNotification() { - Conductor.maestro.cleanupCountdowns() + Conductor.maestro.cleanup() } fileprivate func _onAppear() { diff --git a/LeCountdown/SiriIntents.intentdefinition b/LeCountdown/SiriIntents.intentdefinition new file mode 100644 index 0000000..8d5a7c3 --- /dev/null +++ b/LeCountdown/SiriIntents.intentdefinition @@ -0,0 +1,220 @@ + + + + + INEnums + + INIntentDefinitionModelVersion + 1.2 + INIntentDefinitionNamespace + ggxqDx + INIntentDefinitionSystemVersion + 22A400 + INIntentDefinitionToolsBuildVersion + 14C18 + INIntentDefinitionToolsVersion + 14.2 + INIntents + + + INIntentCategory + start + INIntentConfigurable + + INIntentDescription + Launch timers and stopwatches + INIntentDescriptionID + NdKydA + INIntentInput + timer + INIntentKeyParameter + timer + INIntentLastParameterTag + 2 + INIntentManagedParameterCombinations + + timer + + INIntentParameterCombinationSupportsBackgroundExecution + + INIntentParameterCombinationUpdatesLinked + + + + INIntentName + LaunchTimer + INIntentParameterCombinations + + timer + + INIntentParameterCombinationIsLinked + + INIntentParameterCombinationIsPrimary + + INIntentParameterCombinationSupportsBackgroundExecution + + + + INIntentParameters + + + INIntentParameterConfigurable + + INIntentParameterDisplayName + Timer + INIntentParameterDisplayNameID + wU1mYs + INIntentParameterDisplayPriority + 1 + INIntentParameterName + timer + INIntentParameterObjectType + Type + INIntentParameterObjectTypeNamespace + ggxqDx + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Primary + + + INIntentParameterSupportsResolution + + INIntentParameterTag + 2 + INIntentParameterType + Object + + + INIntentResponse + + INIntentResponseCodes + + + INIntentResponseCodeFormatString + Your ${timer} has been launched + INIntentResponseCodeFormatStringID + E3Sz5n + INIntentResponseCodeName + success + INIntentResponseCodeSuccess + + + + INIntentResponseCodeName + failure + + + INIntentResponseLastParameterTag + 2 + INIntentResponseOutput + timer + INIntentResponseParameters + + + INIntentResponseParameterDisplayName + Timer + INIntentResponseParameterDisplayNameID + Vfpf1t + INIntentResponseParameterDisplayPriority + 1 + INIntentResponseParameterName + timer + INIntentResponseParameterObjectType + Type + INIntentResponseParameterObjectTypeNamespace + ggxqDx + INIntentResponseParameterTag + 2 + INIntentResponseParameterType + Object + + + + INIntentTitle + Launch Timer + INIntentTitleID + nrTIGB + INIntentType + Custom + INIntentVerb + Start + + + INTypes + + + INTypeDisplayName + Timer + INTypeDisplayNameID + 02RXTq + INTypeLastPropertyTag + 99 + INTypeName + Type + INTypeProperties + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 1 + INTypePropertyName + identifier + INTypePropertyTag + 1 + INTypePropertyType + String + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 2 + INTypePropertyName + displayString + INTypePropertyTag + 2 + INTypePropertyType + String + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 3 + INTypePropertyName + pronunciationHint + INTypePropertyTag + 3 + INTypePropertyType + String + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 4 + INTypePropertyName + alternativeSpeakableMatches + INTypePropertySupportsMultipleValues + + INTypePropertyTag + 4 + INTypePropertyType + SpeakableString + + + + + + diff --git a/LeCountdown/Views/LiveTimerListView.swift b/LeCountdown/Views/LiveTimerListView.swift index b6d7c8b..282d39a 100644 --- a/LeCountdown/Views/LiveTimerListView.swift +++ b/LeCountdown/Views/LiveTimerListView.swift @@ -42,6 +42,7 @@ struct TimeView: View { var body: some View { Text(self.text) .font(.system(size: timerFontSize, weight: .medium)) + .minimumScaleFactor(0.1) } } diff --git a/LeCountdown/Views/Stats/RecordsView.swift b/LeCountdown/Views/Stats/RecordsView.swift index 9c8412a..eca616b 100644 --- a/LeCountdown/Views/Stats/RecordsView.swift +++ b/LeCountdown/Views/Stats/RecordsView.swift @@ -24,11 +24,7 @@ struct RecordsView: View { var activity: Activity - var timeFrame: TimeFrame { - didSet { - self._loadFilters() - } - } + var timeFrame: TimeFrame @StateObject var model: RecordsModel = RecordsModel()