Files
JRAlmonte 1a7a116939 feat(ui): add frosted launcher wallpaper and cards (#3559)
Add opt-in frosted wallpaper and cards with separate transparency settings. Keep dialogs solid and fall back to the standard palette when blur or readable contrast is unavailable.
2026-12-02 15:48:36 -05:00

6.0 KiB
Raw Permalink Blame History

Themes

A theme is a Palette (ui/Theme.kt): a dark background scale (background, surface, surfaceVariant, line, line2), two text colours, and the accent: primary / signal (flat accent, also Material's primary), primary2 (the darker or second accent) and onPrimary. PrimaryButton and the launch flood already draw a gradient from primary to primary2. The choice is stored as an id (SessionPrefs.theme) and picked in Setup › Launcher.

Gradient theme

Themes.GRADIENT is the one of the theme whose colours the person picks: a primary and a secondary, kept in SessionPrefs.gradientColors and in Themes.gradientColors, a Compose state, so a change restyles the whole app at once. App.onCreate loads the saved colours; code outside a composition uses Themes.current(context).

ThemeColors.palette builds the full palette from the two colours: primary becomes primary / signal, secondary becomes primary2, the background scale is a dark neutral tinted with the primary's hue (plain grey for a grey primary), and onPrimary is dark or white by the luminance of the pair. A colour too dark to show on the dark background is lifted (ThemeColors.readable) rather than refused.

Setup shows Primary and Secondary under the theme when Gradient is chosen, each a small colour square. It opens ColorPickerDialog: a wheel (hue and saturation, touch), hue / saturation / brightness sliders (they work with a controller) and a hex box, with the old and new colour side by side. OK applies it.

Custom theme

Themes.CUSTOM stores a separate preference for every configurable palette colour: background, surfaces, borders, text, accent, button text, signals, success and error. SessionPrefs.customThemeColors restores the saved values, while Themes.customColors is Compose state so changes update the interface immediately.

The custom palette does not derive its surfaces from the accent. primary2 intentionally equals primary, keeping components that use the existing two-stop button and launch effects visually solid. The colour picker reused from Gradient supports the wheel, sliders and hexadecimal input.

Inner Gamer theme

Themes.INNER_GAMER is an RGB theme: the accent walks round the colour wheel. It sits just above Gradient in the list, and Setup shows a Speed slider (1 to 10, SessionPrefs.rgbSpeed) under the theme while it is chosen.

Themes.innerGamer(hue) builds the palette for one hue through ThemeColors.palette, so button text keeps the same contrast along the gradient at every hue. DroidDeckTheme runs one rememberInfiniteTransition while Inner Gamer is chosen, so the system's animation clock drives it. Compose applies Android's animator scale to it, and the colour holds still when animations are off in the app (Motion.scale) or in Android's own settings. The hue is written to Themes.rgbHue in 3° steps, which restyles the app only when the colour visibly moves; a slow cycle costs few recompositions.

Frosted background

Setup › Launcher › Frosted (SessionPrefs.launcherFrost, off by default) is the master switch. Under it, while it is on, sit Frosted wallpaper and Frosted cards (frostWallpaper, frostCards, both on by default, so the first time Frosted is turned on both apply at their defaults), each with its own transparency from 0 to 100 % in steps of 10 (frostTransparency from 80 %, frostCardTransparency from 50 %). Frosted cards is greyed out while Frosted wallpaper is off, since a card can only show the wallpaper the page behind it shows; each slider stays in place and is greyed out while it has nothing to set.

Frosted wallpaper shows the device's wallpaper, blurred, behind the launcher. Android draws it: the launcher's window is see-through and carries FLAG_SHOW_WALLPAPER and FLAG_BLUR_BEHIND, so the app never reads the wallpaper and needs no permission (ui/LauncherFrost.kt). It works with any theme except True black, which keeps the page unlit.

Over the wallpaper sits one veil of the theme's background (frostLook). 0 % is nearly solid and 100 % shows the most wallpaper. While the frost shows, the theme moves onSurfaceVariant toward onBackground (Palette.frosted): halfway up to 50 %, and further above it, all the way at 100 %. The veil grows past the chosen transparency only as far as that hint text needs to keep 4.5:1, on the page and on a card (the rail and the bottom bar are cards here), as far as the theme's own colours allow: a Custom theme whose hint text matches its background stays unreadable with or without the frost. Android reports only a wallpaper's main colours, and any part of it can sit behind text, so the check takes the worst wallpaper there is: white under a dark theme and black under the light one. The veil is then about 0.7 at 50 %, 0.63 at 80 % and 0.6 at 100 % on a dark theme, and 0.7, 0.57 and 0.52 on the light one. The wallpaper slider starts at 80 % so the wallpaper shows about as much as the game page's glass (0.58) does.

LocalFrost carries the veil and the launcher's root steps aside. With Frosted cards on, the theme hands out surface and surfaceVariant see-through by the card transparency (0.6 on a dark theme and 0.74 on the light one at 50 %, solid at 0 %), and dialogs, popups, menus and settings steps take the solid palette back (SolidSurfaces), so no page text shows through them. The rail and the bottom bar draw surface, so they follow the cards: see-through with them and solid without.

The rows show on Android 12 and later when the system can blur behind windows, and also while Battery Saver pauses the blur, when the page shows the plain background until the blur returns. A window is see-through or not from its first frame, so the launcher prepares its window whenever the wallpaper frost is on at start, whether or not the blur is available then. Turning the wallpaper frost on restarts the launcher once only if the window was not prepared at start; otherwise turning it off and on, and the blur pausing and coming back, switch between the frost and the plain background at once.