Skip to content

Redesign charger notification: charging speed, wired/wireless, 3 styles (#122)#127

Merged
almothafar merged 1 commit into
masterfrom
claude/charger-notification-redesign-s3g5ef
Jul 11, 2026
Merged

Redesign charger notification: charging speed, wired/wireless, 3 styles (#122)#127
almothafar merged 1 commit into
masterfrom
claude/charger-notification-redesign-s3g5ef

Conversation

@almothafar

Copy link
Copy Markdown
Owner

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_PLUGGED reports BATTERY_PLUGGED_AC for 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 from BATTERY_PROPERTY_CURRENT_NOW × EXTRA_VOLTAGE and bucket it into tiers (trickle → super fast+). Handles the discharge-positive sign convention, unsupported readings, and implausible values (falls back to unknown).
  • 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 a ChargeSpeed.
  • NotificationService.notifyChargeConnected() — branches on a new Charge notification style preference: Toast (default) / Notification / None. Message reads e.g. Wireless · Fast charging · ~18 W, or Wired charging when speed is unknown.
  • Settings + resources — new ListPreference (default Toast), all new strings localized in en + ar, removed the now-orphaned charger string.
  • README — documents the new Charging Speed & Type feature.

Follow-ups (separate issues, depend on this)

#123 slow/bad-cable warning · #124 time-to-full · #125 live speed in the ongoing notification.

Testing

  • Pure logic verified: ChargeSpeedTest compiled and run standalone — 26/26 pass (power→tier math, sign handling, plausibility cap, wattage rounding). Added a resolveChargeStyle test and rewrote the receiver tests for the deferred wired/wireless dispatch.
  • ⚠️ The full Android/Robolectric suite was not run in the authoring environment (the Android Gradle Plugin host dl.google.com is blocked there, and no local SDK). Please run ./gradlew testDebugUnitTest to confirm the Robolectric tests before merging.

Notes

  • Wattage is an estimate; devices reporting CURRENT_NOW in a non-standard unit fall back to plain "charging" by design.
  • Toast is the default per the issue; text toasts are announced by TalkBack, and users who want persistence can choose Notification.

🤖 Generated with Claude Code

https://claude.ai/code/session_012LC6Qt7Nr8MpJHXuszizNF


Generated by Claude Code

…#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
@almothafar almothafar force-pushed the claude/charger-notification-redesign-s3g5ef branch from 802bc06 to 201cb36 Compare July 11, 2026 19:19
@almothafar almothafar merged commit 6e7868c into master Jul 11, 2026
2 checks passed
@almothafar almothafar deleted the claude/charger-notification-redesign-s3g5ef branch July 11, 2026 19:21
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.

Redesign charger notification: charging speed (tier + wattage), wired/wireless, and 3 notification modes

2 participants