feat(theme): True black, a pure black theme with a highlight color you pick (#2541)

* feat(theme): AMOLED black, a theme with a pure black page and panels

* feat(theme): rename to True black and let the user pick its highlight color

* fix(theme): True black leaves the page unlit, with no art wash or corner glow
This commit is contained in:
DeathKhan authored and GitHub committed 2026-11-15 09:37:47 -05:00
1 parent 4759a01ef3
commit 253756d45f
7 files changed
+73 -1

No files matched your search

@@ -1376,6 +1376,13 @@ object SessionPrefs {
prefs(context).edit().putInt("gradientPrimary", primary).putInt("gradientSecondary", secondary).apply()
}
fun trueBlackHighlight(context: Context): Int =
prefs(context).getInt("trueBlackHighlight", com.droiddeck.launcher.ui.Themes.DEFAULT_HIGHLIGHT)
fun setTrueBlackHighlight(context: Context, highlight: Int) {
prefs(context).edit().putInt("trueBlackHighlight", highlight).apply()
}
private fun customResolution(context: Context, mode: String): Pair<Int, Int>? =
parseResolution(prefs(context).getString("customRes.$mode", null))
@@ -212,6 +212,8 @@ internal fun inPane(o: Origin): Origin =
private fun Backdrop(art: File?) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
// True black keeps the page unlit: no art wash and no corner glow.
if (pal.id == Themes.TRUE_BLACK) return
Crossfade(targetState = art, animationSpec = Motion.tw(700), label = "backdrop") { a ->
if (a != null && Build.VERSION.SDK_INT >= 31) {
Box(modifier = Modifier.fillMaxSize().alpha(0.26f).blur(70.dp)) {
@@ -436,6 +436,7 @@ internal fun SetupPanel(
}
if (s.theme == Themes.INNER_GAMER) RgbSpeedRow()
if (s.theme == Themes.GRADIENT) GradientColorRows()
if (s.theme == Themes.TRUE_BLACK) HighlightColorRow()
ChoiceRow(
host, "app-scale", stringResource(R.string.setup_app_scale), stringResource(R.string.setup_app_scale_hint),
com.droiddeck.launcher.core.AppUiPrefs.scales.map { percent ->
@@ -1177,6 +1178,16 @@ private fun RgbSpeedRow() {
SliderRow(stringResource(R.string.theme_rgb_speed), stringResource(R.string.theme_rgb_speed_hint), Themes.rgbSpeed, 1..Themes.RGB_SPEEDS) { Themes.setRgbSpeed(ctx, it) }
}
@Composable
private fun HighlightColorRow() {
val ctx = androidx.compose.ui.platform.LocalContext.current.applicationContext
val highlight = Themes.trueBlackHighlight
var picking by remember { mutableStateOf(false) }
val label = stringResource(R.string.theme_true_black_highlight)
SettingsRow(label, stringResource(R.string.theme_true_black_highlight_hint)) { ColorCube(androidx.compose.ui.graphics.Color(highlight), label) { picking = true } }
if (picking) ColorPickerDialog(label, highlight, onDismiss = { picking = false }) { argb -> Themes.setTrueBlackHighlight(ctx, argb) }
}
@Composable
private fun GradientColorRows() {
val ctx = androidx.compose.ui.platform.LocalContext.current.applicationContext
@@ -59,6 +59,11 @@ object Themes {
const val DEFAULT_RGB_SPEED = 3
const val RGB_HUE_STEP = 3f
const val WHITE_RED = "white_red"
const val TRUE_BLACK = "true_black"
const val DEFAULT_HIGHLIGHT = 0xFF1A9FFF.toInt()
var trueBlackHighlight by mutableStateOf(DEFAULT_HIGHLIGHT)
private set
var rgbSpeed by mutableStateOf(DEFAULT_RGB_SPEED)
private set
@@ -81,6 +86,12 @@ object Themes {
fun loadGradient(context: Context) {
gradientColors = SessionPrefs.gradientColors(context)
rgbSpeed = SessionPrefs.rgbSpeed(context)
trueBlackHighlight = SessionPrefs.trueBlackHighlight(context)
}
fun setTrueBlackHighlight(context: Context, highlight: Int) {
SessionPrefs.setTrueBlackHighlight(context, highlight)
trueBlackHighlight = highlight
}
fun innerGamer(hue: Float): Palette = ThemeColors.palette(
@@ -95,7 +106,7 @@ object Themes {
fun current(context: Context): Palette {
val id = SessionPrefs.theme(context)
if (id == GRADIENT || id == INNER_GAMER) loadGradient(context)
if (id == GRADIENT || id == INNER_GAMER || id == TRUE_BLACK) loadGradient(context)
return byId(id)
}
@@ -128,6 +139,7 @@ object Themes {
primary = Color(0xFF2E86FF), primary2 = Color(0xFF2684FF), onPrimary = Color(0xFF03111F), signal = Color(0xFF2E86FF),
good = Color(0xFF4CD37F),
),
ThemeColors.trueBlack(DEFAULT_HIGHLIGHT),
Palette(
WHITE_RED, R.string.theme_white_red, R.string.theme_white_red_detail,
background = Color(0xFFF8F8F8), surface = Color(0xFFFFFFFF), surfaceVariant = Color(0xFFF0F0F0), line = Color(0xFFDDDDDD), line2 = Color(0xFFC8C8C8),
@@ -141,6 +153,7 @@ object Themes {
fun byId(id: String): Palette {
if (id == INNER_GAMER) return innerGamer(rgbHue)
if (id == TRUE_BLACK) return ThemeColors.trueBlack(trueBlackHighlight)
if (id == GRADIENT) return ThemeColors.palette(gradientColors.first, gradientColors.second, R.string.theme_gradient, R.string.theme_gradient_detail)
return all.firstOrNull { it.id == id } ?: all[0]
}
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.ui
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.graphics.toArgb
import com.droiddeck.launcher.R
import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt
@@ -147,4 +148,18 @@ internal object ThemeColors {
good = Color(0xFF4CD37F),
)
}
// Page and panels are pure black so an OLED panel leaves those pixels off; only raised cards, rules and the highlight are lit.
fun trueBlack(highlight: Int): Palette {
val seen = readable(highlight)
val ink = inkFor(seen, seen)
val accent = Color(fitTo(ink, seen))
return Palette(
Themes.TRUE_BLACK, R.string.theme_true_black, R.string.theme_true_black_detail,
background = Color.Black, surface = Color.Black, surfaceVariant = Color(0xFF0C0C0D), line = Color(0xFF1C1D20), line2 = Color(0xFF2A2C30),
onBackground = Color(0xFFF2F4F7), onSurfaceVariant = Color(0xFF8E9196),
primary = accent, primary2 = accent, onPrimary = ink, signal = accent,
good = Color(0xFF4CD37F),
)
}
}
+4
View File
@@ -4079,6 +4079,10 @@
<string name="input_layout_import_failed">Could not import this layout</string>
<string name="epic_third_party_managed">Installs through %1$s</string>
<string name="theme_true_black">True black</string>
<string name="theme_true_black_detail">Pure black page and panels, so an OLED screen switches those pixels off. You pick the highlight color.</string>
<string name="theme_true_black_highlight">Highlight</string>
<string name="theme_true_black_highlight_hint">The color of everything selected.</string>
<string name="theme_white_red">Scarlet Snow</string>
<string name="theme_white_red_detail">White surfaces with red accents.</string>
<string name="rail_soundtracks">Soundtracks</string>
@@ -168,4 +168,24 @@ class ThemeColorsTest {
Themes.setRgbSpeed(app, 1)
assertTrue(Themes.rgbCycleMillis(1) > Themes.rgbCycleMillis(10))
}
@Test fun trueBlackKeepsThePageAndPanelsBlackWhateverTheHighlight() {
for (highlight in listOf(0xFF1A9FFF, 0xFFFF0000, 0xFF00FF66, 0xFFFFFFFF, 0xFF000000, 0xFF00008B, 0xFFFFE600)) {
val p = ThemeColors.trueBlack(highlight.toInt())
assertEquals(Color.Black, p.background)
assertEquals(Color.Black, p.surface)
assertTrue("button text on $highlight", contrast(p.onPrimary, p.primary) >= 4.5f)
assertTrue("highlight $highlight shows on black", contrast(p.primary, Color.Black) >= 3f)
}
}
@Test fun trueBlackFollowsTheSavedHighlightAndComesBackAfterARestart() {
assertEquals(Themes.TRUE_BLACK, Themes.byId(Themes.TRUE_BLACK).id)
Themes.setTrueBlackHighlight(app, 0xFFFF8800.toInt())
assertEquals(Color(0xFFFF8800), Themes.byId(Themes.TRUE_BLACK).primary)
Themes.setTrueBlackHighlight(app, Themes.DEFAULT_HIGHLIGHT)
SessionPrefs.setTrueBlackHighlight(app, 0xFFFF8800.toInt())
SessionPrefs.setTheme(app, Themes.TRUE_BLACK)
assertEquals(Color(0xFFFF8800), Themes.current(app).primary)
}
}