Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e21bccf
V1 of screen
Aug 2, 2020
79c5d95
Fully configure cell
Aug 2, 2020
ea7d689
Fix formatting issue
Aug 3, 2020
72b36ac
Correctly calculate override duration
Aug 3, 2020
3e00ca9
Cleanup
Aug 3, 2020
03779a7
Syling
Aug 3, 2020
bb44f13
Add section
Aug 3, 2020
ca79f23
Separate cells
Aug 5, 2020
d267c16
Spacing
Aug 5, 2020
b3b15ed
Add override editor to history screen
Aug 5, 2020
ebacb3c
Cleaning up override history
Aug 12, 2020
80775ba
Clean up diff
Aug 22, 2020
78d0e2f
Merge branch 'merge-from-tidepool' into novalegra/add-override-history
novalegra Sep 15, 2020
1bcff87
endDate -> scheduledEndDate
novalegra Sep 15, 2020
b75a1a1
Add Siri overrides intent
Oct 10, 2020
95db8d7
Add override activity registering to watch
Oct 10, 2020
f0b6d20
Base work to create intent target
Oct 17, 2020
0d4179b
Add user-default-based saving
Oct 18, 2020
4151815
Fix build issues
Oct 18, 2020
f3b9179
Make it build + add sirikit auth
Oct 18, 2020
80d4318
Add app group to fix crashes
Oct 18, 2020
12657bc
Remove unneeded text + add intent build scheme
Oct 18, 2020
9e54847
Make the intent be siri-runnable
Oct 18, 2020
b601a8f
Remove todos
Oct 18, 2020
3497d02
Merge branch 'override-user-defaults' into novalegra/overrides-siri
Oct 18, 2020
23083f8
Move intent userdefaults into Loop folder
Oct 18, 2020
08714ec
Merge branch 'override-user-defaults' into novalegra/overrides-siri
Oct 18, 2020
022a13e
Add KV observer
Oct 18, 2020
29b05ad
Tweaks so KVO fires correctly
Oct 18, 2020
144e8be
Remove unused siri UI extension
Oct 18, 2020
861ca4a
Revert unintented scheme changes
Oct 18, 2020
d83c3f0
Remove todo
Oct 18, 2020
0ff8dae
Merge remote-tracking branch 'origin/dev' into novalegra/add-override…
Oct 18, 2020
7e88f6c
Auto stash before merge of "novalegra/add-override-history" and "orig…
Oct 18, 2020
a27967e
Merge branch 'novalegra/add-override-history' into novalegra/override…
Oct 18, 2020
0723bf3
Fix weird memory issue when initializing closure
Oct 20, 2020
75ff4c4
Fix memory issue
Oct 21, 2020
131083a
Typo
Oct 21, 2020
0360f32
Remove override watch nsactivity
Oct 22, 2020
b230a0d
PR-related cleanup
Oct 22, 2020
6c3e266
Fix broken codable test
Oct 22, 2020
fa5b9af
Merge remote-tracking branch 'origin/dev' into novalegra/overrides-siri
Nov 4, 2020
b95e22e
Update order of targets
Nov 4, 2020
e3c321e
Fix bundle identifier in intent extension
Nov 16, 2020
8bf962a
Only request Siri auth if it hasn't been asked for
Nov 16, 2020
e663091
Add feature flag
Nov 16, 2020
a72abf6
make intent definition name clearer
Nov 16, 2020
3cf5fac
Add dynamic options
Nov 16, 2020
23af052
Add identifier to override interaction
Nov 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 136 additions & 31 deletions Common/Base.lproj/Intents.intentdefinition
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
<key>INEnums</key>
<array/>
<key>INIntentDefinitionModelVersion</key>
<string>1.0</string>
<string>1.2</string>
<key>INIntentDefinitionNamespace</key>
<string>wqYaJi</string>
<key>INIntentDefinitionSystemVersion</key>
<string>18G87</string>
<string>19G2021</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>10G8</string>
<string>12B45b</string>
<key>INIntentDefinitionToolsVersion</key>
<string>10.3</string>
<string>12.2</string>
<key>INIntents</key>
<array>
<dict>
Expand All @@ -21,8 +23,6 @@
<string>Add a carb entry to Loop</string>
<key>INIntentDescriptionID</key>
<string>yc02Yq</string>
<key>INIntentLastParameterTag</key>
<integer>0</integer>
<key>INIntentName</key>
<string>NewCarbEntry</string>
<key>INIntentParameterCombinations</key>
Expand All @@ -31,10 +31,6 @@
<dict>
<key>INIntentParameterCombinationIsPrimary</key>
<true/>
<key>INIntentParameterCombinationSubtitle</key>
<string></string>
<key>INIntentParameterCombinationSubtitleID</key>
<string>bOiZXO</string>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<false/>
<key>INIntentParameterCombinationTitle</key>
Expand All @@ -43,51 +39,160 @@
<string>OcNxIj</string>
</dict>
</dict>
<key>INIntentParameters</key>
<array/>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeFormatString</key>
<string></string>
<key>INIntentResponseCodeFormatStringID</key>
<string>SP7STY</string>
<key>INIntentResponseCodeName</key>
<string>failure</string>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<false/>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
</dict>
<key>INIntentTitle</key>
<string>Add Carb Entry</string>
<key>INIntentTitleID</key>
<string>80eo5o</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>Add</string>
</dict>
<dict>
<key>INIntentCategory</key>
<string>generic</string>
<key>INIntentConfigurable</key>
<true/>
<key>INIntentDescription</key>
<string>Enable an override preset in Loop</string>
<key>INIntentDescriptionID</key>
<string>ZZ3mtM</string>
<key>INIntentLastParameterTag</key>
<integer>1</integer>
<key>INIntentManagedParameterCombinations</key>
<dict>
<key>overrideName</key>
<dict>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
<key>INIntentParameterCombinationUpdatesLinked</key>
<true/>
</dict>
</dict>
<key>INIntentName</key>
<string>EnableOverridePreset</string>
<key>INIntentParameterCombinations</key>
<dict>
<key>overrideName</key>
<dict>
<key>INIntentParameterCombinationSubtitle</key>
<string>Enable preset in Loop</string>
<key>INIntentParameterCombinationSubtitleID</key>
<string>XNNmtH</string>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
<key>INIntentParameterCombinationTitle</key>
<string>Enable '${overrideName}' Override Preset</string>
<key>INIntentParameterCombinationTitleID</key>
<string>oLQSsJ</string>
</dict>
</dict>
<key>INIntentParameters</key>
<array>
<dict>
<key>INIntentParameterConfigurable</key>
<true/>
<key>INIntentParameterCustomDisambiguation</key>
<true/>
<key>INIntentParameterDisplayName</key>
<string>Override Name</string>
<key>INIntentParameterDisplayNameID</key>
<string>lYMuWV</string>
<key>INIntentParameterDisplayPriority</key>
<integer>1</integer>
<key>INIntentParameterMetadata</key>
<dict>
<key>INIntentParameterMetadataCapitalization</key>
<string>None</string>
<key>INIntentParameterMetadataDefaultValueID</key>
<string>sfi0XQ</string>
</dict>
<key>INIntentParameterName</key>
<string>overrideName</string>
<key>INIntentParameterPromptDialogs</key>
<array>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogFormatString</key>
<string>Override Selection</string>
<key>INIntentParameterPromptDialogFormatStringID</key>
<string>yBzwCL</string>
<key>INIntentParameterPromptDialogType</key>
<string>Configuration</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogFormatString</key>
<string>What's the name of the override you'd like to set?</string>
<key>INIntentParameterPromptDialogFormatStringID</key>
<string>nDKAmn</string>
<key>INIntentParameterPromptDialogType</key>
<string>Primary</string>
</dict>
</array>
<key>INIntentParameterSupportsDynamicEnumeration</key>
<true/>
<key>INIntentParameterSupportsResolution</key>
<true/>
<key>INIntentParameterTag</key>
<integer>1</integer>
<key>INIntentParameterType</key>
<string>String</string>
</dict>
</array>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeFormatString</key>
<string></string>
<string>I've set the preset</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>I1DB3p</string>
<string>9KhaIS</string>
<key>INIntentResponseCodeName</key>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeFormatString</key>
<string>I wasn't able to set the preset.</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>b085BW</string>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
<key>INIntentResponseLastParameterTag</key>
<integer>0</integer>
<key>INIntentResponseParameters</key>
<array/>
</dict>
<key>INIntentRestrictions</key>
<integer>0</integer>
<key>INIntentTitle</key>
<string>Add Carb Entry</string>
<string>Enable Override Preset</string>
<key>INIntentTitleID</key>
<string>80eo5o</string>
<string>I4OZy8</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentUserConfirmationRequired</key>
<false/>
<key>INIntentVerb</key>
<string>Add</string>
<string>Do</string>
</dict>
</array>
<key>INTypes</key>
<array/>
</dict>
</plist>
42 changes: 42 additions & 0 deletions Common/Extensions/UserDefaults+LoopIntents.swift
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)
}
}
}

