Skip to content

Add tap-to-toggle Mbps / bytes-per-second display for live rates - #2

Open
NickLD wants to merge 6 commits into
Sir-MmD:mainfrom
NickLD:rate-unit-toggle-pr
Open

Add tap-to-toggle Mbps / bytes-per-second display for live rates#2
NickLD wants to merge 6 commits into
Sir-MmD:mainfrom
NickLD:rate-unit-toggle-pr

Conversation

@NickLD

@NickLD NickLD commented Aug 9, 2026

Copy link
Copy Markdown

What this adds

Tapping the unit label on the "Proxy Speed" card cycles the live upload/download rate display between the existing binary bytes/sec ladder (B/s, KB/s, MB/s, GB/s) and standard decimal Mbps (bps, Kbps, Mbps, Gbps) — the convention carriers, speed-test tools, and routers use for reporting speed. The choice persists across restarts and is reflected in both the in-app card and the persistent foreground notification, so the two never disagree.

Why

Comparing DataProxy's reported speed against a carrier's advertised rate, a speed-test app, or a router's throughput display currently means mentally converting bytes to bits. This makes that comparison direct.

Implementation

  • New RateUnit enum (BytesPerSecond / Mbps), modeled on the existing ThemeMode preference pattern.
  • Consolidated three separate, near-duplicate rate-formatting functions (one in SpeedometerCard, one in ProxyService, one already-unused in ByteFormatter) into a single ByteFormatter.rate(bps, unit). Mbps math is bytes→bits (×8) then walked on a decimal (÷1000) ladder — deliberately not the same ÷1024 base as the byte ladder, since that's how Mbps is conventionally reported.
  • The preference lives in the same SharedPreferences file as every other setting, in a key shared between MainViewModel (writes on tap) and ProxyService (reads live on every notification rebuild, same pattern already used for auth config) — so toggling while the proxy is running updates the notification within a second, no restart needed.
  • No new screen, no new dependency, no new nav tile — the unit label itself is the toggle, the same "tap to cycle" pattern already used for the theme button in the header.

Default is the existing byte-based display, so nothing changes for anyone who doesn't tap it.

Testing

This project has no automated test framework, so this was verified by building and manually walking through it on a real device: default state, tap-to-toggle (confirmed both the download and upload tiles switch together, since it's one shared preference, not two independent ones), notification match, persistence across a force-stop/relaunch, and toggling back.

Scope

Independent of my other open PR (the connection-concurrency fix) — this one touches entirely different files (UI/preferences vs. relay threading) and has no dependency on it either direction.

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.

1 participant