Add preference to disable charging animation

Close #456
This commit is contained in:
MM20 2023-08-26 23:04:47 +02:00
parent f079974c10
commit d1371b224d
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
8 changed files with 52 additions and 1 deletions

View File

@ -53,6 +53,9 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent {
val navBarColor = dataStore.data.map { it.systemBars.statusBarColor }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
val chargingAnimation = dataStore.data.map { it.animations.charging }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
val hideNavBar = dataStore.data.map { it.systemBars.hideNavBar }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false)
val hideStatusBar = dataStore.data.map { it.systemBars.hideStatusBar }

View File

@ -105,6 +105,8 @@ abstract class SharedLauncherActivity(
val statusBarColor by viewModel.statusBarColor.collectAsState()
val navBarColor by viewModel.navBarColor.collectAsState()
val chargingAnimation by viewModel.chargingAnimation.collectAsState()
val lightStatus =
!dimBackground && (statusBarColor == SystemBarColors.Dark || statusBarColor == SystemBarColors.Auto && wallpaperColors.supportsDarkText)
val lightNav =
@ -164,7 +166,9 @@ abstract class SharedLauncherActivity(
.background(if (dimBackground) Color.Black.copy(alpha = 0.30f) else Color.Transparent),
contentAlignment = Alignment.BottomCenter
) {
NavBarEffects(modifier = Modifier.fillMaxSize())
if (chargingAnimation == true) {
NavBarEffects(modifier = Modifier.fillMaxSize())
}
if (mode == LauncherActivityMode.Assistant) {
key(bottomSearchBar, reverseSearchResults) {
AssistantScaffold(

View File

@ -60,6 +60,7 @@ fun HomescreenSettingsScreen() {
val lightNavBar by viewModel.navBarIcons.collectAsStateWithLifecycle(null)
val hideStatusBar by viewModel.hideStatusBar.collectAsStateWithLifecycle(null)
val hideNavBar by viewModel.hideNavBar.collectAsStateWithLifecycle(null)
val chargingAnimation by viewModel.chargingAnimation.collectAsStateWithLifecycle(null)
PreferenceScreen(title = stringResource(id = R.string.preference_screen_homescreen)) {
item {
@ -173,6 +174,18 @@ fun HomescreenSettingsScreen() {
)
}
}
item {
PreferenceCategory(stringResource(R.string.preference_category_animations)) {
SwitchPreference(
title = stringResource(R.string.preference_charging_animation),
summary = stringResource(R.string.preference_charging_animation_summary),
value = chargingAnimation == true,
onValueChanged = {
viewModel.setChargingAnimation(it)
}
)
}
}
item {
PreferenceCategory(stringResource(R.string.preference_category_system_bars)) {

View File

@ -202,6 +202,21 @@ class HomescreenSettingsScreenVM(
}
}
val chargingAnimation = dataStore.data.map { it.animations.charging }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
fun setChargingAnimation(chargingAnimation: Boolean) {
viewModelScope.launch {
dataStore.updateData {
it.toBuilder()
.setAnimations(
it.animations.toBuilder()
.setCharging(chargingAnimation)
)
.build()
}
}
}
companion object : KoinComponent {
val Factory = viewModelFactory {

View File

@ -508,6 +508,9 @@
<string name="preference_icon_pack_summary_empty">No icon packs installed</string>
<!-- Indicates that an icon pack supports dynamic colors (icon colors adapt to the launchers color scheme) -->
<string name="icon_pack_dynamic_colors">Dynamic colors</string>
<string name="preference_category_animations">Animations</string>
<string name="preference_charging_animation">Charging</string>
<string name="preference_charging_animation_summary">Play a bubble animation while the device is charging</string>
<string name="preference_category_system_bars">System bars</string>
<string name="preference_status_bar_icons">Status bar icons</string>
<string name="preference_nav_bar_icons">Navigation bar icons</string>

View File

@ -185,6 +185,10 @@ fun createFactorySettings(context: Context): Settings {
.setOrdering(Settings.SearchResultOrderingSettings.Ordering.Weighted)
.setWeightFactor(Settings.SearchResultOrderingSettings.WeightFactor.Default)
)
.setAnimations(
Settings.AnimationSettings.newBuilder()
.setCharging(true)
)
.build()
}

View File

@ -15,5 +15,9 @@ class Migration_16_17: VersionedMigration(16, 17) {
}.toString()
)
)
.setAnimations(
builder.animations.toBuilder()
.setCharging(true)
)
}
}

View File

@ -367,4 +367,9 @@ message Settings {
bool widget_tags_multiline = 2;
}
UiState ui = 30;
message AnimationSettings {
bool charging = 1;
}
AnimationSettings animations = 31;
}