Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
feature: add app intents
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Jan 27, 2024
1 parent 45f35fa commit 691cdd7
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ TrollSpeed_FILES += $(wildcard sources/KIF/*.mm sources/KIF/*.m)
TrollSpeed_FILES += $(wildcard sources/*.swift)
TrollSpeed_FILES += $(wildcard sources/SPLarkController/*.swift)
TrollSpeed_FILES += $(wildcard sources/SnapshotSafeView/*.swift)
TrollSpeed_FILES += $(wildcard sources/Intents/*.swift)

TrollSpeed_CFLAGS += -fobjc-arc
TrollSpeed_CFLAGS += -Iheaders
Expand Down
26 changes: 26 additions & 0 deletions TrollSpeed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
CC711D9A2B5BFF2F007235A6 /* BackBoardServices.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CC711D972B5BFF2F007235A6 /* BackBoardServices.tbd */; };
CC711D9C2B5C0032007235A6 /* IOKit.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CC711D9B2B5C0032007235A6 /* IOKit.tbd */; };
CC711D9E2B5C0081007235A6 /* AssertionServices.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CC711D9D2B5C0081007235A6 /* AssertionServices.tbd */; };
CC8DDA8F2B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */; };
CC8DDA902B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */; };
CC8DDA922B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */; };
CC8DDA932B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */; };
CC8DDA952B6551C7001C7C9E /* ToggleHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */; };
CC8DDA962B6551C8001C7C9E /* ToggleHUDIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */; };
CC91309E2B616541006E3280 /* HUDBackdropLabel.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC91309D2B616541006E3280 /* HUDBackdropLabel.mm */; };
CC91309F2B616541006E3280 /* HUDBackdropLabel.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC91309D2B616541006E3280 /* HUDBackdropLabel.mm */; };
CC9130A32B616C18006E3280 /* HUDBackdropView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC9130A22B616C18006E3280 /* HUDBackdropView.mm */; };
Expand Down Expand Up @@ -160,6 +166,9 @@
CC711D972B5BFF2F007235A6 /* BackBoardServices.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = BackBoardServices.tbd; sourceTree = "<group>"; };
CC711D9B2B5C0032007235A6 /* IOKit.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = IOKit.tbd; sourceTree = "<group>"; };
CC711D9D2B5C0081007235A6 /* AssertionServices.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = AssertionServices.tbd; sourceTree = "<group>"; };
CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivateHUDIntent.swift; sourceTree = "<group>"; };
CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeactivateHUDIntent.swift; sourceTree = "<group>"; };
CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleHUDIntent.swift; sourceTree = "<group>"; };
CC91309C2B616541006E3280 /* HUDBackdropLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HUDBackdropLabel.h; sourceTree = "<group>"; };
CC91309D2B616541006E3280 /* HUDBackdropLabel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HUDBackdropLabel.mm; sourceTree = "<group>"; };
CC9130A02B616BBF006E3280 /* CAFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CAFilter.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -236,6 +245,7 @@
CC711D292B5BF5C6007235A6 /* KIF */,
CC711D3A2B5BF5C6007235A6 /* SnapshotSafeView */,
CC711D2F2B5BF5C6007235A6 /* SPLarkController */,
CC8DDA8D2B654D7D001C7C9E /* Intents */,
CC711D3F2B5BF5C6007235A6 /* JetsamHelper.h */,
CC711D212B5BF5C6007235A6 /* HUDPresetPosition.h */,
CC711D482B5BF5C6007235A6 /* HUDApp.mm */,
Expand Down Expand Up @@ -353,6 +363,16 @@
path = libraries;
sourceTree = "<group>";
};
CC8DDA8D2B654D7D001C7C9E /* Intents */ = {
isa = PBXGroup;
children = (
CC8DDA942B655183001C7C9E /* ToggleHUDIntent.swift */,
CC8DDA8E2B654DC8001C7C9E /* ActivateHUDIntent.swift */,
CC8DDA912B655156001C7C9E /* DeactivateHUDIntent.swift */,
);
path = Intents;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -456,6 +476,7 @@
buildActionMask = 2147483647;
files = (
CC2BAFBA2B5CA9DD00A429D1 /* SPLarkPresentingAnimationController.swift in Sources */,
CC8DDA962B6551C8001C7C9E /* ToggleHUDIntent.swift in Sources */,
CC91309F2B616541006E3280 /* HUDBackdropLabel.mm in Sources */,
CC2BAFBB2B5CA9DD00A429D1 /* SPLarkDismissingAnimationController.swift in Sources */,
CC2BAFBC2B5CA9DD00A429D1 /* MainButton.mm in Sources */,
Expand All @@ -471,12 +492,14 @@
CC2BAFC82B5CA9DD00A429D1 /* SPLarkController.swift in Sources */,
CC2BAFC92B5CA9DD00A429D1 /* HUDApp.mm in Sources */,
CC2BAFCB2B5CA9DD00A429D1 /* SPLarkSettingsCollectionView.swift in Sources */,
CC8DDA932B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */,
CC9130A82B62A33A006E3280 /* TSSettingsIndex.swift in Sources */,
CC2BAFCC2B5CA9DD00A429D1 /* SPLarkSettingsController.swift in Sources */,
CC2BAFCD2B5CA9DD00A429D1 /* SPLarkControllerExtension.swift in Sources */,
CC2BAFCE2B5CA9DD00A429D1 /* MainApplicationDelegate.mm in Sources */,
CC2BAFCF2B5CA9DD00A429D1 /* HUDRootViewController.mm in Sources */,
CC2BAFD12B5CA9DD00A429D1 /* SPLarkTransitioningDelegate.swift in Sources */,
CC8DDA902B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */,
CC2BAFD22B5CA9DD00A429D1 /* SPLarkSettingsCollectionViewCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -485,6 +508,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CC8DDA8F2B654DC8001C7C9E /* ActivateHUDIntent.swift in Sources */,
CC9130A72B62A33A006E3280 /* TSSettingsIndex.swift in Sources */,
CC711D4A2B5BF5C6007235A6 /* HUDHelper.mm in Sources */,
CC711D532B5BF5C6007235A6 /* SPLarkPresentingAnimationController.swift in Sources */,
Expand All @@ -500,12 +524,14 @@
CC711D622B5BF5C6007235A6 /* TSSettingsController.swift in Sources */,
CC711D612B5BF5C6007235A6 /* HUDMainApplication.mm in Sources */,
CC711D5F2B5BF5C6007235A6 /* MainApplication.mm in Sources */,
CC8DDA952B6551C7001C7C9E /* ToggleHUDIntent.swift in Sources */,
CC711D4B2B5BF5C6007235A6 /* RootViewController.mm in Sources */,
CC711D5C2B5BF5C6007235A6 /* ScreenshotInvisibleContainer.swift in Sources */,
CC711D5D2B5BF5C6007235A6 /* ScreenshotInvincibleContainerProtocol.swift in Sources */,
CC711D562B5BF5C6007235A6 /* SPLarkController.swift in Sources */,
CC711D642B5BF5C6007235A6 /* HUDApp.mm in Sources */,
CC711D502B5BF5C6007235A6 /* IOHIDEvent+KIF.m in Sources */,
CC8DDA922B655156001C7C9E /* DeactivateHUDIntent.swift in Sources */,
CC711D572B5BF5C6007235A6 /* SPLarkSettingsCollectionView.swift in Sources */,
CC711D552B5BF5C6007235A6 /* SPLarkSettingsController.swift in Sources */,
CC711D5B2B5BF5C6007235A6 /* SPLarkControllerExtension.swift in Sources */,
Expand Down
15 changes: 15 additions & 0 deletions layout/Applications/TrollSpeed.app/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
/* formattedSpeed */
"0 KB/s" = "0 KB/s";

/* No comment provided by engineer. */
"Activate the network speed HUD." = "Activate the network speed HUD.";

/* No comment provided by engineer. */
"Appearance" = "Appearance";

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

/* No comment provided by engineer. */
"Deactivate the network speed HUD." = "Deactivate the network speed HUD.";

/* No comment provided by engineer. */
"Developer Area" = "Developer Area";

Expand Down Expand Up @@ -133,9 +139,18 @@
/* No comment provided by engineer. */
"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.";

/* No comment provided by engineer. */
"Toggle HUD" = "Toggle HUD";

/* No comment provided by engineer. */
"Toggle the network speed HUD." = "Toggle the network speed HUD.";

/* No comment provided by engineer. */
"Unit" = "Unit";

/* No comment provided by engineer. */
"Utility" = "Utility";

/* No comment provided by engineer. */
"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.";

Expand Down
15 changes: 15 additions & 0 deletions layout/Applications/TrollSpeed.app/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
/* formattedSpeed */
"0 KB/s" = "0 KB/s";

/* No comment provided by engineer. */
"Activate the network speed HUD." = "Activate the network speed HUD.";

/* No comment provided by engineer. */
"Appearance" = "Apariencia";

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

/* No comment provided by engineer. */
"Deactivate the network speed HUD." = "Deactivate the network speed HUD.";

/* No comment provided by engineer. */
"Developer Area" = "Área de desarrollo";

Expand Down Expand Up @@ -133,9 +139,18 @@
/* No comment provided by engineer. */
"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“.";

/* No comment provided by engineer. */
"Toggle HUD" = "Toggle HUD";

/* No comment provided by engineer. */
"Toggle the network speed HUD." = "Toggle the network speed HUD.";

/* No comment provided by engineer. */
"Unit" = "Unid";

/* No comment provided by engineer. */
"Utility" = "Utility";

/* No comment provided by engineer. */
"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.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
/* formattedSpeed */
"0 KB/s" = "0 KB/s";

/* No comment provided by engineer. */
"Activate the network speed HUD." = "打开网速悬浮窗。";

/* No comment provided by engineer. */
"Appearance" = "外观";

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

/* No comment provided by engineer. */
"Deactivate the network speed HUD." = "关闭网速悬浮窗。";

/* No comment provided by engineer. */
"Developer Area" = "开发者工具";

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

/* No comment provided by engineer. */
"Toggle HUD" = "打开/关闭悬浮窗";

/* No comment provided by engineer. */
"Toggle the network speed HUD." = "打开/关闭网速悬浮窗。";

/* No comment provided by engineer. */
"Unit" = "单位";

/* No comment provided by engineer. */
"Utility" = "实用工具";

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

Expand Down
2 changes: 1 addition & 1 deletion layout/Library/LaunchDaemons/ch.xxtou.hudapp.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<string>Interactive</string>
<key>ProgramArguments</key>
<array>
<string>/var/jb/Applications/TrollSpeed.app/TrollSpeed</string>
<string>/Applications/TrollSpeed.app/TrollSpeed</string>
<string>-hud</string>
</array>
<key>RunAtLoad</key>
Expand Down
31 changes: 31 additions & 0 deletions sources/Intents/ActivateHUDIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// ActivateHUDIntent.swift
// TrollSpeed
//
// Created by Lessica on 2024/1/27.
//

import AppIntents

@available(iOS 16, *)
struct ActivateHUDIntent: AppIntent {
static let title: LocalizedStringResource = "Open HUD"

static let description = IntentDescription(
"Activate the network speed HUD.",
categoryName: "Utility",
searchKeywords: [
"activate",
"open",
"hud",
]
)

func perform() async throws -> some IntentResult {
if !IsHUDEnabled() {
SetHUDEnabled(true)
return .result(value: true)
}
return .result(value: false)
}
}
31 changes: 31 additions & 0 deletions sources/Intents/DeactivateHUDIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// DeactivateHUDIntent.swift
// TrollSpeed
//
// Created by Lessica on 2024/1/27.
//

import AppIntents

@available(iOS 16, *)
struct DeactivateHUDIntent: AppIntent {
static let title: LocalizedStringResource = "Exit HUD"

static let description = IntentDescription(
"Deactivate the network speed HUD.",
categoryName: "Utility",
searchKeywords: [
"deactivate",
"exit",
"hud",
]
)

func perform() async throws -> some IntentResult {
if IsHUDEnabled() {
SetHUDEnabled(false)
return .result(value: true)
}
return .result(value: false)
}
}
28 changes: 28 additions & 0 deletions sources/Intents/ToggleHUDIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// ToggleHUDIntent.swift
// TrollSpeed
//
// Created by Lessica on 2024/1/27.
//

import AppIntents

@available(iOS 16, *)
struct ToggleHUDIntent: AppIntent {
static let title: LocalizedStringResource = "Toggle HUD"

static let description = IntentDescription(
"Toggle the network speed HUD.",
categoryName: "Utility",
searchKeywords: [
"toggle",
"exit",
"hud",
]
)

func perform() async throws -> some IntentResult {
SetHUDEnabled(!IsHUDEnabled())
return .result(value: true)
}
}
2 changes: 2 additions & 0 deletions supports/hudapp-bridging-header.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#import <Foundation/Foundation.h>

#import "HUDHelper.h"

typedef NSString * HUDUserDefaultsKey;

static HUDUserDefaultsKey const HUDUserDefaultsKeySelectedMode = @"selectedMode";
Expand Down

0 comments on commit 691cdd7

Please sign in to comment.