commit 718f2125ba86f8dfe3be192567722d813e5a4de0
parent a196092c2db713730477c2341a84eda2a68a7a42
Author: Jacob Thomas <41988041+bocajthomas@users.noreply.github.com>
Date: Tue, 21 May 2024 23:20:52 +0100
feat(theme_picker): material you light & dark (#1059)
Co-authored-by: rhunk <101876869+rhunk@users.noreply.github.com>
Diffstat:
3 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json
@@ -1061,7 +1061,8 @@
"theme_picker": {
"amoled_dark_mode": "AMOLED Dark Mode",
"custom": "Custom Colors",
- "material_you": "Material You (Android 12+)",
+ "material_you_light": "Material You Light (Android 12+)",
+ "material_you_dark": "Material You Dark (Android 12+)",
"light_blue": "Light Blue",
"dark_blue": "Dark Blue",
"earthy_autumn": "Earthy Autumn",
diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt
@@ -37,7 +37,8 @@ class UserInterfaceTweaks : ConfigContainer() {
val themePicker = unique("theme_picker",
"custom",
"amoled_dark_mode",
- "material_you",
+ "material_you_light",
+ "material_you_dark",
"light_blue",
"dark_blue",
"earthy_autumn",
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/CustomizeUI.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/CustomizeUI.kt
@@ -37,31 +37,31 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
"actionSheetBackgroundDrawable" to colorsConfig.actionMenuBackgroundColor.getNullable(),
"actionSheetRoundedBackgroundDrawable" to colorsConfig.actionMenuRoundBackgroundColor.getNullable(),
"sigExceptionColorCameraGridLines" to colorsConfig.cameraGridLines.getNullable(),
- ).apply {
- }.filterValues { it != null }.map { (key, value) ->
+ ).filterValues { it != null }.map { (key, value) ->
getAttribute(key) to value!!
}.toMap()
}
- if (themePicker == "material_you") {
+ if (themePicker == "material_you_light" || themePicker == "material_you_dark") {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val colorScheme = dynamicDarkColorScheme(context.androidContext)
+ val light = themePicker == "material_you_light"
themes.clear()
+ val surfaceVariant = (if (light) colorScheme.surfaceVariant else colorScheme.onSurfaceVariant).toArgb()
+ val background = (if (light) colorScheme.onBackground else colorScheme.background).toArgb()
+
themes[themePicker] = mapOf(
- "sigColorTextPrimary" to colorScheme.onSurfaceVariant.toArgb(),
- "sigColorChatChat" to colorScheme.onSurfaceVariant.toArgb(),
- "sigColorChatPendingSending" to colorScheme.onSurfaceVariant.toArgb(),
- "sigColorChatSnapWithSound" to colorScheme.onSurfaceVariant.toArgb(),
- "sigColorChatSnapWithoutSound" to colorScheme.onSurfaceVariant.toArgb(),
- "sigColorBackgroundMain" to colorScheme.background.toArgb(),
- "sigColorBackgroundSurface" to colorScheme.background.toArgb(),
- "listDivider" to colorScheme.primary.copy(alpha = 0.12f).toArgb(),
- "actionSheetBackgroundDrawable" to colorScheme.background.toArgb(),
- "actionSheetRoundedBackgroundDrawable" to colorScheme.background.toArgb(),
- "sigExceptionColorCameraGridLines" to colorScheme.background.toArgb(),
- ).apply {
- }.filterValues { true }.map { (key, value) ->
- getAttribute(key) to value
- }.toMap()
+ "sigColorTextPrimary" to surfaceVariant,
+ "sigColorChatChat" to surfaceVariant,
+ "sigColorChatPendingSending" to surfaceVariant,
+ "sigColorChatSnapWithSound" to surfaceVariant,
+ "sigColorChatSnapWithoutSound" to surfaceVariant,
+ "sigColorBackgroundMain" to background,
+ "sigColorBackgroundSurface" to background,
+ "listDivider" to colorScheme.onPrimary.copy(alpha = 0.12f).toArgb(),
+ "actionSheetBackgroundDrawable" to background,
+ "actionSheetRoundedBackgroundDrawable" to background,
+ "sigExceptionColorCameraGridLines" to background,
+ ).map { getAttribute(it.key) to it.value }.toMap()
}
}