Merge branch 'main' of github.com:MM2-0/Kvaesitso
This commit is contained in:
@@ -607,7 +607,10 @@
|
||||
<string name="preference_clockwidget_music_part">Media</string>
|
||||
<string name="preference_clockwidget_music_part_summary">Show media controls when there is an active media session</string>
|
||||
<string name="preference_clockwidget_battery_part">Battery</string>
|
||||
<string name="preference_clockwidget_battery_part_summary">Show the current battery level when the battery is low or charging</string>
|
||||
<string name="preference_clockwidget_battery_part_summary">Show the current battery level</string>
|
||||
<string name="preference_clockwidget_battery_part_always_show">Always show</string>
|
||||
<string name="preference_clockwidget_battery_part_show">Show when low or charging</string>
|
||||
<string name="preference_clockwidget_battery_part_hide">Off</string>
|
||||
<string name="preference_clockwidget_alarm_part">Alarms</string>
|
||||
<string name="preference_clockwidget_alarm_part_summary">Show alarms that will ring within the next 8 hours</string>
|
||||
<string name="preference_screen_backup">Backup and restore</string>
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.mm20.launcher2.preferences.migrations.Migration2
|
||||
import de.mm20.launcher2.preferences.migrations.Migration3
|
||||
import de.mm20.launcher2.preferences.migrations.Migration4
|
||||
import de.mm20.launcher2.preferences.migrations.Migration5
|
||||
import de.mm20.launcher2.preferences.migrations.Migration6
|
||||
import de.mm20.launcher2.settings.BaseSettings
|
||||
|
||||
internal class LauncherDataStore(
|
||||
@@ -19,6 +20,7 @@ internal class LauncherDataStore(
|
||||
Migration3(),
|
||||
Migration4(),
|
||||
Migration5(),
|
||||
Migration6(),
|
||||
),
|
||||
corruptionHandler = ReplaceFileCorruptionHandler { LauncherSettingsData() }
|
||||
) {
|
||||
|
||||
@@ -51,7 +51,11 @@ data class LauncherSettingsData internal constructor(
|
||||
val clockWidgetMonospaced: Boolean = false,
|
||||
val clockWidgetUseThemeColor: Boolean = false,
|
||||
val clockWidgetAlarmPart: Boolean = true,
|
||||
val clockWidgetBatteryPart: Boolean = true,
|
||||
@Deprecated("")
|
||||
@SerialName("clockWidgetBatteryPart")
|
||||
val _clockWidgetBatteryPart: Boolean = true,
|
||||
@SerialName("clockWidgetBatteryPart2")
|
||||
val clockWidgetBatteryPart: BatteryStatusVisibility = BatteryStatusVisibility.Show,
|
||||
val clockWidgetMusicPart: Boolean = true,
|
||||
val clockWidgetDatePart: Boolean = true,
|
||||
val clockWidgetFillHeight: Boolean = false,
|
||||
@@ -457,3 +461,10 @@ enum class MeasurementSystem {
|
||||
@SerialName("uk") UnitedKingdom,
|
||||
@SerialName("us") UnitedStates,
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class BatteryStatusVisibility {
|
||||
@SerialName("hide") Hide,
|
||||
@SerialName("show") Show,
|
||||
@SerialName("always") Always
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import androidx.datastore.core.DataMigration
|
||||
import de.mm20.launcher2.preferences.BatteryStatusVisibility
|
||||
import de.mm20.launcher2.preferences.LauncherSettingsData
|
||||
|
||||
class Migration6 : DataMigration<LauncherSettingsData> {
|
||||
override suspend fun cleanUp() {
|
||||
}
|
||||
|
||||
override suspend fun shouldMigrate(currentData: LauncherSettingsData): Boolean {
|
||||
return currentData.schemaVersion < 6
|
||||
}
|
||||
|
||||
override suspend fun migrate(currentData: LauncherSettingsData): LauncherSettingsData {
|
||||
return currentData.copy(
|
||||
schemaVersion = 6,
|
||||
clockWidgetBatteryPart = if (currentData._clockWidgetBatteryPart) {
|
||||
BatteryStatusVisibility.Show
|
||||
} else {
|
||||
BatteryStatusVisibility.Hide
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.mm20.launcher2.preferences.ui
|
||||
|
||||
import de.mm20.launcher2.preferences.BatteryStatusVisibility
|
||||
import de.mm20.launcher2.preferences.ClockWidgetAlignment
|
||||
import de.mm20.launcher2.preferences.ClockWidgetColors
|
||||
import de.mm20.launcher2.preferences.ClockWidgetStyle
|
||||
@@ -13,7 +14,7 @@ import kotlinx.coroutines.flow.map
|
||||
data class ClockWidgetParts(
|
||||
val date: Boolean,
|
||||
val music: Boolean = false,
|
||||
val battery: Boolean = false,
|
||||
val battery: BatteryStatusVisibility = BatteryStatusVisibility.Hide,
|
||||
val alarm: Boolean = false,
|
||||
)
|
||||
|
||||
@@ -51,7 +52,7 @@ class ClockWidgetSettings internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setBatteryPart(batteryPart: Boolean) {
|
||||
fun setBatteryPart(batteryPart: BatteryStatusVisibility) {
|
||||
launcherDataStore.update {
|
||||
it.copy(clockWidgetBatteryPart = batteryPart)
|
||||
}
|
||||
@@ -175,4 +176,4 @@ internal val ClockWidgetStyle.enumValue
|
||||
is ClockWidgetStyle.Segment -> ClockWidgetStyleEnum.Segment
|
||||
is ClockWidgetStyle.Empty -> ClockWidgetStyleEnum.Empty
|
||||
is ClockWidgetStyle.Custom -> ClockWidgetStyleEnum.Custom
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user