diff --git a/app/src/main/java/com/geode/launcher/MainActivity.kt b/app/src/main/java/com/geode/launcher/MainActivity.kt index 248bb617..6f00fdae 100644 --- a/app/src/main/java/com/geode/launcher/MainActivity.kt +++ b/app/src/main/java/com/geode/launcher/MainActivity.kt @@ -54,8 +54,10 @@ class MainActivity : ComponentActivity() { val themeOption by PreferenceUtils.useIntPreference(PreferenceUtils.Key.THEME) val theme = Theme.fromInt(themeOption) + val backgroundOption by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.BLACK_BACKGROUND) + CompositionLocalProvider(LocalTheme provides theme) { - GeodeLauncherTheme(theme = theme) { + GeodeLauncherTheme(theme = theme, blackBackground = backgroundOption) { Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background diff --git a/app/src/main/java/com/geode/launcher/SettingsActivity.kt b/app/src/main/java/com/geode/launcher/SettingsActivity.kt index 2979d06f..7db769b6 100644 --- a/app/src/main/java/com/geode/launcher/SettingsActivity.kt +++ b/app/src/main/java/com/geode/launcher/SettingsActivity.kt @@ -58,8 +58,10 @@ class SettingsActivity : ComponentActivity() { val themeOption by PreferenceUtils.useIntPreference(PreferenceUtils.Key.THEME) val theme = Theme.fromInt(themeOption) + val backgroundOption by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.BLACK_BACKGROUND) + CompositionLocalProvider(LocalTheme provides theme) { - GeodeLauncherTheme(theme = theme) { + GeodeLauncherTheme(theme = theme, blackBackground = backgroundOption) { Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background @@ -265,6 +267,10 @@ fun SettingsScreen( toLabel = { themeToKey(it) }, extraSelectBehavior = { updateTheme(context, it) } ) + SettingsCard( + title = stringResource(R.string.preference_black_background_name), + preferenceKey = PreferenceUtils.Key.BLACK_BACKGROUND + ) SettingsCard( title = context.getString(R.string.preference_load_testing_name), preferenceKey = PreferenceUtils.Key.LOAD_TESTING, diff --git a/app/src/main/java/com/geode/launcher/ui/theme/Theme.kt b/app/src/main/java/com/geode/launcher/ui/theme/Theme.kt index 1e1393c4..bf24a92b 100644 --- a/app/src/main/java/com/geode/launcher/ui/theme/Theme.kt +++ b/app/src/main/java/com/geode/launcher/ui/theme/Theme.kt @@ -60,16 +60,21 @@ fun GeodeLauncherTheme( theme: Theme = Theme.fromInt(0), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, + blackBackground: Boolean = false, content: @Composable () -> Unit ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current - when (theme) { - Theme.DARK -> dynamicDarkColorScheme(context) + when { + theme == Theme.DARK && blackBackground -> + dynamicDarkColorScheme(context).copy(surface = Color.Black, background = Color.Black) + theme == Theme.DARK -> dynamicDarkColorScheme(context) else -> dynamicLightColorScheme(context) } } + theme == Theme.DARK && blackBackground -> + DarkColorScheme.copy(surface = Color.Black, background = Color.Black) theme == Theme.DARK -> DarkColorScheme else -> LightColorScheme } diff --git a/app/src/main/java/com/geode/launcher/utils/PreferenceUtils.kt b/app/src/main/java/com/geode/launcher/utils/PreferenceUtils.kt index e39d6366..12e31c53 100644 --- a/app/src/main/java/com/geode/launcher/utils/PreferenceUtils.kt +++ b/app/src/main/java/com/geode/launcher/utils/PreferenceUtils.kt @@ -95,7 +95,8 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) { RELEASE_CHANNEL, CURRENT_VERSION_TAG, CURRENT_VERSION_TIMESTAMP, - THEME + THEME, + BLACK_BACKGROUND, } private fun defaultValueForBooleanKey(key: Key): Boolean { @@ -114,6 +115,7 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) { Key.CURRENT_VERSION_TAG -> "PreferenceCurrentVersionName" Key.CURRENT_VERSION_TIMESTAMP -> "PreferenceCurrentVersionDescriptor" Key.THEME -> "PreferenceTheme" + Key.BLACK_BACKGROUND -> "PreferenceBlackBackground" } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d1d95c1..4440c298 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -52,6 +52,7 @@ System default Light Dark + Black background in dark theme Updates Enable automatic updates