Add App Shortcuts for service control (start/stop/toggle)#676
Open
sleshep wants to merge 1 commit intoMetaCubeX:mainfrom
Open
Add App Shortcuts for service control (start/stop/toggle)#676sleshep wants to merge 1 commit intoMetaCubeX:mainfrom
sleshep wants to merge 1 commit intoMetaCubeX:mainfrom
Conversation
…tines) Register toggle/start/stop shortcuts via ShortcutManagerCompat on app launch, enabling Samsung Routines and other launchers to control the Clash service through long-press app icon shortcuts.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add dynamic App Shortcuts for external automation
Background
The app already supports external control via intent actions (
START_CLASH/STOP_CLASH/TOGGLE_CLASH) throughExternalControlActivity, and provides a Quick Settings tile viaTileService. However, using these intent actions requires third-party tools like Tasker to send intents manually.Many Android launchers and built-in automation tools (such as Samsung Routines) can natively discover and trigger App Shortcuts, but the app doesn't currently register any. Adding App Shortcuts would allow users to control the Clash service without installing additional apps.
What this PR does
Registers three dynamic App Shortcuts via
ShortcutManagerCompaton app launch:ACTION_TOGGLE_CLASHic_baseline_swap_vertical_circleACTION_START_CLASHic_baseline_flash_onACTION_STOP_CLASHic_baseline_stopThese shortcuts:
Why dynamic shortcuts (not static XML)
shortcuts.xmlrequiresandroid:targetPackagewhich doesn't support${applicationId}placeholderapplicationId, dynamic shortcuts resolve the package name at runtimeChanges
app/.../MainApplication.kt— AddedsetupShortcuts()method called inonCreate()(main process only)design/.../values/strings.xml— Added 6 English shortcut label stringsdesign/.../values-zh/strings.xml— Added 6 Chinese shortcut label stringsCompatibility
ShortcutManagerCompatfrom AndroidX (already a dependency)