Migrate system bar settings
This commit is contained in:
parent
97e714acf4
commit
f5b21e4fe6
@ -114,5 +114,10 @@ fun createFactorySettings(context: Context): Settings {
|
||||
.setIconPack("")
|
||||
)
|
||||
.setEasterEgg(false)
|
||||
.setSystemBars(
|
||||
Settings.SystemBarsSettings.newBuilder()
|
||||
.setLightNavBar(false)
|
||||
.setLightStatusBar(false)
|
||||
)
|
||||
.build()
|
||||
}
|
||||
@ -159,4 +159,10 @@ message Settings {
|
||||
|
||||
bool easter_egg = 22;
|
||||
|
||||
message SystemBarsSettings {
|
||||
bool lightStatusBar = 1;
|
||||
bool lightNavBar = 2;
|
||||
}
|
||||
SystemBarsSettings system_bars = 23;
|
||||
|
||||
}
|
||||
@ -57,6 +57,14 @@ class LauncherActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
val windowController = WindowInsetsControllerCompat(window, binding.rootView)
|
||||
viewModel.lightStatusBar.observe(this) {
|
||||
windowController.isAppearanceLightStatusBars = it
|
||||
}
|
||||
viewModel.lightNavBar.observe(this) {
|
||||
windowController.isAppearanceLightNavigationBars = it
|
||||
}
|
||||
|
||||
var editFavoritesDialog: MaterialDialog? = null
|
||||
viewModel.isEditFavoritesShown.observe(this) {
|
||||
if (it) {
|
||||
|
||||
@ -18,11 +18,26 @@ class LauncherActivityVM : ViewModel(), KoinComponent {
|
||||
|
||||
private var isDarkInMode = MutableStateFlow(false)
|
||||
|
||||
val dimBackground = combine(
|
||||
private val dimBackgroundState = combine(
|
||||
dataStore.data.map { it.appearance.dimWallpaper },
|
||||
isDarkInMode
|
||||
) { dim, darkMode ->
|
||||
dim && darkMode
|
||||
}
|
||||
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()
|
||||
|
||||
fun setDarkMode(darkMode: Boolean) {
|
||||
|
||||
@ -173,6 +173,24 @@ 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,
|
||||
onValueChanged = {
|
||||
viewModel.setLightStatusBar(it)
|
||||
}
|
||||
)
|
||||
val lightNavBar by viewModel.lightNavBar.observeAsState()
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.preference_light_nav_bar),
|
||||
value = lightNavBar == true,
|
||||
onValueChanged = {
|
||||
viewModel.setLightNavBar(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,4 +148,32 @@ class AppearanceSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val lightStatusBar = dataStore.data.map { it.systemBars.lightStatusBar }.asLiveData()
|
||||
fun setLightStatusBar(lightStatusBar: Boolean) {
|
||||
viewModelScope.launch {
|
||||
dataStore.updateData {
|
||||
it.toBuilder()
|
||||
.setSystemBars(
|
||||
it.systemBars.toBuilder()
|
||||
.setLightStatusBar(lightStatusBar)
|
||||
)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val lightNavBar = dataStore.data.map { it.systemBars.lightNavBar }.asLiveData()
|
||||
fun setLightNavBar(lightNavBar: Boolean) {
|
||||
viewModelScope.launch {
|
||||
dataStore.updateData {
|
||||
it.toBuilder()
|
||||
.setSystemBars(
|
||||
it.systemBars.toBuilder()
|
||||
.setLightNavBar(lightNavBar)
|
||||
)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user