Connectivity: a live websocket parks the HTTP poll loop, and the poll loop was the only place that re-probed LAN. So once connected over ngrok the app never noticed the home network coming back unless the laptop's advertised LAN IPs happened to change. Add maybePreferLan(): while streaming over the tunnel, probe the paired LAN addresses on a background thread every ~15s and, when one answers, drop the tunnel so the resumed poll reconnects directly over LAN. Note this only works if the laptop is actually reachable on the LAN — the server must bind a non-loopback address (host 0.0.0.0) with ngrok still enabled. Document that in operations.md along with an `adb logcat -s airc:I` troubleshooting recipe; the new prefer-lan / endpoint-switch log lines make the LAN-vs-tunnel decision visible. Also theme showPairDialog() to match the rest of the chrome (header TextView, fields reusing the input-row styling, roundedStroke window background, themed buttons) instead of the stock AlertDialog look, and update the theming doc which had flagged it as the last unstyled dialog.
5.4 KiB
Android Theming
The Android app has its own neon-on-near-black look that is not shared with
the browser app (public/app.css is a separate, dimmer palette). Everything
visual lives in one file:
android-app/app/src/main/java/dev/airc/tmuxremote/MainActivity.kt
There is no XML layout and no per-widget styles file — the UI is built in code
in buildUi(), and colors/shapes come from a small set of helpers. When adding
a new control, reuse those helpers instead of setting raw colors so the new
piece matches automatically.
Where the colors live
The palette is declared in three places that must stay in sync:
MainActivity.Chrome— theobjectnear the top of the file. Native Kotlin colors (ARGB ints) for every chrome surface, button, dot, and border. This is the source of truth for the native UI (top bar, buttons, dialogs, input row).terminalHtml()— the embedded WebView's CSS:rootblock. Mirrors the same hex values for the terminal render area (--bg,--surface,--primary,--accent,--muted,--amber,--danger, plus thefg-*/bg-*ANSI palette). Change a brand color here too or the terminal will drift from the chrome around it.res/values/styles.xml—AppThemesetsmonospace, the dark status/nav bar colors, andwindowLightStatusBar=false.applySystemBarColors()also re-applies the bar tints at runtime for older devices.
Palette (Chrome)
| Token | Hex | Use |
|---|---|---|
bg |
#070B0A |
App background, WebView, recessed button fills |
surface |
#0A100E |
Top/bottom bars, dialog & popup backgrounds |
primary |
#9EF56C |
Brand green: primary/active fills, live status |
primaryDim |
#6CC458 |
Inactive pane text, input hint |
accent |
#16FFFF |
Cyan: enter key, icon button, dialog OK, section labels |
accent2 |
#FF6EC7 |
Magenta (ANSI palette only so far) |
muted |
#D5D0AC |
Body/input text |
amber |
#EF9F27 |
Connecting / reconnecting status |
danger |
#E24B4A |
Offline status, ANSI red |
primaryText |
#04240F |
Dark text on a primary fill |
borderAlpha |
#4D9EF56C |
Default 30%-green stroke |
dimBorder |
#666CC458 |
Inactive stroke |
wash |
0x1F9EF56C |
Pressed-state translucent green fill |
offlineFill |
#140909 |
Hollow status dot center |
radiusDp |
6 |
Corner radius for every rounded shape |
Building blocks
Use these instead of hand-rolling drawables:
chromeButton(label, kind) { action }— the only button factory. Mono font, no all-caps, no elevation, press-scale animation, and aButtonKindthat picks colors. Returns aButtonyou can still tweak (gravity, padding).ButtonKind— the styling enum, resolved inapplyButtonKind():Primary— green fill, dark text (the send button).Enter— cyan outline on bg (the enter key).PaneActive— green fill, dark text (selected pane / top-bar pane button).PaneInactive— dim outline on bg (unselected pane rows).IconAccent— borderless cyan glyph (the ⚙ settings button).Key— green outline on bg (quick keys:A-,A+,^,v). Each kind also sets a matchingsetShadowLayerglow.
roundedStroke(fill, stroke, radiusDp)— a rounded rectangleGradientDrawable. Used for inputs, popup/dialog backgrounds, and as the base of button states. This is also how dialogs get their themed window background:window?.setBackgroundDrawable(roundedStroke(Chrome.surface, Chrome.borderAlpha, Chrome.radiusDp)).stateBackground(fill, stroke, pressedFill)— aStateListDrawablethat swaps fill on press.chromeButtonuses it under the hood.dotDrawable(color, filled, glow)— the status indicator dot (filled + halo when live, hollow when offline).dp(value)— density helper. All sizing is indp(...), never raw px.
Themed dialogs and popups
Stock AlertDialog/PopupWindow chrome (titles, list items, Material buttons)
does not match. The pattern used by showStatusDetail(),
showSettingsMenu(), showPaneDialog(), and showPairDialog() is:
- Build the content as a
LinearLayout(headerTextViewinaccent, thenchromeButtonrows or muted text). - For a dialog,
create()it with.setView(...)and no title/items, then insetOnShowListenerset the window background to aroundedStrokeand theme any default buttons (mono font +accenttext). - For a popup, set the panel background to
roundedStrokeand a transparentPopupWindowbackground.
showPairDialog() keeps the three default AlertDialog buttons (Save / Scan
QR / Cancel) and themes them in setOnShowListener; its two EditTexts reuse
the input-row field styling (roundedStroke background, muted text,
primaryDim hint).
Checklist for adding a new control
- Color comes from a
Chrome.*token — add a token if a genuinely new color is needed (and mirror it intoterminalHtml()if it's a brand color). - Buttons go through
chromeButtonwith an existingButtonKind; add a kind (and a branch inapplyButtonKind) only for a genuinely new role. - Shapes use
roundedStroke/stateBackgroundandChrome.radiusDp. - Sizes/margins/padding use
dp(...). - Text uses
monoTypeface,includeFontPadding = false. - New dialogs/popups follow the themed-dialog pattern above rather than stock
setTitle/setItems.