Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 691cdd7

Browse files
committed
feature: add app intents
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent 45f35fa commit 691cdd7

File tree

10 files changed

+165
-1
lines changed

10 files changed

+165
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TrollSpeed_FILES += $(wildcard sources/KIF/*.mm sources/KIF/*.m)
1515
TrollSpeed_FILES += $(wildcard sources/*.swift)
1616
TrollSpeed_FILES += $(wildcard sources/SPLarkController/*.swift)
1717
TrollSpeed_FILES += $(wildcard sources/SnapshotSafeView/*.swift)
18+
TrollSpeed_FILES += $(wildcard sources/Intents/*.swift)
1819

1920
TrollSpeed_CFLAGS += -fobjc-arc
2021
TrollSpeed_CFLAGS += -Iheaders

TrollSpeed.xcodeproj/project.pbxproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
CC711D9A2B5BFF2F007235A6 /* BackBoardServices.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CC711D972B5BFF2F007235A6 /* BackBoardServices.tbd */; };
6868
CC711D9C2B5C0032007235A6 /* IOKit.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CC711D9B2B5C0032007235A6 /* IOKit.tbd */; };
6969
CC711D9E2B5C0081007235A6 /* AssertionServices.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CC711D9D2B5C0081007235A6 /* AssertionServices.tbd */; };
70+
CC8DDA8F2B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */; };
71+
CC8DDA902B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */; };
72+
CC8DDA922B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */; };
73+
CC8DDA932B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */; };
74+
CC8DDA952B6551C7001C7C9E /* ToggleHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */; };
75+
CC8DDA962B6551C8001C7C9E /* ToggleHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */; };
7076
CC91309E2B616541006E3280 /* HUDBackdropLabel.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC91309D2B616541006E3280 /* HUDBackdropLabel.mm */; };
7177
CC91309F2B616541006E3280 /* HUDBackdropLabel.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC91309D2B616541006E3280 /* HUDBackdropLabel.mm */; };
7278
CC9130A32B616C18006E3280 /* HUDBackdropView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC9130A22B616C18006E3280 /* HUDBackdropView.mm */; };
@@ -160,6 +166,9 @@
160166
CC711D972B5BFF2F007235A6 /* BackBoardServices.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = BackBoardServices.tbd; sourceTree = "<group>"; };
161167
CC711D9B2B5C0032007235A6 /* IOKit.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = IOKit.tbd; sourceTree = "<group>"; };
162168
CC711D9D2B5C0081007235A6 /* AssertionServices.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = AssertionServices.tbd; sourceTree = "<group>"; };
169+
CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivateHUDIntent.swift; sourceTree = "<group>"; };
170+
CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeactivateHUDIntent.swift; sourceTree = "<group>"; };
171+
CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleHUDIntent.swift; sourceTree = "<group>"; };
163172
CC91309C2B616541006E3280 /* HUDBackdropLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HUDBackdropLabel.h; sourceTree = "<group>"; };
164173
CC91309D2B616541006E3280 /* HUDBackdropLabel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HUDBackdropLabel.mm; sourceTree = "<group>"; };
165174
CC9130A02B616BBF006E3280 /* CAFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CAFilter.h; sourceTree = "<group>"; };
@@ -236,6 +245,7 @@
236245
CC711D292B5BF5C6007235A6 /* KIF */,
237246
CC711D3A2B5BF5C6007235A6 /* SnapshotSafeView */,
238247
CC711D2F2B5BF5C6007235A6 /* SPLarkController */,
248+
CC8DDA8D2B654D7D001C7C9E /* Intents */,
239249
CC711D3F2B5BF5C6007235A6 /* JetsamHelper.h */,
240250
CC711D212B5BF5C6007235A6 /* HUDPresetPosition.h */,
241251
CC711D482B5BF5C6007235A6 /* HUDApp.mm */,
@@ -353,6 +363,16 @@
353363
path = libraries;
354364
sourceTree = "<group>";
355365
};
366+
CC8DDA8D2B654D7D001C7C9E /* Intents */ = {
367+
isa = PBXGroup;
368+
children = (
369+
CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */,
370+
CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */,
371+
CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */,
372+
);
373+
path = Intents;
374+
sourceTree = "<group>";
375+
};
356376
/* End PBXGroup section */
357377

