Skip to content

Commit 8eb2cc7

Browse files
committed
All Off, Manual Shortcuts
1 parent 8e736a4 commit 8eb2cc7

12 files changed

+112
-69
lines changed

Intents.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,57 @@ struct AllOnIntent: AppIntent {
5757
return .result()
5858
}
5959
}
60+
61+
@available(iOS 16.0, *)
62+
struct AllOffIntent: AppIntent {
63+
static let title: LocalizedStringResource = "All Off"
64+
static let description = IntentDescription(
65+
"Turn off all LEDs",
66+
categoryName: "Device"
67+
)
68+
static let openAppWhenRun: Bool = true
69+
70+
func perform() async throws -> some IntentResult {
71+
if let url = URL(string: "leds://com.ps.TrollLEDs.AllOff") {
72+
if await UIApplication.shared.canOpenURL(url) {
73+
await UIApplication.shared.open(url)
74+
}
75+
}
76+
return .result()
77+
}
78+
}
79+
80+
@available(iOS 16.0, *)
81+
struct ManualIntent: AppIntent {
82+
static let title: LocalizedStringResource = "Manual"
83+
static let description = IntentDescription(
84+
"Configure LEDs levels manually (0 - 255) (For Quad-LEDs devices only)",
85+
categoryName: "Device"
86+
)
87+
static let openAppWhenRun: Bool = true
88+
89+
@Parameter(title: "Cool LED 0", inclusiveRange: (0, 255))
90+
var coolLED0: Int
91+
92+
@Parameter(title: "Cool LED 1", inclusiveRange: (0, 255))
93+
var coolLED1: Int
94+
95+
@Parameter(title: "Warm LED 0", inclusiveRange: (0, 255))
96+
var warmLED0: Int
97+
98+
@Parameter(title: "Warm LED 1", inclusiveRange: (0, 255))
99+
var warmLED1: Int
100+
101+
static var parameterSummary: some ParameterSummary {
102+
Summary("Configure LEDs levels to (\(\.$coolLED0), \(\.$coolLED1), \(\.$warmLED0), \(\.$warmLED1))")
103+
}
104+
105+
func perform() async throws -> some IntentResult {
106+
if let url = URL(string: "leds://com.ps.TrollLEDs.Manual?coolLED0=\(coolLED0)&coolLED1=\(coolLED1)&warmLED0=\(warmLED0)&warmLED1=\(warmLED1)") {
107+
if await UIApplication.shared.canOpenURL(url) {
108+
await UIApplication.shared.open(url)
109+
}
110+
}
111+
return .result()
112+
}
113+
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TARGET := iphone:clang:latest:11.0
22
INSTALL_TARGET_PROCESSES = TrollLEDs
33
ARCHS = arm64
4-
PACKAGE_VERSION = 1.7.0
4+
PACKAGE_VERSION = 1.8.0
55

66
include $(THEOS)/makefiles/common.mk
77

Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
<string>iPhoneOS</string>
4545
</array>
4646
<key>CFBundleShortVersionString</key>
47-
<string>1.7.0</string>
47+
<string>1.8.0</string>
4848
<key>CFBundleVersion</key>
49-
<string>1.7.0</string>
49+
<string>1.8.0</string>
5050
<key>LSRequiresIPhoneOS</key>
5151
<true/>
5252
<key>MinimumOSVersion</key>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"generator":{"version":"15.2","name":"xcode-tools"},"enums":[],"autoShortcutProviderMangledName":"9TrollLEDs0aB20AppShortcutsProviderV","entities":{},"autoShortcuts":[{"actionIdentifier":"AmberOnIntent","phraseTemplates":[{"key":"Turn on amber LEDs with ${applicationName}"}],"systemImageName":"flashlight.on.circle.fill","shortTitle":{"key":"Amber On"}},{"systemImageName":"flashlight.on.circle.fill","actionIdentifier":"WhiteOnIntent","shortTitle":{"key":"White On"},"phraseTemplates":[{"key":"Turn on white LEDs with ${applicationName}"}]},{"systemImageName":"flashlight.on.circle.fill","shortTitle":{"key":"All On"},"actionIdentifier":"AllOnIntent","phraseTemplates":[{"key":"Turn on all LEDs with ${applicationName}"}]}],"queries":{},"shortcutTileColor":14,"actions":{"AmberOnIntent":{"parameters":[],"presentationStyle":0,"identifier":"AmberOnIntent","outputFlags":0,"systemProtocols":[],"title":{"key":"Amber On"},"openAppWhenRun":true,"isDiscoverable":true,"mangledTypeNameByBundleIdentifier":{},"typeSpecificMetadata":[],"systemProtocolMetadata":[],"availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"},"LNPlatformNameIOS":{"introducedVersion":"16.0"}},"mangledTypeNameV2":"9TrollLEDs13AmberOnIntentV","mangledTypeName":"9TrollLEDs13AmberOnIntentV","effectiveBundleIdentifiers":[],"authenticationPolicy":0,"descriptionMetadata":{"descriptionText":{"key":"Turn on all amber LEDs"},"searchKeywords":[],"categoryName":{"title":{"key":"Device"}}},"requiredCapabilities":[],"mangledTypeNameByBundleIdentifierV2":{}},"WhiteOnIntent":{"identifier":"WhiteOnIntent","mangledTypeNameByBundleIdentifier":{},"isDiscoverable":true,"mangledTypeName":"9TrollLEDs13WhiteOnIntentV","requiredCapabilities":[],"openAppWhenRun":true,"authenticationPolicy":0,"mangledTypeNameByBundleIdentifierV2":{},"parameters":[],"typeSpecificMetadata":[],"descriptionMetadata":{"descriptionText":{"key":"Turn on all white LEDs"},"categoryName":{"title":{"key":"Device"}},"searchKeywords":[]},"systemProtocols":[],"presentationStyle":0,"outputFlags":0,"availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"},"LNPlatformNameIOS":{"introducedVersion":"16.0"}},"mangledTypeNameV2":"9TrollLEDs13WhiteOnIntentV","title":{"key":"White On"},"systemProtocolMetadata":[],"effectiveBundleIdentifiers":[]},"AllOnIntent":{"outputFlags":0,"systemProtocolMetadata":[],"availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"},"LNPlatformNameIOS":{"introducedVersion":"16.0"}},"presentationStyle":0,"isDiscoverable":true,"title":{"key":"All On"},"mangledTypeNameByBundleIdentifier":{},"descriptionMetadata":{"searchKeywords":[],"categoryName":{"title":{"key":"Device"}},"descriptionText":{"key":"Turn on all LEDs"}},"systemProtocols":[],"mangledTypeNameByBundleIdentifierV2":{},"parameters":[],"requiredCapabilities":[],"openAppWhenRun":true,"effectiveBundleIdentifiers":[],"authenticationPolicy":0,"mangledTypeName":"9TrollLEDs11AllOnIntentV","typeSpecificMetadata":[],"mangledTypeNameV2":"9TrollLEDs11AllOnIntentV","identifier":"AllOnIntent"}},"negativePhrases":[],"version":1}
1+
{"autoShortcuts":[{"actionIdentifier":"AmberOnIntent","shortTitle":{"key":"Amber On"},"phraseTemplates":[{"key":"Turn on amber LEDs with ${applicationName}"}],"systemImageName":"flashlight.on.circle.fill"},{"shortTitle":{"key":"White On"},"phraseTemplates":[{"key":"Turn on white LEDs with ${applicationName}"}],"actionIdentifier":"WhiteOnIntent","systemImageName":"flashlight.on.circle.fill"},{"actionIdentifier":"AllOnIntent","phraseTemplates":[{"key":"Turn on all LEDs with ${applicationName}"}],"shortTitle":{"key":"All On"},"systemImageName":"flashlight.on.circle.fill"},{"shortTitle":{"key":"All Off"},"systemImageName":"flashlight.off.circle.fill","phraseTemplates":[{"key":"Turn off all LEDs with ${applicationName}"}],"actionIdentifier":"AllOffIntent"},{"shortTitle":{"key":"Manual"},"systemImageName":"flashlight.on.circle.fill","actionIdentifier":"ManualIntent","phraseTemplates":[{"key":"Configure LEDs levels manually with ${applicationName}"}]}],"queries":{},"negativePhrases":[],"actions":{"ManualIntent":{"title":{"key":"Manual"},"parameters":[{"isOptional":false,"title":{"key":"Cool LED 0"},"dynamicOptionsSupport":0,"typeSpecificMetadata":["LNValueTypeMetadataKeyNumberRangeType",{"int":{"wrapper":0}},"LNValueTypeMetadataKeyNumberUpperBound",{"double":{"wrapper":255}},"LNValueTypeMetadataKeyNumberLowerBound",{"double":{"wrapper":0}}],"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"name":"coolLED0","inputConnectionBehavior":0,"resolvableInputTypes":[{"kindValue":0,"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}}},{"valueType":{"primitive":{"wrapper":{"typeIdentifier":7}}},"kindValue":0},{"kindValue":0,"valueType":{"primitive":{"wrapper":{"typeIdentifier":0}}}}],"isInput":false},{"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"dynamicOptionsSupport":0,"resolvableInputTypes":[{"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"kindValue":0},{"valueType":{"primitive":{"wrapper":{"typeIdentifier":7}}},"kindValue":0},{"kindValue":0,"valueType":{"primitive":{"wrapper":{"typeIdentifier":0}}}}],"title":{"key":"Cool LED 1"},"name":"coolLED1","typeSpecificMetadata":["LNValueTypeMetadataKeyNumberLowerBound",{"double":{"wrapper":0}},"LNValueTypeMetadataKeyNumberRangeType",{"int":{"wrapper":0}},"LNValueTypeMetadataKeyNumberUpperBound",{"double":{"wrapper":255}}],"isInput":false,"inputConnectionBehavior":0,"isOptional":false},{"isInput":false,"dynamicOptionsSupport":0,"title":{"key":"Warm LED 0"},"inputConnectionBehavior":0,"name":"warmLED0","isOptional":false,"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"resolvableInputTypes":[{"kindValue":0,"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}}},{"valueType":{"primitive":{"wrapper":{"typeIdentifier":7}}},"kindValue":0},{"kindValue":0,"valueType":{"primitive":{"wrapper":{"typeIdentifier":0}}}}],"typeSpecificMetadata":["LNValueTypeMetadataKeyNumberRangeType",{"int":{"wrapper":0}},"LNValueTypeMetadataKeyNumberLowerBound",{"double":{"wrapper":0}},"LNValueTypeMetadataKeyNumberUpperBound",{"double":{"wrapper":255}}]},{"isOptional":false,"isInput":false,"typeSpecificMetadata":["LNValueTypeMetadataKeyNumberUpperBound",{"double":{"wrapper":255}},"LNValueTypeMetadataKeyNumberLowerBound",{"double":{"wrapper":0}},"LNValueTypeMetadataKeyNumberRangeType",{"int":{"wrapper":0}}],"resolvableInputTypes":[{"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"kindValue":0},{"valueType":{"primitive":{"wrapper":{"typeIdentifier":7}}},"kindValue":0},{"kindValue":0,"valueType":{"primitive":{"wrapper":{"typeIdentifier":0}}}}],"title":{"key":"Warm LED 1"},"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"name":"warmLED1","inputConnectionBehavior":0,"dynamicOptionsSupport":0}],"openAppWhenRun":true,"isDiscoverable":true,"authenticationPolicy":0,"effectiveBundleIdentifiers":[],"outputFlags":0,"systemProtocols":[],"descriptionMetadata":{"searchKeywords":[],"categoryName":{"title":{"key":"Device"}},"descriptionText":{"key":"Configure LEDs levels manually (0 - 255) (For Quad-LEDs devices only)"}},"mangledTypeNameByBundleIdentifier":{},"systemProtocolMetadata":[],"typeSpecificMetadata":[],"mangledTypeNameV2":"9TrollLEDs12ManualIntentV","mangledTypeNameByBundleIdentifierV2":{},"availabilityAnnotations":{"LNPlatformNameIOS":{"introducedVersion":"16.0"},"LNPlatformNameWildcard":{"introducedVersion":"*"}},"requiredCapabilities":[],"actionConfiguration":{"actionSummary":{"wrapper":{"summaryString":{"parameterIdentifiers":["coolLED0","coolLED1","warmLED0","warmLED1"],"formatString":"Configure LEDs levels to (${coolLED0}, ${coolLED1}, ${warmLED0}, ${warmLED1})"},"otherParameterIdentifiers":[]}}},"mangledTypeName":"9TrollLEDs12ManualIntentV","presentationStyle":0,"identifier":"ManualIntent"},"AllOnIntent":{"requiredCapabilities":[],"systemProtocols":[],"systemProtocolMetadata":[],"openAppWhenRun":true,"descriptionMetadata":{"descriptionText":{"key":"Turn on all LEDs"},"categoryName":{"title":{"key":"Device"}},"searchKeywords":[]},"identifier":"AllOnIntent","parameters":[],"outputFlags":0,"typeSpecificMetadata":[],"mangledTypeNameByBundleIdentifier":{},"presentationStyle":0,"authenticationPolicy":0,"title":{"key":"All On"},"isDiscoverable":true,"effectiveBundleIdentifiers":[],"mangledTypeName":"9TrollLEDs11AllOnIntentV","availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"},"LNPlatformNameIOS":{"introducedVersion":"16.0"}},"mangledTypeNameV2":"9TrollLEDs11AllOnIntentV","mangledTypeNameByBundleIdentifierV2":{}},"AmberOnIntent":{"parameters":[],"availabilityAnnotations":{"LNPlatformNameIOS":{"introducedVersion":"16.0"},"LNPlatformNameWildcard":{"introducedVersion":"*"}},"mangledTypeNameByBundleIdentifier":{},"authenticationPolicy":0,"openAppWhenRun":true,"descriptionMetadata":{"categoryName":{"title":{"key":"Device"}},"descriptionText":{"key":"Turn on all amber LEDs"},"searchKeywords":[]},"mangledTypeNameV2":"9TrollLEDs13AmberOnIntentV","effectiveBundleIdentifiers":[],"systemProtocolMetadata":[],"typeSpecificMetadata":[],"presentationStyle":0,"identifier":"AmberOnIntent","requiredCapabilities":[],"mangledTypeNameByBundleIdentifierV2":{},"systemProtocols":[],"mangledTypeName":"9TrollLEDs13AmberOnIntentV","isDiscoverable":true,"title":{"key":"Amber On"},"outputFlags":0},"AllOffIntent":{"requiredCapabilities":[],"effectiveBundleIdentifiers":[],"parameters":[],"systemProtocolMetadata":[],"mangledTypeName":"9TrollLEDs12AllOffIntentV","identifier":"AllOffIntent","title":{"key":"All Off"},"presentationStyle":0,"descriptionMetadata":{"searchKeywords":[],"descriptionText":{"key":"Turn off all LEDs"},"categoryName":{"title":{"key":"Device"}}},"isDiscoverable":true,"systemProtocols":[],"outputFlags":0,"mangledTypeNameByBundleIdentifierV2":{},"openAppWhenRun":true,"typeSpecificMetadata":[],"authenticationPolicy":0,"mangledTypeNameV2":"9TrollLEDs12AllOffIntentV","mangledTypeNameByBundleIdentifier":{},"availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"},"LNPlatformNameIOS":{"introducedVersion":"16.0"}}},"WhiteOnIntent":{"mangledTypeName":"9TrollLEDs13WhiteOnIntentV","parameters":[],"effectiveBundleIdentifiers":[],"mangledTypeNameByBundleIdentifierV2":{},"systemProtocols":[],"isDiscoverable":true,"typeSpecificMetadata":[],"availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"},"LNPlatformNameIOS":{"introducedVersion":"16.0"}},"authenticationPolicy":0,"presentationStyle":0,"mangledTypeNameV2":"9TrollLEDs13WhiteOnIntentV","title":{"key":"White On"},"requiredCapabilities":[],"descriptionMetadata":{"categoryName":{"title":{"key":"Device"}},"searchKeywords":[],"descriptionText":{"key":"Turn on all white LEDs"}},"mangledTypeNameByBundleIdentifier":{},"outputFlags":0,"identifier":"WhiteOnIntent","openAppWhenRun":true,"systemProtocolMetadata":[]}},"entities":{},"enums":[],"autoShortcutProviderMangledName":"9TrollLEDs0aB20AppShortcutsProviderV","shortcutTileColor":14,"generator":{"name":"xcode-tools","version":"15.2"},"version":1}
Binary file not shown.
-1.33 KB
Binary file not shown.

