commit 613e9f28a6a47f99b7d677ab46b188f640aa49ff
parent 4999ca451de2ad03236b3c087e0b2ec47cc26a50
Author: Jacob Thomas <41988041+bocajthomas@users.noreply.github.com>
Date: Tue, 14 May 2024 21:32:31 +0100
feat(theme_picker): material you (#1021)
Diffstat:
3 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json
@@ -396,6 +396,10 @@
"name": "Background Surface Color",
"description": "Changes Snapchats background surface color"
},
+ "friend_feed_conversations_line_color": {
+ "name": "Conversations Line Color",
+ "description": "Changes the line divider color that splits Conversations on the friend feed "
+ },
"action_menu_background_color": {
"name": "Action Menu Background Color",
"description": "Changes Snapchats chat action menu background color"
@@ -1055,6 +1059,7 @@
"theme_picker": {
"amoled_dark_mode": "AMOLED Dark Mode",
"custom": "Custom Colors",
+ "material_you": "Material You (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
@@ -27,6 +27,7 @@ class UserInterfaceTweaks : ConfigContainer() {
val snapWithoutSoundTextColor = color("snap_without_sound_text_color")
val backgroundColor = color("background_color")
val backgroundColorSurface = color("background_color_surface")
+ val friendFeedConversationsLineColor = color("friend_feed_conversations_line_color")
val actionMenuBackgroundColor = color("action_menu_background_color")
val actionMenuRoundBackgroundColor = color("action_menu_round_background_color")
val cameraGridLines = color("camera_grid_lines")
@@ -36,6 +37,7 @@ class UserInterfaceTweaks : ConfigContainer() {
val themePicker = unique("theme_picker",
"custom",
"amoled_dark_mode",
+ "material_you",
"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
@@ -2,7 +2,10 @@ package me.rhunk.snapenhance.core.features.impl.ui
import android.content.res.TypedArray
import android.graphics.drawable.ColorDrawable
+import android.os.Build
import android.util.TypedValue
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.ui.graphics.toArgb
import me.rhunk.snapenhance.core.features.Feature
import me.rhunk.snapenhance.core.features.FeatureLoadParams
import me.rhunk.snapenhance.core.util.hook.HookStage
@@ -29,6 +32,7 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
"sigColorChatSnapWithSound" to colorsConfig.snapWithSoundTextColor.getNullable(),
"sigColorChatSnapWithoutSound" to colorsConfig.snapWithoutSoundTextColor.getNullable(),
"sigColorBackgroundMain" to colorsConfig.backgroundColor.getNullable(),
+ "listDivider" to colorsConfig.friendFeedConversationsLineColor.getNullable(),
"sigColorBackgroundSurface" to colorsConfig.backgroundColorSurface.getNullable(),
"actionSheetBackgroundDrawable" to colorsConfig.actionMenuBackgroundColor.getNullable(),
"actionSheetRoundedBackgroundDrawable" to colorsConfig.actionMenuRoundBackgroundColor.getNullable(),
@@ -37,6 +41,28 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
}.filterValues { it != null }.map { (key, value) ->
getAttribute(key) to value!!
}.toMap()
+ }
+ if (themePicker == "material_you") {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ val colorScheme = dynamicDarkColorScheme(context.androidContext)
+ themes.clear()
+ 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()
+ }
}
context.androidContext.theme.javaClass.getMethod("obtainStyledAttributes", IntArray::class.java).hook(
@@ -73,6 +99,7 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
"sigColorTextPrimary" to 0xFFFFFFFF,
"sigColorBackgroundMain" to 0xFF000000,
"sigColorBackgroundSurface" to 0xFF000000,
+ "listDivider" to 0xFF000000,
"actionSheetBackgroundDrawable" to 0xFF000000,
"actionSheetRoundedBackgroundDrawable" to 0xFF000000
),
@@ -80,8 +107,12 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
"sigColorTextPrimary" to 0xFF03BAFC,
"sigColorBackgroundMain" to 0xFFBDE6FF,
"sigColorBackgroundSurface" to 0xFF78DBFF,
+ "listDivider" to 0xFFBDE6FF,
"actionSheetBackgroundDrawable" to 0xFF78DBFF,
"sigColorChatChat" to 0xFF08D6FF,
+ "sigColorChatPendingSending" to 0xFF08D6FF,
+ "sigColorChatSnapWithSound" to 0xFF08D6FF,
+ "sigColorChatSnapWithoutSound" to 0xFF08D6FF,
"sigExceptionColorCameraGridLines" to 0xFF08D6FF
),
"dark_blue" to mapOf(
@@ -90,6 +121,9 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
"sigColorBackgroundSurface" to 0xFF192744,
"actionSheetBackgroundDrawable" to 0xFF192744,
"sigColorChatChat" to 0xFF98C2FD,
+ "sigColorChatPendingSending" to 0xFF98C2FD,
+ "sigColorChatSnapWithSound" to 0xFF98C2FD,
+ "sigColorChatSnapWithoutSound" to 0xFF98C2FD,
"sigExceptionColorCameraGridLines" to 0xFF192744
),
"earthy_autumn" to mapOf(
@@ -98,6 +132,9 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
"sigColorBackgroundSurface" to 0xFF800000,
"actionSheetBackgroundDrawable" to 0xFF800000,
"sigColorChatChat" to 0xFFF7CAC9,
+ "sigColorChatPendingSending" to 0xFFF7CAC9,
+ "sigColorChatSnapWithSound" to 0xFFF7CAC9,
+ "sigColorChatSnapWithoutSound" to 0xFFF7CAC9,
"sigExceptionColorCameraGridLines" to 0xFF800000
),
"mint_chocolate" to mapOf(