mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
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:
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),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user