-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add Siri support for overrides #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
e21bccf
V1 of screen
79c5d95
Fully configure cell
ea7d689
Fix formatting issue
72b36ac
Correctly calculate override duration
3e00ca9
Cleanup
03779a7
Syling
bb44f13
Add section
ca79f23
Separate cells
d267c16
Spacing
b3b15ed
Add override editor to history screen
ebacb3c
Cleaning up override history
80775ba
Clean up diff
78d0e2f
Merge branch 'merge-from-tidepool' into novalegra/add-override-history
novalegra 1bcff87
endDate -> scheduledEndDate
novalegra b75a1a1
Add Siri overrides intent
95db8d7
Add override activity registering to watch
f0b6d20
Base work to create intent target
0d4179b
Add user-default-based saving
4151815
Fix build issues
f3b9179
Make it build + add sirikit auth
80d4318
Add app group to fix crashes
12657bc
Remove unneeded text + add intent build scheme
9e54847
Make the intent be siri-runnable
b601a8f
Remove todos
3497d02
Merge branch 'override-user-defaults' into novalegra/overrides-siri
23083f8
Move intent userdefaults into Loop folder
08714ec
Merge branch 'override-user-defaults' into novalegra/overrides-siri
022a13e
Add KV observer
29b05ad
Tweaks so KVO fires correctly
144e8be
Remove unused siri UI extension
861ca4a
Revert unintented scheme changes
d83c3f0
Remove todo
0ff8dae
Merge remote-tracking branch 'origin/dev' into novalegra/add-override…
7e88f6c
Auto stash before merge of "novalegra/add-override-history" and "orig…
a27967e
Merge branch 'novalegra/add-override-history' into novalegra/override…
0723bf3
Fix weird memory issue when initializing closure
75ff4c4
Fix memory issue
131083a
Typo
0360f32
Remove override watch nsactivity
b230a0d
PR-related cleanup
6c3e266
Fix broken codable test
fa5b9af
Merge remote-tracking branch 'origin/dev' into novalegra/overrides-siri
b95e22e
Update order of targets
e3c321e
Fix bundle identifier in intent extension
8bf962a
Only request Siri auth if it hasn't been asked for
e663091
Add feature flag
a72abf6
make intent definition name clearer
3cf5fac
Add dynamic options
23af052
Add identifier to override interaction
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // | ||
| // UserDefaults+LoopIntents.swift | ||
| // Loop Intent Extension | ||
| // | ||
| // Created by Anna Quinlan on 10/17/20. | ||
| // Copyright © 2020 LoopKit Authors. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension UserDefaults { | ||
|
|
||
| private enum Key: String { | ||
| case IntentExtensionContext = "com.loopkit.Loop.IntentExtensionContext" | ||
| // This key needs to be EXACTLY the same string as the objc dynamic var for the KVO to work correctly | ||
| case IntentExtensionOverrideToSet = "intentExtensionOverrideToSet" | ||
| } | ||
|
|
||
| // Information for the extension from Loop | ||
| var intentExtensionInfo: IntentExtensionInfo? { | ||
| get { | ||
| if let rawValue = dictionary(forKey: Key.IntentExtensionContext.rawValue) { | ||
| return IntentExtensionInfo(rawValue: rawValue) | ||
| } else { | ||
| return nil | ||
| } | ||
| } | ||
| set { | ||
| set(newValue?.rawValue, forKey: Key.IntentExtensionContext.rawValue) | ||
| } | ||
| } | ||
|
|
||
| @objc dynamic var intentExtensionOverrideToSet: String? { | ||
| get { | ||
| return object(forKey: Key.IntentExtensionOverrideToSet.rawValue) as? String | ||
| } | ||
| set { | ||
| set(newValue, forKey: Key.IntentExtensionOverrideToSet.rawValue) | ||
| } | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // | ||
| // IntentExtensionInfo.swift | ||
| // Loop Intent Extension | ||
| // | ||
| // Created by Anna Quinlan on 10/17/20. | ||
| // Copyright © 2020 LoopKit Authors. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct IntentExtensionInfo: RawRepresentable { | ||
| typealias RawValue = [String: Any] | ||
|
|
||
| var overridePresetNames: [String]? | ||
|
|
||
| init() { } | ||
|
|
||
| init(rawValue: RawValue) { | ||
| overridePresetNames = rawValue["overridePresetNames"] as? [String] | ||
| } | ||
|
|
||
| init(overridePresetNames: [String]?) { | ||
| self.overridePresetNames = overridePresetNames | ||
| } | ||
|
|
||
| var rawValue: RawValue { | ||
| var raw: RawValue = [:] | ||
|
|
||
| raw["overridePresetNames"] = overridePresetNames | ||
|
|
||
| return raw | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>AppGroupIdentifier</key> | ||
| <string>$(APP_GROUP_IDENTIFIER)</string> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>$(DEVELOPMENT_LANGUAGE)</string> | ||
| <key>CFBundleDisplayName</key> | ||
| <string>Loop Intent Extension</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>$(MARKETING_VERSION)</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>$(CURRENT_PROJECT_VERSION)</string> | ||
| <key>NSExtension</key> | ||
| <dict> | ||
| <key>NSExtensionAttributes</key> | ||
| <dict> | ||
| <key>IntentsRestrictedWhileLocked</key> | ||
| <array/> | ||
| <key>IntentsRestrictedWhileProtectedDataUnavailable</key> | ||
| <array/> | ||
| <key>IntentsSupported</key> | ||
| <array> | ||
| <string>EnableOverridePresetIntent</string> | ||
| <string>NewCarbEntryIntent</string> | ||
| </array> | ||
| </dict> | ||
| <key>NSExtensionPointIdentifier</key> | ||
| <string>com.apple.intents-service</string> | ||
| <key>NSExtensionPrincipalClass</key> | ||
| <string>$(PRODUCT_MODULE_NAME).IntentHandler</string> | ||
| </dict> | ||
| </dict> | ||
| </plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // | ||
| // IntentHandler.swift | ||
| // Loop Intent Extension | ||
| // | ||
| // Created by Anna Quinlan on 10/17/20. | ||
| // Copyright © 2020 LoopKit Authors. All rights reserved. | ||
| // | ||
|
|
||
| import Intents | ||
|
|
||
| class IntentHandler: INExtension { | ||
| override func handler(for intent: INIntent) -> Any { | ||
| if intent is EnableOverridePresetIntent { | ||
| return OverrideIntentHandler() | ||
| } | ||
| return self | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created
IntentExtensionInfoso it would be easier to pass data between the intent extension and the main app in the event someone wanted to add other things to Loop's Siri capabilities