Redesign charger notification: charging speed, wired/wireless, 3 styles (#122)#127
Merged
Merged
Conversation
…#122) Replace the misleading "AC charger connected" message with what's actually useful when plugging in: the estimated charging speed (tier + wattage) and whether charging is wired or wireless. - Add ChargeSpeed / ChargeSpeedTier with pure, unit-tested helpers that estimate charging power from CURRENT_NOW x voltage and bucket it into device-agnostic tiers (trickle -> super fast+), degrading to "unknown" when the device doesn't report instantaneous current. - Drop the unreliable AC/USB split (EXTRA_PLUGGED reports AC for many power banks and fast chargers); keep the reliable wired/wireless distinction. - Sample the current a short delay after connect (it reads 0/noisy at plug-in) rather than synchronously in the receiver. - Add a "Charge notification style" preference: Toast (default), Notification, or None, so plugging in stays low-clutter. - Localize all new strings (en + ar); remove the now-unused "charger" string. Tests: pure unit tests for the power->tier estimation and the style resolver; receiver tests updated for the deferred wired/wireless dispatch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012LC6Qt7Nr8MpJHXuszizNF
802bc06 to
201cb36
Compare
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.
Closes #122.
Replaces the misleading "AC charger connected" message with what's actually useful when you plug in: the estimated charging speed (tier + wattage) and whether charging is wired or wireless — surfaced however you prefer.
Why
EXTRA_PLUGGEDreportsBATTERY_PLUGGED_ACfor many power banks and fast chargers, so the AC/USB label was often wrong and never actionable. There's no public API for a vendor "fast charging" label, but current × voltage gives a real, device-agnostic power estimate.What changed
ChargeSpeed/ChargeSpeedTier(new) — pure, Android-free helpers that estimate power fromBATTERY_PROPERTY_CURRENT_NOW × EXTRA_VOLTAGEand bucket it into tiers (trickle → super fast+). Handles the discharge-positive sign convention, unsupported readings, and implausible values (falls back tounknown).PowerConnectionReceiver— drops the AC/USB split; keeps the reliable wired/wireless distinction. Samples current ~2 s after connect (it's 0/noisy at plug-in) on a main-thread handler, re-checking it's still plugged in.SystemService.getChargeSpeed()— reads current + voltage and builds aChargeSpeed.NotificationService.notifyChargeConnected()— branches on a new Charge notification style preference: Toast (default) / Notification / None. Message reads e.g.Wireless · Fast charging · ~18 W, orWired chargingwhen speed is unknown.ListPreference(default Toast), all new strings localized in en + ar, removed the now-orphanedchargerstring.Follow-ups (separate issues, depend on this)
#123 slow/bad-cable warning · #124 time-to-full · #125 live speed in the ongoing notification.
Testing
ChargeSpeedTestcompiled and run standalone — 26/26 pass (power→tier math, sign handling, plausibility cap, wattage rounding). Added aresolveChargeStyletest and rewrote the receiver tests for the deferred wired/wireless dispatch.dl.google.comis blocked there, and no local SDK). Please run./gradlew testDebugUnitTestto confirm the Robolectric tests before merging.Notes
CURRENT_NOWin a non-standard unit fall back to plain "charging" by design.🤖 Generated with Claude Code
https://claude.ai/code/session_012LC6Qt7Nr8MpJHXuszizNF
Generated by Claude Code