diff --git a/i18n/src/main/res/values-cs/strings.xml b/i18n/src/main/res/values-cs/strings.xml index 30ae9364..77d41f7d 100644 --- a/i18n/src/main/res/values-cs/strings.xml +++ b/i18n/src/main/res/values-cs/strings.xml @@ -37,7 +37,6 @@ Vlhkost: %1$s Nejsou nainstalovány žádné balíčky ikon Nastavit polohu - Tmavé ikony na stavové liště Tento widget vyžaduje přístup ke kalendáři Momentálně nejste přihlášeni Není podporováno na tomto zařízení @@ -310,7 +309,6 @@ Barevné ikony s barevným schématem aplikace Balíček ikon Systémové lišty - Tmavé ikony na navigační liště Skrýt stavovou lištu Skrýt navigační lištu Spravovat připojené účty a služby diff --git a/i18n/src/main/res/values-de/strings.xml b/i18n/src/main/res/values-de/strings.xml index ed214245..5c3bc99e 100644 --- a/i18n/src/main/res/values-de/strings.xml +++ b/i18n/src/main/res/values-de/strings.xml @@ -110,8 +110,6 @@ Widget hinzufügen Weitere Systemleisten - Dunkle Statusleisten-Symbole - Dunkle Navigationsleisten-Symbole Statusleiste ausblenden Navigationsleiste ausblenden Musik diff --git a/i18n/src/main/res/values-fr/strings.xml b/i18n/src/main/res/values-fr/strings.xml index 9689eff6..bb94064f 100644 --- a/i18n/src/main/res/values-fr/strings.xml +++ b/i18n/src/main/res/values-fr/strings.xml @@ -145,8 +145,6 @@ Ajouter un widget Plus Barres du système - Icônes de la barre d\'état sombres - Icônes de la barre de navigation sombres Musique Ouvrir dans l\'application de contacts Ajouter aux favoris diff --git a/i18n/src/main/res/values-it/strings.xml b/i18n/src/main/res/values-it/strings.xml index 3119dd44..08204073 100644 --- a/i18n/src/main/res/values-it/strings.xml +++ b/i18n/src/main/res/values-it/strings.xml @@ -30,7 +30,6 @@ Maggiori informazioni sulla build di questa app Icone colorate con la combinazione di colori dell\'applicazione Mostra automaticamente la tastiera all\'apertura della ricerca - Icone scure nella barra di navigazione Connetti account Nascondi barra di stato Non hai eseguito l\'accesso @@ -259,7 +258,6 @@ Icone a tema Nessun pacchetto icone installato Pacchetto icone - Icone scure nella barra di stato Barre di sistema Triangolo di Reuleaux Nascondi barra di navigazione diff --git a/i18n/src/main/res/values-nl/strings.xml b/i18n/src/main/res/values-nl/strings.xml index 4e1949f0..1467cb2e 100644 --- a/i18n/src/main/res/values-nl/strings.xml +++ b/i18n/src/main/res/values-nl/strings.xml @@ -297,8 +297,6 @@ Forceer iconen met een thema Pictogrammenpakket Systeembalken - Donkere statusbalkpictogrammen - Donkere navigatiebalkpictogrammen Statusbalk verbergen Je bent niet ingelogd Vijfhoek diff --git a/i18n/src/main/res/values-pt-rBR/strings.xml b/i18n/src/main/res/values-pt-rBR/strings.xml index ee5c53ca..d1fa358b 100644 --- a/i18n/src/main/res/values-pt-rBR/strings.xml +++ b/i18n/src/main/res/values-pt-rBR/strings.xml @@ -276,8 +276,6 @@ Pacote de ícones Não há pacotes de ícones instalados Barras do sistema - Ícones da barra de status escuro - Ícones da barra de navegação escuro Ocultar a barra de status Ocultar a barra de navegação Gerenciar as contas e serviços conectados diff --git a/i18n/src/main/res/values-ro/strings.xml b/i18n/src/main/res/values-ro/strings.xml index 6a30a8d4..d177a64b 100644 --- a/i18n/src/main/res/values-ro/strings.xml +++ b/i18n/src/main/res/values-ro/strings.xml @@ -247,8 +247,6 @@ Pachet de pictograme Nu sunt instalate pachete de pictograme Bare de sistem - Pictogramele barei de stare întunecate - Pictograme întunecate ale barei de navigare Ascunde bara de stare Ascunde bara de navigare Google diff --git a/i18n/src/main/res/values-ru/strings.xml b/i18n/src/main/res/values-ru/strings.xml index b6ba4825..928f8009 100644 --- a/i18n/src/main/res/values-ru/strings.xml +++ b/i18n/src/main/res/values-ru/strings.xml @@ -284,8 +284,6 @@ Поиск локальных файлов и облачных файлов Показать ярлыки различных поисковых систем Google - Темные значки в строке состояния - Темные значки в панели навигации Скрыть строку состояния Скрыть панель навигации Обои diff --git a/i18n/src/main/res/values-sv/strings.xml b/i18n/src/main/res/values-sv/strings.xml index f2fcfb3f..15d0ac28 100644 --- a/i18n/src/main/res/values-sv/strings.xml +++ b/i18n/src/main/res/values-sv/strings.xml @@ -230,8 +230,6 @@ Ikonpaket Inga ikonpaket installerade Systemfält - Mörka statusfältikoner - Mörka navigationsfältikoner Göm statusfält Göm navigationsfält Hantera anslutna konton och tjänster diff --git a/i18n/src/main/res/values-zh-rCN/strings.xml b/i18n/src/main/res/values-zh-rCN/strings.xml index 0ecff296..abd05f33 100644 --- a/i18n/src/main/res/values-zh-rCN/strings.xml +++ b/i18n/src/main/res/values-zh-rCN/strings.xml @@ -1,6 +1,5 @@ - 深色的导航条图标 在深色主题中,使壁纸变暗 配置图标角标 登陆以查找OneDrive @@ -252,7 +251,6 @@ 图标包 没有已安装的图标包 系统栏 - 深色的状态栏图标 隐藏状态栏 隐藏导航条 管理已连接的账户和服务 diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 3a56be27..1e46bab6 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -482,8 +482,11 @@ Icon pack No icon packs installed System bars - Dark status bar icons - Dark navigation bar icons + Status bar icons + Navigation bar icons + Auto + Light + Dark Hide status bar Hide navigation bar Manage connected accounts and services diff --git a/preferences/src/main/java/de/mm20/launcher2/preferences/Defaults.kt b/preferences/src/main/java/de/mm20/launcher2/preferences/Defaults.kt index 70bc3034..d34af3be 100644 --- a/preferences/src/main/java/de/mm20/launcher2/preferences/Defaults.kt +++ b/preferences/src/main/java/de/mm20/launcher2/preferences/Defaults.kt @@ -144,8 +144,8 @@ fun createFactorySettings(context: Context): Settings { .setEasterEgg(false) .setSystemBars( Settings.SystemBarsSettings.newBuilder() - .setLightNavBar(false) - .setLightStatusBar(false) + .setNavBarColor(Settings.SystemBarsSettings.SystemBarColors.Light) + .setStatusBarColor(Settings.SystemBarsSettings.SystemBarColors.Light) .setHideStatusBar(false) .setHideNavBar(false) ) diff --git a/preferences/src/main/proto/settings.proto b/preferences/src/main/proto/settings.proto index 19307519..7fb3f48c 100644 --- a/preferences/src/main/proto/settings.proto +++ b/preferences/src/main/proto/settings.proto @@ -238,8 +238,16 @@ message Settings { bool easter_egg = 22; message SystemBarsSettings { - bool lightStatusBar = 1; - bool lightNavBar = 2; + enum SystemBarColors { + // Light icons + Auto = 0; + // Dark icons + Dark = 1; + // Wallpaper based + Light = 2; + } + SystemBarColors statusBarColor = 1; + SystemBarColors navBarColor = 2; bool hideStatusBar = 3; bool hideNavBar = 4; } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherActivityVM.kt b/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherActivityVM.kt index e361e605..181c8ca4 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherActivityVM.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherActivityVM.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.asLiveData import de.mm20.launcher2.preferences.LauncherDataStore +import de.mm20.launcher2.preferences.Settings.SystemBarsSettings import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map @@ -23,19 +24,8 @@ class LauncherActivityVM : ViewModel(), KoinComponent { } val dimBackground = dimBackgroundState.asLiveData() - val lightStatusBar = combine( - dimBackgroundState, - dataStore.data.map { it.systemBars.lightStatusBar } - ) { dim, light -> - !dim && light - }.asLiveData() - - val lightNavBar = combine( - dimBackgroundState, - dataStore.data.map { it.systemBars.lightNavBar } - ) { dim, light -> - !dim && light - }.asLiveData() + val statusBarColor = dataStore.data.map { it.systemBars.statusBarColor }.asLiveData() + val navBarColor = dataStore.data.map { it.systemBars.statusBarColor }.asLiveData() val hideNavBar = dataStore.data.map { it.systemBars.hideNavBar }.asLiveData() val hideStatusBar = dataStore.data.map { it.systemBars.hideStatusBar }.asLiveData() diff --git a/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt b/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt index 2e39111a..3b84df96 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt @@ -35,6 +35,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.flowWithLifecycle import com.google.accompanist.systemuicontroller.rememberSystemUiController import de.mm20.launcher2.preferences.Settings +import de.mm20.launcher2.preferences.Settings.SystemBarsSettings.SystemBarColors import de.mm20.launcher2.ui.assistant.AssistantScaffold import de.mm20.launcher2.ui.base.BaseActivity import de.mm20.launcher2.ui.base.ProvideCurrentTime @@ -44,9 +45,12 @@ import de.mm20.launcher2.ui.ktx.animateTo import de.mm20.launcher2.ui.launcher.transitions.HomeTransition import de.mm20.launcher2.ui.launcher.transitions.HomeTransitionManager import de.mm20.launcher2.ui.launcher.transitions.LocalHomeTransitionManager +import de.mm20.launcher2.ui.locals.LocalPreferDarkContentOverWallpaper import de.mm20.launcher2.ui.locals.LocalSnackbarHostState +import de.mm20.launcher2.ui.locals.LocalWallpaperColors import de.mm20.launcher2.ui.locals.LocalWindowSize import de.mm20.launcher2.ui.theme.LauncherTheme +import de.mm20.launcher2.ui.theme.wallpaperColorsAsState import kotlin.math.pow @@ -73,19 +77,26 @@ abstract class SharedLauncherActivity( setContent { val snackbarHostState = remember { SnackbarHostState() } + val wallpaperColors by wallpaperColorsAsState() + val dimBackground by viewModel.dimBackground.observeAsState(false) CompositionLocalProvider( LocalHomeTransitionManager provides homeTransitionManager, LocalWindowSize provides windowSize, - LocalSnackbarHostState provides snackbarHostState + LocalSnackbarHostState provides snackbarHostState, + LocalWallpaperColors provides wallpaperColors, + LocalPreferDarkContentOverWallpaper provides (!dimBackground && wallpaperColors.supportsDarkText), ) { LauncherTheme { ProvideCurrentTime { ProvideSettings { - val lightStatus by viewModel.lightStatusBar.observeAsState(false) - val lightNav by viewModel.lightNavBar.observeAsState(false) + val statusBarColor by viewModel.statusBarColor.observeAsState(SystemBarColors.Auto) + val navBarColor by viewModel.navBarColor.observeAsState(SystemBarColors.Auto) + + val lightStatus = !dimBackground && (statusBarColor == SystemBarColors.Dark || statusBarColor == SystemBarColors.Auto && wallpaperColors.supportsDarkText) + val lightNav = !dimBackground && (navBarColor == SystemBarColors.Dark || navBarColor == SystemBarColors.Auto && wallpaperColors.supportsDarkText) + val hideStatus by viewModel.hideStatusBar.observeAsState(false) val hideNav by viewModel.hideNavBar.observeAsState(false) - val dimBackground by viewModel.dimBackground.observeAsState(false) val layout by viewModel.layout.observeAsState(null) val systemUiController = rememberSystemUiController() diff --git a/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt b/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt index cae89e97..14c5311c 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt @@ -4,10 +4,10 @@ import android.appwidget.AppWidgetHost import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.compositionLocalOf import androidx.compose.ui.geometry.Size -import androidx.compose.ui.unit.dp import androidx.navigation.NavController import de.mm20.launcher2.preferences.Settings import de.mm20.launcher2.preferences.Settings.GridSettings +import de.mm20.launcher2.ui.theme.WallpaperColors val LocalWindowSize = compositionLocalOf { Size(0f, 0f) } @@ -29,4 +29,8 @@ val LocalDarkTheme = compositionLocalOf { false } * Workaround a bug in Jetpack Compose which incorrectly places popups * that are nested inside other popups. */ -val LocalWindowPosition = compositionLocalOf { 0f } \ No newline at end of file +val LocalWindowPosition = compositionLocalOf { 0f } + +val LocalWallpaperColors = compositionLocalOf { WallpaperColors() } + +val LocalPreferDarkContentOverWallpaper = compositionLocalOf { false } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/settings/SettingsActivity.kt b/ui/src/main/java/de/mm20/launcher2/ui/settings/SettingsActivity.kt index 1a100a54..9d52a703 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/settings/SettingsActivity.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/settings/SettingsActivity.kt @@ -20,6 +20,7 @@ import de.mm20.launcher2.ui.theme.LauncherTheme import de.mm20.launcher2.ui.base.BaseActivity import de.mm20.launcher2.ui.locals.LocalCardStyle import de.mm20.launcher2.ui.locals.LocalNavController +import de.mm20.launcher2.ui.locals.LocalWallpaperColors import de.mm20.launcher2.ui.settings.about.AboutSettingsScreen import de.mm20.launcher2.ui.settings.accounts.AccountsSettingsScreen import de.mm20.launcher2.ui.settings.appearance.AppearanceSettingsScreen @@ -47,6 +48,7 @@ import de.mm20.launcher2.ui.settings.weatherwidget.WeatherWidgetSettingsScreen import de.mm20.launcher2.ui.settings.websearch.WebSearchSettingsScreen import de.mm20.launcher2.ui.settings.widgets.WidgetsSettingsScreen import de.mm20.launcher2.ui.settings.wikipedia.WikipediaSettingsScreen +import de.mm20.launcher2.ui.theme.wallpaperColorsAsState import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map import org.koin.android.ext.android.inject @@ -72,9 +74,11 @@ class SettingsActivity : BaseActivity() { }.collectAsState( Settings.CardSettings.getDefaultInstance() ) + val wallpaperColors by wallpaperColorsAsState() CompositionLocalProvider( LocalNavController provides navController, - LocalCardStyle provides cardStyle + LocalCardStyle provides cardStyle, + LocalWallpaperColors provides wallpaperColors, ) { LauncherTheme { AnimatedNavHost( diff --git a/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt index 6b1c712e..733fef6f 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt @@ -33,6 +33,7 @@ import de.mm20.launcher2.ktx.isAtLeastApiLevel import de.mm20.launcher2.preferences.Settings.* import de.mm20.launcher2.preferences.Settings.AppearanceSettings.ColorScheme import de.mm20.launcher2.preferences.Settings.AppearanceSettings.Theme +import de.mm20.launcher2.preferences.Settings.SystemBarsSettings.SystemBarColors import de.mm20.launcher2.ui.R import de.mm20.launcher2.ui.component.ShapedLauncherIcon import de.mm20.launcher2.ui.component.getShape @@ -251,20 +252,30 @@ fun AppearanceSettingsScreen() { ) } PreferenceCategory(stringResource(R.string.preference_category_system_bars)) { - val lightStatusBar by viewModel.lightStatusBar.observeAsState() - SwitchPreference( - title = stringResource(R.string.preference_light_status_bar), - value = lightStatusBar == true, + val lightStatusBar by viewModel.statusBarIcons.observeAsState() + ListPreference( + title = stringResource(R.string.preference_status_bar_icons), + value = lightStatusBar, + items = listOf( + stringResource(R.string.preference_system_bar_icons_auto) to SystemBarColors.Auto, + stringResource(R.string.preference_system_bar_icons_light) to SystemBarColors.Light, + stringResource(R.string.preference_system_bar_icons_dark) to SystemBarColors.Dark, + ), onValueChanged = { - viewModel.setLightStatusBar(it) + if (it != null) viewModel.setLightStatusBar(it) } ) - val lightNavBar by viewModel.lightNavBar.observeAsState() - SwitchPreference( - title = stringResource(R.string.preference_light_nav_bar), - value = lightNavBar == true, + val lightNavBar by viewModel.navBarIcons.observeAsState() + ListPreference( + title = stringResource(R.string.preference_nav_bar_icons), + value = lightNavBar, + items = listOf( + stringResource(R.string.preference_system_bar_icons_auto) to SystemBarColors.Auto, + stringResource(R.string.preference_system_bar_icons_light) to SystemBarColors.Light, + stringResource(R.string.preference_system_bar_icons_dark) to SystemBarColors.Dark, + ), onValueChanged = { - viewModel.setLightNavBar(it) + if (it != null) viewModel.setLightNavBar(it) } ) val hideStatusBar by viewModel.hideStatusBar.observeAsState() diff --git a/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreenVM.kt b/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreenVM.kt index b2fe39bb..8cc48e30 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreenVM.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreenVM.kt @@ -13,6 +13,7 @@ import de.mm20.launcher2.preferences.LauncherDataStore import de.mm20.launcher2.preferences.Settings import de.mm20.launcher2.preferences.Settings.AppearanceSettings.* import de.mm20.launcher2.preferences.Settings.SearchBarSettings +import de.mm20.launcher2.preferences.Settings.SystemBarsSettings import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent @@ -217,28 +218,28 @@ class AppearanceSettingsScreenVM : ViewModel(), KoinComponent { } } - val lightStatusBar = dataStore.data.map { it.systemBars.lightStatusBar }.asLiveData() - fun setLightStatusBar(lightStatusBar: Boolean) { + val statusBarIcons = dataStore.data.map { it.systemBars.statusBarColor }.asLiveData() + fun setLightStatusBar(statusBarColor: SystemBarsSettings.SystemBarColors) { viewModelScope.launch { dataStore.updateData { it.toBuilder() .setSystemBars( it.systemBars.toBuilder() - .setLightStatusBar(lightStatusBar) + .setStatusBarColor(statusBarColor) ) .build() } } } - val lightNavBar = dataStore.data.map { it.systemBars.lightNavBar }.asLiveData() - fun setLightNavBar(lightNavBar: Boolean) { + val navBarIcons = dataStore.data.map { it.systemBars.navBarColor }.asLiveData() + fun setLightNavBar(navBarColors: SystemBarsSettings.SystemBarColors) { viewModelScope.launch { dataStore.updateData { it.toBuilder() .setSystemBars( it.systemBars.toBuilder() - .setLightNavBar(lightNavBar) + .setNavBarColor(navBarColors) ) .build() } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/LauncherTheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/LauncherTheme.kt index de928804..26bb2b28 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/LauncherTheme.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/LauncherTheme.kt @@ -16,6 +16,7 @@ import de.mm20.launcher2.preferences.Settings import de.mm20.launcher2.preferences.Settings.AppearanceSettings import de.mm20.launcher2.preferences.Settings.AppearanceSettings.Theme import de.mm20.launcher2.ui.locals.LocalDarkTheme +import de.mm20.launcher2.ui.locals.LocalWallpaperColors import de.mm20.launcher2.ui.theme.colorscheme.* import de.mm20.launcher2.ui.theme.typography.DefaultTypography import de.mm20.launcher2.ui.theme.typography.getDeviceDefaultTypography @@ -124,11 +125,10 @@ fun colorSchemeAsState( } else -> { if (Build.VERSION.SDK_INT >= 27 && (Build.VERSION.SDK_INT < 31 || colorScheme == AppearanceSettings.ColorScheme.DebugMaterialYouCompat)) { - val wallpaperColors by wallpaperColorsAsState() + val wallpaperColors = LocalWallpaperColors.current val state = remember(wallpaperColors, darkTheme) { mutableStateOf( - wallpaperColors?.let { MaterialYouCompatScheme(it, darkTheme) } - ?: if (darkTheme) DarkDefaultColorScheme else LightDefaultColorScheme + MaterialYouCompatScheme(wallpaperColors, darkTheme) ) } return state diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/WallpaperColors.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/WallpaperColors.kt index 8433f9f9..41399b84 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/WallpaperColors.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/WallpaperColors.kt @@ -5,21 +5,35 @@ import android.os.Build import android.os.Handler import android.os.Looper import androidx.annotation.RequiresApi -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -data class WallpaperColors(val primary: Color, val secondary: Color?, val tertiary: Color?) { +data class WallpaperColors( + val primary: Color = Color(0xFF3C6089), + val secondary: Color? = null, + val tertiary: Color? = null, + private val hints: Int = 0, +) { + val supportsDarkText: Boolean + get() = hints and android.app.WallpaperColors.HINT_SUPPORTS_DARK_TEXT != 0 + companion object { @RequiresApi(Build.VERSION_CODES.O_MR1) fun fromPlatformType(colors: android.app.WallpaperColors): WallpaperColors { return WallpaperColors( Color(colors.primaryColor.toArgb()), colors.secondaryColor?.toArgb()?.let { Color(it) }, - colors.tertiaryColor?.toArgb()?.let { Color(it) } + colors.tertiaryColor?.toArgb()?.let { Color(it) }, + colors.colorHints ) } } @@ -27,18 +41,18 @@ data class WallpaperColors(val primary: Color, val secondary: Color?, val tertia @RequiresApi(Build.VERSION_CODES.O_MR1) @Composable -fun wallpaperColorsAsState(): State { +fun wallpaperColorsAsState(): State { val scope = rememberCoroutineScope() val context = LocalContext.current - val state = remember { mutableStateOf(null) } + val state = remember { mutableStateOf(WallpaperColors()) } DisposableEffect(null) { val wallpaperManager = WallpaperManager.getInstance(context) val callback = callback@{ colors: android.app.WallpaperColors?, which: Int -> - if (which or WallpaperManager.FLAG_SYSTEM == 0) return@callback + if (which and WallpaperManager.FLAG_SYSTEM == 0) return@callback if (colors != null) { state.value = WallpaperColors.fromPlatformType(colors) } else { - state.value = null + state.value = WallpaperColors() } } wallpaperManager.addOnColorsChangedListener( @@ -57,6 +71,4 @@ fun wallpaperColorsAsState(): State { } } return state -} - -internal val DefaultWallpaperColors = WallpaperColors(Color.White, null, null) \ No newline at end of file +} \ No newline at end of file