Skip to content

Comments

Add notification and battery optimization permission checks at launch#154

Closed
keithvassallomt wants to merge 1 commit intotimer-machine:developfrom
keithvassallomt:permission-checks
Closed

Add notification and battery optimization permission checks at launch#154
keithvassallomt wants to merge 1 commit intotimer-machine:developfrom
keithvassallomt:permission-checks

Conversation

@keithvassallomt
Copy link

Summary

  • Adds recurring permission checks when the app opens for notification permission (Android 13+) and battery optimization exemption
  • Shows a dialog explaining why each permission is needed, with "Enable" and "Not now" buttons
  • Includes a "Don't ask again" checkbox that permanently suppresses the prompt (stored in SharedPreferences)
  • Adds a "Reset permission reminders" option in Settings > Notifications to re-enable suppressed prompts
  • Permission checks are skipped while onboarding tips are still active, so new users complete the tutorial first
  • Dialogs are shown one at a time in onResume, so they re-check when the user returns from system settings

Note: This PR is a prerequisite for a follow-up PR that adds broadcast intent support for external app control of timers (see the broadcast-intents branch). The battery optimization exemption in particular is needed for broadcast receivers to start foreground services on Android 12+.

Test plan

  • Revoke notification permission on Android 13+ emulator — notification dialog appears on launch
  • Tap "Enable" — opens Android notification settings for the app
  • Grant permission, return to app — battery optimization dialog appears next
  • Tap "Enable" on battery dialog — system battery optimization prompt appears
  • Grant exemption, return to app — no more dialogs
  • Revoke permission again, check "Don't ask again" + tap "Not now" — dialog does not reappear
  • Go to Settings > Notifications > "Reset permission reminders" — snackbar confirms reset
  • Reopen app — suppressed dialogs reappear
  • Fresh install — verify onboarding tips show first, permission dialogs only appear after onboarding completes
  • Run ./gradlew test — no regressions
  • Test all of the above on an actual device (tested on Pixel 10 Pro Fold).

Shows dialogs guiding the user to enable notification permission
(Android 13+) and disable battery optimization when the app opens.
Includes "Don't ask again" checkbox and a Settings option to reset
suppressed reminders.
@DeweyReed
Copy link
Member

Thank you for your contribution!

Asking for permissions right after the app launches is a terrible user experience. Ideally, apps trigger permission requests when the user performs some actions. For example, the app requests the notification permission only when the user starts a timer.

The battery optimization exemption isn't enough on many smartphones, which is why the app has a whitelist guideline.

What does the broadcast intent support look like?

@keithvassallomt
Copy link
Author

Thank you for the feedback — you're right that prompting for permissions at launch is poor UX, and the whitelist guideline already handles battery optimization better than a simple exemption request.

I'm going to close this PR. The broadcast intent support is in a separate branch, which I'll submit as a new PR shortly. It adds a public broadcast API for external timer control (create, start, pause, resume, reset, dismiss, list) — useful for voice assistant integration.

The only permission-related change in the new PR is a settings entry for the full-screen intent permission (Android 14+), which auto-hides once granted. This one doesn't have a natural in-flow prompt point since users won't know it's missing until a timer fires without the full-screen overlay.

@keithvassallomt keithvassallomt deleted the permission-checks branch February 21, 2026 09:51
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.

2 participants