Skip to content

Pause the gauge pulse when the app is backgrounded, not just on destroy (#129)#130

Merged
almothafar merged 1 commit into
masterfrom
fix/129-pause-pulse-in-background
Jul 11, 2026
Merged

Pause the gauge pulse when the app is backgrounded, not just on destroy (#129)#130
almothafar merged 1 commit into
masterfrom
fix/129-pause-pulse-in-background

Conversation

@almothafar

Copy link
Copy Markdown
Owner

Fixes #129.

Problem

The low-battery/charging pulse on the circular gauge is an INFINITE ValueAnimator. It was only stopped when the view is destroyed (CircularProgressBar.onDetachedFromWindow) — not when the activity is backgrounded.

MainActivity.onPause() already stops the battery-polling timer for exactly this reason, but it never paused the pulse. So opening the app (e.g. at critical) and switching away without swiping it closed left the pulse invalidating ~60×/s on the main thread for a view nobody can see, as long as the screen stayed on.

Fix

Mirror the existing timer handling on both lifecycle sides:

  • MainActivity.onPausepausePulseAnimation()
  • MainActivity.onPostResumeresumePulseAnimation() (restarts only if still charging or critical)

New public pausePulseAnimation() / resumePulseAnimation() on CircularProgressBar make the lifecycle intent explicit, rather than relying on the refresh loop to restart the pulse as a side effect.

Not changed

  • Foreground behavior is identical — the gauge still breathes when the app is open at critical/charging, and still breathes after leaving and returning. This only removes wasted background work.
  • No new user-facing strings, so no values-ar work needed.

Verification

  • :app:compileDebugJavaWithJavac passes.
  • On-device (pending): set the critical threshold above the current level so the gauge goes critical immediately, then confirm the pulse (1) shows when the app is open, and (2) still animates correctly after Home → other app → return. Same with the charger plugged in.

🤖 Generated with Claude Code

…oy (#129)

The low-battery/charging pulse (an INFINITE ValueAnimator) was only stopped
in CircularProgressBar.onDetachedFromWindow, i.e. on view destroy. When the
activity was merely backgrounded with the screen on, it kept invalidating
~60x/s on the main thread for a view nobody could see.

MainActivity.onPause already stops the battery-polling timer for this exact
reason; teach it (and onPostResume) to pause/resume the pulse too. Expose
pausePulseAnimation()/resumePulseAnimation() on the view so the lifecycle
intent is explicit rather than relying on the refresh loop to restart it as
a side effect. resumePulseAnimation() restarts only if the state still calls
for it (charging or critical).

No user-facing strings; no behavior change while the app is in the foreground.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@almothafar almothafar merged commit b163340 into master Jul 11, 2026
2 checks passed
@almothafar almothafar deleted the fix/129-pause-pulse-in-background branch July 11, 2026 19:26
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.

Pulse animation keeps running while the app is backgrounded — pause it in onPause/onResume

1 participant