Resources/Metadata.appintents/root.ssu.yaml

Lines changed: 0 additions & 55 deletions
This file was deleted.

ShortcutsProvider.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,21 @@ struct TrollLEDsAppShortcutsProvider: AppShortcutsProvider {
2727
shortTitle: "All On",
2828
systemImageName: "flashlight.on.circle.fill"
2929
)
30+
AppShortcut(
31+
intent: AllOffIntent(),
32+
phrases: [
33+
"Turn off all LEDs with \(.applicationName)"
34+
],
35+
shortTitle: "All Off",
36+
systemImageName: "flashlight.off.circle.fill"
37+
)
38+
AppShortcut(
39+
intent: ManualIntent(),
40+
phrases: [
41+
"Configure LEDs levels manually with \(.applicationName)"
42+
],
43+
shortTitle: "Manual",
44+
systemImageName: "flashlight.on.circle.fill"
45+
)
3046
}
3147
}

TLAppDelegate.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ - (UISceneConfiguration *)application:(UIApplication *)application configuration
2323
}
2424

2525
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler {
26-
[_myViewController handleShortcutAction:shortcutItem.type];
26+
[_myViewController handleShortcutAction:shortcutItem.type withParameters:nil];
2727
}
2828

2929
- (void)appWillEnterForeground:(UIApplication *)application {
@@ -45,8 +45,10 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction
4545
if (!url) return NO;
4646
if ([url.scheme isEqualToString:@"leds"]) {
4747
NSString *action = url.host;
48-
if (action)
49-
[_myViewController handleShortcutAction:action];
48+
if (action) {
49+
NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
50+
[_myViewController handleShortcutAction:action withParameters:components.queryItems];
51+
}
5052
}
5153
return YES;
5254
}

TLRootViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
TLDeviceManager *deviceManager;
66
}
77
@property (nonatomic, retain) NSString *shortcutAction;
8-
- (void)handleShortcutAction:(NSString *)action;
8+
- (void)handleShortcutAction:(NSString *)action withParameters:(NSArray <NSURLQueryItem *> *)params;
99
- (void)setupStream;
1010
- (void)releaseStream;
1111
@end

0 commit comments

Comments
 (0)