Pause the gauge pulse when the app is backgrounded, not just on destroy (#129)#130
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #129.
Problem
The low-battery/charging pulse on the circular gauge is an
INFINITEValueAnimator. 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.onPause→pausePulseAnimation()MainActivity.onPostResume→resumePulseAnimation()(restarts only if still charging or critical)New public
pausePulseAnimation()/resumePulseAnimation()onCircularProgressBarmake the lifecycle intent explicit, rather than relying on the refresh loop to restart the pulse as a side effect.Not changed
values-arwork needed.Verification
:app:compileDebugJavaWithJavacpasses.🤖 Generated with Claude Code