358378
/* Begin PBXNativeTarget section */
@@ -456,6 +476,7 @@
456476
buildActionMask = 2147483647;
457477
files = (
458478
CC2BAFBA2B5CA9DD00A429D1 /* SPLarkPresentingAnimationController.swift in Sources */,
479+
CC8DDA962B6551C8001C7C9E /* ToggleHUDIntent.swift in Sources */,
459480
CC91309F2B616541006E3280 /* HUDBackdropLabel.mm in Sources */,
460481
CC2BAFBB2B5CA9DD00A429D1 /* SPLarkDismissingAnimationController.swift in Sources */,
461482
CC2BAFBC2B5CA9DD00A429D1 /* MainButton.mm in Sources */,
@@ -471,12 +492,14 @@
471492
CC2BAFC82B5CA9DD00A429D1 /* SPLarkController.swift in Sources */,
472493
CC2BAFC92B5CA9DD00A429D1 /* HUDApp.mm in Sources */,
473494
CC2BAFCB2B5CA9DD00A429D1 /* SPLarkSettingsCollectionView.swift in Sources */,
495+
CC8DDA932B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */,
474496
CC9130A82B62A33A006E3280 /* TSSettingsIndex.swift in Sources */,
475497
CC2BAFCC2B5CA9DD00A429D1 /* SPLarkSettingsController.swift in Sources */,
476498
CC2BAFCD2B5CA9DD00A429D1 /* SPLarkControllerExtension.swift in Sources */,
477499
CC2BAFCE2B5CA9DD00A429D1 /* MainApplicationDelegate.mm in Sources */,
478500
CC2BAFCF2B5CA9DD00A429D1 /* HUDRootViewController.mm in Sources */,
479501
CC2BAFD12B5CA9DD00A429D1 /* SPLarkTransitioningDelegate.swift in Sources */,
502+
CC8DDA902B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */,
480503
CC2BAFD22B5CA9DD00A429D1 /* SPLarkSettingsCollectionViewCell.swift in Sources */,
481504
);
482505
runOnlyForDeploymentPostprocessing = 0;
@@ -485,6 +508,7 @@
485508
isa = PBXSourcesBuildPhase;
486509
buildActionMask = 2147483647;
487510
files = (
511+
CC8DDA8F2B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */,
488512
CC9130A72B62A33A006E3280 /* TSSettingsIndex.swift in Sources */,
489513
CC711D4A2B5BF5C6007235A6 /* HUDHelper.mm in Sources */,
490514
CC711D532B5BF5C6007235A6 /* SPLarkPresentingAnimationController.swift in Sources */,
@@ -500,12 +524,14 @@
500524
CC711D622B5BF5C6007235A6 /* TSSettingsController.swift in Sources */,
501525
CC711D612B5BF5C6007235A6 /* HUDMainApplication.mm in Sources */,
502526
CC711D5F2B5BF5C6007235A6 /* MainApplication.mm in Sources */,
527+
CC8DDA952B6551C7001C7C9E /* ToggleHUDIntent.swift in Sources */,
503528
CC711D4B2B5BF5C6007235A6 /* RootViewController.mm in Sources */,
504529
CC711D5C2B5BF5C6007235A6 /* ScreenshotInvisibleContainer.swift in Sources */,
505530
CC711D5D2B5BF5C6007235A6 /* ScreenshotInvincibleContainerProtocol.swift in Sources */,
506531
CC711D562B5BF5C6007235A6 /* SPLarkController.swift in Sources */,
507532
CC711D642B5BF5C6007235A6 /* HUDApp.mm in Sources */,
508533
CC711D502B5BF5C6007235A6 /* IOHIDEvent+KIF.m in Sources */,
534+
CC8DDA922B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */,
509535
CC711D572B5BF5C6007235A6 /* SPLarkSettingsCollectionView.swift in Sources */,
510536
CC711D552B5BF5C6007235A6 /* SPLarkSettingsController.swift in Sources */,
511537
CC711D5B2B5BF5C6007235A6 /* SPLarkControllerExtension.swift in Sources */,

layout/Applications/TrollSpeed.app/en.lproj/Localizable.strings

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
/* formattedSpeed */
4747
"0 KB/s" = "0 KB/s";
4848

49+
/* No comment provided by engineer. */
50+
"Activate the network speed HUD." = "Activate the network speed HUD.";
51+
4952
/* No comment provided by engineer. */
5053
"Appearance" = "Appearance";
5154

@@ -61,6 +64,9 @@
6164
/* No comment provided by engineer. */
6265
"Classic" = "Classic";
6366

67+
/* No comment provided by engineer. */
68+
"Deactivate the network speed HUD." = "Deactivate the network speed HUD.";
69+
6470
/* No comment provided by engineer. */
6571
"Developer Area" = "Developer Area";
6672

@@ -133,9 +139,18 @@
133139
/* No comment provided by engineer. */
134140
"Tap that button on the center again,\nto toggle ON/OFF “Dynamic Island” mode." = "Tap that button on the center again,\nto toggle ON/OFF “Dynamic Island” mode.";
135141

142+
/* No comment provided by engineer. */
143+
"Toggle HUD" = "Toggle HUD";
144+
145+
/* No comment provided by engineer. */
146+
"Toggle the network speed HUD." = "Toggle the network speed HUD.";
147+
136148
/* No comment provided by engineer. */
137149
"Unit" = "Unit";
138150

151+
/* No comment provided by engineer. */
152+
"Utility" = "Utility";
153+
139154
/* No comment provided by engineer. */
140155
"You can quit this app now.\nThe HUD will persist on your screen." = "You can quit this app now.\nThe HUD will persist on your screen.";
141156

layout/Applications/TrollSpeed.app/es.lproj/Localizable.strings

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
/* formattedSpeed */
4747
"0 KB/s" = "0 KB/s";
4848

49+
/* No comment provided by engineer. */
50+
"Activate the network speed HUD." = "Activate the network speed HUD.";
51+
4952
/* No comment provided by engineer. */
5053
"Appearance" = "Apariencia";
5154

@@ -61,6 +64,9 @@
6164
/* No comment provided by engineer. */
6265
"Classic" = "Clásico";
6366

67+
/* No comment provided by engineer. */
68+
"Deactivate the network speed HUD." = "Deactivate the network speed HUD.";
69+
6470
/* No comment provided by engineer. */
6571
"Developer Area" = "Área de desarrollo";
6672

@@ -133,9 +139,18 @@
133139
/* No comment provided by engineer. */
134140
"Tap that button on the center again,\nto toggle ON/OFF “Dynamic Island” mode." = "Toca de nuevo el botón en el centro,\npara activar/desactivar el modo “Isla dinámica“.";
135141

142+
/* No comment provided by engineer. */
143+
"Toggle HUD" = "Toggle HUD";
144+
145+
/* No comment provided by engineer. */
146+
"Toggle the network speed HUD." = "Toggle the network speed HUD.";
147+
136148
/* No comment provided by engineer. */
137149
"Unit" = "Unid";
138150

151+
/* No comment provided by engineer. */
152+
"Utility" = "Utility";
153+
139154
/* No comment provided by engineer. */
140155
"You can quit this app now.\nThe HUD will persist on your screen." = "Puedes salir de esta aplicación ahora.\nEl HUD persistirá en tu pantalla.";
141156

layout/Applications/TrollSpeed.app/zh-Hans.lproj/Localizable.strings

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
/* formattedSpeed */
4747
"0 KB/s" = "0 KB/s";
4848

49+
/* No comment provided by engineer. */
50+
"Activate the network speed HUD." = "打开网速悬浮窗。";
51+
4952
/* No comment provided by engineer. */
5053
"Appearance" = "外观";
5154

@@ -61,6 +64,9 @@
6164
/* No comment provided by engineer. */
6265
"Classic" = "经典";
6366

67+
/* No comment provided by engineer. */
68+
"Deactivate the network speed HUD." = "关闭网速悬浮窗。";
69+
6470
/* No comment provided by engineer. */
6571
"Developer Area" = "开发者工具";
6672

@@ -133,9 +139,18 @@
133139
/* No comment provided by engineer. */
134140
"Tap that button on the center again,\nto toggle ON/OFF “Dynamic Island” mode." = "多次轻按位于中间的布局按钮,\n可以在“灵动岛”上方或下方切换布局。";
135141

142+
/* No comment provided by engineer. */
143+
"Toggle HUD" = "打开/关闭悬浮窗";
144+
145+
/* No comment provided by engineer. */
146+
"Toggle the network speed HUD." = "打开/关闭网速悬浮窗。";
147+
136148
/* No comment provided by engineer. */
137149
"Unit" = "单位";
138150

151+
/* No comment provided by engineer. */
152+
"Utility" = "实用工具";
153+
139154
/* No comment provided by engineer. */
140155
"You can quit this app now.\nThe HUD will persist on your screen." = "你现在可以退出这个应用了,\n悬浮窗将会一直显示在你的屏幕上。";
141156

layout/Library/LaunchDaemons/ch.xxtou.hudapp.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<string>Interactive</string>
2626
<key>ProgramArguments</key>
2727
<array>
28-
<string>/var/jb/Applications/TrollSpeed.app/TrollSpeed</string>
28+
<string>/Applications/TrollSpeed.app/TrollSpeed</string>
2929
<string>-hud</string>
3030
</array>
3131
<key>RunAtLoad</key>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// ActivateHUDIntent.swift
3+
// TrollSpeed
4+
//
5+
// Created by Lessica on 2024/1/27.
6+
//
7+
8+
import AppIntents
9+
10+
@available(iOS 16, *)
11+
struct ActivateHUDIntent: AppIntent {
12+
static let title: LocalizedStringResource = "Open HUD"
13+
14+
static let description = IntentDescription(
15+
"Activate the network speed HUD.",
16+
categoryName: "Utility",
17+
searchKeywords: [
18+
"activate",
19+
"open",
20+
"hud",
21+
]
22+
)
23+
24+
func perform() async throws -> some IntentResult {
25+
if !IsHUDEnabled() {
26+
SetHUDEnabled(true)
27+
return .result(value: true)
28+
}
29+
return .result(value: false)
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// DeactivateHUDIntent.swift
3+
// TrollSpeed
4+
//
5+
// Created by Lessica on 2024/1/27.
6+
//
7+
8+
import AppIntents
9+
10+
@available(iOS 16, *)
11+
struct DeactivateHUDIntent: AppIntent {
12+
static let title: LocalizedStringResource = "Exit HUD"
13+
14+
static let description = IntentDescription(
15+
"Deactivate the network speed HUD.",
16+
categoryName: "Utility",
17+
searchKeywords: [
18+
"deactivate",
19+
"exit",
20+
"hud",
21+
]
22+
)
23+
24+
func perform() async throws -> some IntentResult {
25+
if IsHUDEnabled() {
26+
SetHUDEnabled(false)
27+
return .result(value: true)
28+
}
29+
return .result(value: false)
30+
}
31+
}

sources/Intents/ToggleHUDIntent.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// ToggleHUDIntent.swift
3+
// TrollSpeed
4+
//
5+
// Created by Lessica on 2024/1/27.
6+
//
7+
8+
import AppIntents
9+
10+
@available(iOS 16, *)
11+
struct ToggleHUDIntent: AppIntent {
12+
static let title: LocalizedStringResource = "Toggle HUD"
13+
14+
static let description = IntentDescription(
15+
"Toggle the network speed HUD.",
16+
categoryName: "Utility",
17+
searchKeywords: [
18+
"toggle",
19+
"exit",
20+
"hud",
21+
]
22+
)
23+
24+
func perform() async throws -> some IntentResult {
25+
SetHUDEnabled(!IsHUDEnabled())
26+
return .result(value: true)
27+
}
28+
}

supports/hudapp-bridging-header.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#import <Foundation/Foundation.h>
1212

13+
#import "HUDHelper.h"
14+
1315
typedef NSString * HUDUserDefaultsKey;
1416

1517
static HUDUserDefaultsKey const HUDUserDefaultsKeySelectedMode = @"selectedMode";

0 commit comments

Comments
 (0)