11 changes: 10 additions & 1 deletion Common/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct FeatureFlagConfiguration: Decodable {
let sensitivityOverridesEnabled: Bool
let simulatedCoreDataEnabled: Bool
let walshInsulinModelEnabled: Bool
let siriEnabled: Bool

fileprivate init() {
#if CGM_MANAGER_CATEGORIZE_GLUCOSE_RANGE_ENABLED
Expand Down Expand Up @@ -119,6 +120,13 @@ struct FeatureFlagConfiguration: Decodable {
#else
self.walshInsulinModelEnabled = true
#endif

// Swift compiler config is inverse, since the default state is enabled.
#if SIRI_DISABLED
self.siriEnabled = false
#else
self.siriEnabled = true
#endif
}
}

Expand All @@ -139,7 +147,8 @@ extension FeatureFlagConfiguration : CustomDebugStringConvertible {
"* scenariosEnabled: \(scenariosEnabled)",
"* sensitivityOverridesEnabled: \(sensitivityOverridesEnabled)",
"* simulatedCoreDataEnabled: \(simulatedCoreDataEnabled)",
"* walshInsulinModelEnabled: \(walshInsulinModelEnabled)"
"* walshInsulinModelEnabled: \(walshInsulinModelEnabled)",
"* siriEnabled: \(siriEnabled)",
].joined(separator: "\n")
}
}
33 changes: 33 additions & 0 deletions Common/Models/IntentExtensionInfo.swift
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 {
Copy link
Collaborator Author

@novalegra novalegra Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created IntentExtensionInfo so 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

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
}
}
45 changes: 45 additions & 0 deletions Loop Intent Extension/Info.plist
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>
18 changes: 18 additions & 0 deletions Loop Intent Extension/IntentHandler.swift
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
}
}
Loading