commit fb8bf902379868901245845e16e27c1a01a36c99 truex <truex@equwal.com> 2026-09-21 03:51:36 -0700 Fix system Back in the button setup From Android 13, the system does not call onBackPressed for an app with this target version. Back closed the setup at every step. The activity now registers an OnBackInvokedCallback that runs the same rule, Route.back. The arrow in the title bar was not affected.
CHANGELOG.md | 4 ++++ .../main/java/dev/equwal/assistkey/setup/GuidedSetupActivity.kt | 8 ++++++++ 2 files changed, 12 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a20d4..9f4e300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - **Change a button from the Done step.** "Change what it does" and "Change how you press it" go back to those steps with the button kept. Back on the Done step goes to the actions too. Tests: `Route.back`. +- **Fix: system Back always closed the button setup.** From Android 13 the + system does not call `onBackPressed` for an app with this target version. + The setup now registers the Back callback, and Back goes one step back. + Checked on the reader: Done, actions, how to press, main screen. ## 0.0.12-alpha - 2026-09-21 diff --git a/app/src/main/java/dev/equwal/assistkey/setup/GuidedSetupActivity.kt b/app/src/main/java/dev/equwal/assistkey/setup/GuidedSetupActivity.kt index bf5f38d..7ade463 100644 --- a/app/src/main/java/dev/equwal/assistkey/setup/GuidedSetupActivity.kt +++ b/app/src/main/java/dev/equwal/assistkey/setup/GuidedSetupActivity.kt @@ -77,6 +77,14 @@ class GuidedSetupActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + // From Android 13, the system does not call onBackPressed for an app + // with this target version. It calls this callback. Without it, Back + // always closed the screen, whatever the step. + if (android.os.Build.VERSION.SDK_INT >= 33) { + onBackInvokedDispatcher.registerOnBackInvokedCallback( + android.window.OnBackInvokedDispatcher.PRIORITY_DEFAULT + ) { @Suppress("DEPRECATION") onBackPressed() } + } savedInstanceState?.let { s -> step = Step.valueOf(s.getString("step", Step.BUTTON.name)) keys = tokens(s.getString("keys"))