Skip to content

Defer shortcut setup to MainActivity#215

Merged
Goooler merged 3 commits into
port-214from
copilot/port-214
May 9, 2026
Merged

Defer shortcut setup to MainActivity#215
Goooler merged 3 commits into
port-214from
copilot/port-214

Conversation

Copy link
Copy Markdown

Copilot AI commented May 9, 2026

Shortcuts were being set up (and torn down) in Application.onCreate(), which runs in every process and requires eagerly reading UiStore. They were also being explicitly removed when the user hid the app icon.

Changes

  • MainApplication: Remove setupShortcuts() and its uiStore dependency entirely
  • MainActivity: Call setupShortcuts() in onCreate(); bail early if hideAppIcon is set — no removal needed
  • AppSettingsActivity: Drop ShortcutManagerCompat.removeAllDynamicShortcuts() from onHideIconChange() — disabling the launcher alias is sufficient; existing shortcuts don't need to be purged

Ports #214.

@Goooler Goooler marked this pull request as ready for review May 9, 2026 05:18
@Goooler Goooler changed the title port: defer shortcut setup to MainActivity (#214) Defer shortcut setup to MainActivity May 9, 2026
@Goooler Goooler requested a review from Copilot May 9, 2026 05:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves dynamic shortcut creation out of Application.onCreate() (which runs in all processes) and into MainActivity, and stops explicitly purging shortcuts when the launcher alias is disabled.

Changes:

  • Removed shortcut setup (and UiStore dependency) from MainApplication.
  • Added shortcut setup to MainActivity.onCreate(), skipping creation when hideAppIcon is enabled.
  • Removed removeAllDynamicShortcuts() call from AppSettingsActivity when hiding the app icon.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
app/src/main/java/com/github/kr328/clash/MainApplication.kt Removes dynamic shortcut setup from app startup to avoid running it in non-main processes.
app/src/main/java/com/github/kr328/clash/MainActivity.kt Creates dynamic shortcuts during activity creation instead of application startup.
app/src/main/java/com/github/kr328/clash/AppSettingsActivity.kt Stops purging shortcuts when toggling the launcher alias state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/java/com/github/kr328/clash/MainActivity.kt
Comment thread app/src/main/java/com/github/kr328/clash/MainActivity.kt Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Goooler Goooler changed the base branch from upstream to port-214 May 9, 2026 05:25
@Goooler Goooler merged commit 72d28fa into port-214 May 9, 2026
1 check passed
@Goooler Goooler deleted the copilot/port-214 branch May 9, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants