Add a charging gauge: battery level on the eight LEDs when the charger goes in - #21
Open
Joerikros wants to merge 3 commits into
Open
Add a charging gauge: battery level on the eight LEDs when the charger goes in#21Joerikros wants to merge 3 commits into
Joerikros wants to merge 3 commits into
Conversation
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.
What this adds
A charging gauge: when the charger goes in, and again when the battery reaches 100%, the
eight LEDs fill up to the battery level, with the last LED dimmed to its share (73% = five
full LEDs and a sixth at 84%). It lives as a single rule card on the Apps tab, below the
privacy rules, with its own full-screen editor.
Look
LED, plus eleven ready-made presets (Traffic light, Red → green, Fire, Sunset, Ocean,
Aurora, Rainbow, Four colours, Ice, Mint, White).
Readability — the eight LEDs sit behind one diffuser, so a solid run blurs into one glow:
goes dark briefly and counts again for as long as the gauge shows.
separate dots.
Timing
brightness; "only when the screen is off"; optional repeat every N minutes while the
charger stays in (off by default). The rule itself is off by default.
How it is wired
Pattern.BATTERYis a new renderer pattern (core/Renderer.java, mirrored inPreview.ktfor the on-screen strip). It is markedinternaland hidden from the Stylecarousel and the rule pickers, since it needs a level only the charging trigger supplies.
ChargingRule(singleton, prefs keychargingRule) andChargingEvents, a pure trackerthat decides plug-in and full moments once per charging session — starting the app on the
charger is not a plug-in, and a phone sitting at 100% does not re-fire.
Storefires it as an ordinary finite alert (AlertSource.CHARGING,arm = false)from the existing power receiver, now also listening to
ACTION_BATTERY_CHANGED. Theone-minute cap, duty-cycle guard, sustained-brightness taper, quiet hours and Battery
Saver all apply unchanged;
Engineis not touched. The low-battery guard never blocks it,because on the charger the level is already reported as full.
cancelAlert()leaves a charging alert alone when the screencomes on — the screen waking as the charger goes in is exactly when the gauge is read.
PatternCarouselis generalised intoChipCarousel<T>(with an optional leading slot forthe preset miniatures); the Style tab uses it unchanged.
Tests
131 unit tests pass (
:app:testDebugUnitTest :app:build :app:lintall green). New:RendererBatteryTest— fill maths, partial LED, alternate dimming, the one-by-onetimeline (count / hold / gap / restart), the tip blink, clamping.
ChargingEventsTest— once-per-session plug-in and full, priming on start-up, unplug reset.ChargingRuleTest,ChargingPresetTest— prefs round trips, clamping of malformed values,alert JSON, preset matching.
PrivacyRuleTestupdated for theinternalpattern flag.Device verification
Pixel 11 Pro XL, Android 17 (API 37), Shizuku transport. Charger faked with
adb shell dumpsys battery unplug/set level N/set ac 1/set status 5, resetafterwards:
HiLightCore: alert … battery for 8000ms; full → second alert; sittingat 100% → no repeat; unplug and re-plug at 20% → third alert; session released after 8 s.
dumpsys lightsduring the gauge at 62% and 50%: the runcounts up one LED at a time, every second LED at 25%, the boundary LED at its share
(
0xd2f500= 96% at 62%), the tip blinking three times, then the gap and a fresh count.One thing worth knowing for anyone testing renderer changes: reinstalling the APK does not
restart the Shizuku user service, which keeps running the old dex. Kill it
(
pkill -f 'com.hilight.(core.AdbHelper|studio:hilight)') and reopen the app first.Notes for review
docs/i18n/ja-glossary.md, nor do they carry the per-entry English source comments theJA files use. Happy to adjust, or for a native review.
charging_*instrings_rules.xml; README and CHANGELOGhave a short entry each.
easier to review.