Skip to content

v0.4.1

Choose a tag to compare

@github-actions github-actions released this 11 Nov 16:17
· 47 commits to main since this release
c7c01c3

AltShift v0.4.1 — patch release for Android 8.0+ since v0.4. It adds a first-class battery optimization exemption flow to the onboarding wizard so the IME and keyboard monitor survive Doze and OEM process killers during long idle periods, rebuilds Step 3 as a Material 3 permission card with an in-app rationale dialog, fixes live Step 2 IME selection and cold-start auto-switch conflicts, constrains onboarding content to a readable tablet column, and makes Re-run Setup Wizard start from Step 1. No input, transliteration, or hotkey behavior changed.


🔋 Background Execution & Doze

  • BatteryHelper (ru.b1sted.altshift.util.BatteryHelper): isIgnoringBatteryOptimizations() queries PowerManager.isIgnoringBatteryOptimizations(packageName) (treating a missing power service as restricted). requestIgnoreBatteryOptimizations() launches Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS with a package: URI and falls back sequentially to ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS if the OEM hides the per-package dialog.
  • Manifest & safety guards: Declares REQUEST_IGNORE_BATTERY_OPTIMIZATIONS in AndroidManifest.xml (annotated with BatteryLife lint suppression; treated as user-revocable, never permanent), adds FLAG_ACTIVITY_NEW_TASK only for non-Activity contexts, and wraps intent launches in try/catch (RuntimeException) with Log.w.
  • Doze scope: Moves AltShift out of standard Doze/App Standby restrictions during multi-day idle periods while leaving IME binding, KeyboardMonitor, and boot recovery unchanged.

🎨 Onboarding & Permission UX

  • Step 3 Material 3 card: Displays Overlay access, Notifications, and Background execution with colored status dots. ALLOW BACKGROUND RUNNING and its description appear only while restricted, collapsing to ✓ Unrestricted (brand_success) once granted.
  • In-app rationale & resume refresh: Tapping ALLOW BACKGROUND RUNNING opens a Material 3 rationale dialog (CONTINUE triggers the system prompt; CANCEL leaves state untouched), and OnboardingActivity.onResume() re-reads BatteryHelper to update the card immediately on return.
  • Live Step 2 selection & cold-start guard: Registers a ContentObserver on Settings.Secure.DEFAULT_INPUT_METHOD (onStart–onStop) plus onWindowFocusChanged(), updating the row to AltShift is the active keyboard / CONTINUE without requiring a second tap. HardwareInputService.setAutoSwitchSuppressed(true) while the wizard is active keeps KeyboardMonitor.applyKeyboardDetached() from immediately switching back to the soft keyboard when no hardware keyboard is attached.
  • Rerun & preserved flows: EXTRA_RERUN (About → Re-run Setup Wizard) always starts at STEP_ENABLE (Step 1), while first-time launches resume at the first incomplete step. Overlay (ACTION_MANAGE_OVERLAY_PERMISSION) and Android 13+ notification (POST_NOTIFICATIONS) flows are preserved.

📱 Responsive Layout

  • Readable tablet measure: Constrains titles, descriptions (640dp max text measure), and the permission card to a centered column via onboarding_content_side_margin (0dp phones, 48dp sw600dp, 96dp sw800dp, 240dp sw800dp-land) rather than stretching across 1280dp displays.
  • Centered layout & Material 3 widgets: fillViewport with gravity="center" balances all three steps (Step 3 fits without scrolling at 1280×800dp and scrolls cleanly at larger font scales), using a 96dp icon, 16dp card radius/padding, 12dp dividers, and existing MaterialCardView/MaterialButton/bg_status_dot components.

🧪 Build, Tests & Verification

  • Version & docs: versionCode 8, versionName '0.4.1' (AltShift-v0.4.1.apk / AltShift-v0.4.1-debug.apk). Toolchain unchanged (minSdk 26, targetSdk 34, Java 21, Gradle 8.9, AGP 8.7.3). Added the Version-0.4.1 badge and background-execution summary to README.md; RELEASE-NOTES.md remains local/untracked; additive change with no DI or architecture modifications.
  • Automated checks: ./gradlew test lintDebug and ./gradlew assembleDebug passed (BUILD SUCCESSFUL), gated by the existing ModelTest, TransliterationTableTest, ThemeModeTest, and KeyLabelFormatterTest JVM suites (no instrumentation tests added).
  • Device verification (Lenovo TB710FU, Android 16 ZUI, ADB): Verified Steps 1–3 in portrait/landscape, Re-run Setup Wizard starting at Step 1, rationale → native prompt → ✓ Unrestricted (dumpsys deviceidle whitelist confirmed user,ru.b1sted.altshift), live Step 2 picker update to CONTINUE, and cold-start OnboardingActivity launch with Gboard active and no hardware keyboard attached (present=false without auto-switching back). System exemption dialog, Settings fallback, and OEM battery-manager behavior remain manually verified.

📥 Installation

Asset Description
AltShift-v0.4.1.apk Release build, R8-minified, signed with the CI release keystore.
AltShift-v0.4.1-debug.apk Debug build, unminified, signed with the local debug key.
adb install -r AltShift-v0.4.1.apk
adb shell ime enable ru.b1sted.altshift/.service.HardwareInputService
adb shell ime set ru.b1sted.altshift/.service.HardwareInputService

Optional provisioning grants:

adb shell pm grant ru.b1sted.altshift android.permission.WRITE_SECURE_SETTINGS
adb shell pm grant ru.b1sted.altshift android.permission.POST_NOTIFICATIONS
adb shell appops set ru.b1sted.altshift SYSTEM_ALERT_WINDOW allow
adb shell cmd deviceidle whitelist +ru.b1sted.altshift

Note: Debug and release APKs use different signing keys (adb uninstall ru.b1sted.altshift is required when switching between them). Uninstalling clears altshift_prefs, WRITE_SECURE_SETTINGS, and the battery exemption.


🔨 Building from Source

Requires JDK 21, Android SDK Platform 34 (Build-Tools 34.0.0), and sdk.dir in local.properties:

./gradlew test lintDebug assembleDebug
# Or signed release (with KEYSTORE_FILE / KEYSTORE_PASSWORD / KEY_ALIAS / KEY_PASSWORD or scripts/build-release.sh):
./gradlew assembleRelease

⚠️ Notes & Limitations

  • System dialog contrast & Settings toggle: The native Let app always run in background? prompt (com.android.settings) shows low-contrast body text in Android 16 dark mode (ZUI), mitigated by AltShift's pre-dialog rationale. On verified firmware, App battery usage → Allow background usage does not populate deviceidle whitelist—only the native prompt or cmd deviceidle whitelist makes isIgnoringBatteryOptimizations() return true.
  • OEM process killers & revocability: Exemption covers AOSP Doze/App Standby, while vendor task killers can still intervene (lock AltShift in Recents on ZUI for multi-day idle survival); users can revoke the exemption at any time and the onboarding row only reflects state.
  • Distribution & manual scope: REQUEST_IGNORE_BATTERY_OPTIMIZATIONS targets sideload/F-Droid builds (a Play-distributed build should use the settings-list fallback); Settings intent resolution and OEM battery UI are verified manually rather than by instrumentation tests.
  • No v0.4 input-path or backup changes: Transliteration, hotkeys, Dynamic Island geometry, notification channels, and keyboard monitor behavior are untouched, and allowBackup="false" resets preferences, WRITE_SECURE_SETTINGS, and the battery exemption on uninstall or pm clear.

🛡️ Security & Analysis (AltShift-v0.4.1.apk)


Full Changelog: v0.4...v0.4.1