Add clock widget preference migration, remove OnePlus variant
This commit is contained in:
@@ -2,6 +2,7 @@ package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import de.mm20.launcher2.preferences.migrations.Migration1
|
||||
import de.mm20.launcher2.preferences.migrations.Migration2
|
||||
import de.mm20.launcher2.settings.BaseSettings
|
||||
|
||||
internal class LauncherDataStore(
|
||||
@@ -11,7 +12,10 @@ internal class LauncherDataStore(
|
||||
context,
|
||||
fileName = "settings.json",
|
||||
serializer = LauncherSettingsDataSerializer,
|
||||
migrations = listOf(Migration1(legacyDataStore)),
|
||||
migrations = listOf(
|
||||
Migration1(legacyDataStore),
|
||||
Migration2(),
|
||||
),
|
||||
) {
|
||||
|
||||
val data
|
||||
|
||||
+4
-3
@@ -4,11 +4,10 @@ import android.content.Context
|
||||
import de.mm20.launcher2.preferences.search.LocationSearchSettings
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.UUID
|
||||
|
||||
@Serializable
|
||||
data class LauncherSettingsData(
|
||||
val schemaVersion: Int = 1,
|
||||
val schemaVersion: Int = 2,
|
||||
|
||||
val uiColorScheme: ColorScheme = ColorScheme.System,
|
||||
val uiTheme: ThemeDescriptor = ThemeDescriptor.Default,
|
||||
@@ -186,12 +185,14 @@ sealed interface ClockWidgetStyle {
|
||||
@SerialName("digital1")
|
||||
data class Digital1(
|
||||
val outlined: Boolean = false,
|
||||
@Deprecated("Variant.MDY has been replaced with LauncherSettingsData.clockWidgetUseThemeColor")
|
||||
val variant: Variant = Variant.Default,
|
||||
) : ClockWidgetStyle {
|
||||
@Serializable
|
||||
@Deprecated("No longer in use")
|
||||
enum class Variant {
|
||||
Default,
|
||||
OnePlus,
|
||||
MDY,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ class Migration1(
|
||||
LegacySettings.ClockWidgetSettings.ClockStyle.AnalogClock -> ClockWidgetStyle.Analog
|
||||
LegacySettings.ClockWidgetSettings.ClockStyle.EmptyClock -> ClockWidgetStyle.Empty
|
||||
LegacySettings.ClockWidgetSettings.ClockStyle.DigitalClock1_MDY -> ClockWidgetStyle.Digital1(
|
||||
variant = ClockWidgetStyle.Digital1.Variant.Default
|
||||
variant = ClockWidgetStyle.Digital1.Variant.MDY
|
||||
)
|
||||
|
||||
LegacySettings.ClockWidgetSettings.ClockStyle.DigitalClock1_Outlined -> ClockWidgetStyle.Digital1(
|
||||
@@ -84,7 +84,7 @@ class Migration1(
|
||||
)
|
||||
|
||||
LegacySettings.ClockWidgetSettings.ClockStyle.DigitalClock1_OnePlus -> ClockWidgetStyle.Digital1(
|
||||
variant = ClockWidgetStyle.Digital1.Variant.OnePlus
|
||||
variant = ClockWidgetStyle.Digital1.Variant.Default
|
||||
)
|
||||
|
||||
else -> ClockWidgetStyle.Digital1()
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import androidx.datastore.core.DataMigration
|
||||
import de.mm20.launcher2.preferences.ClockWidgetStyle.Digital1
|
||||
import de.mm20.launcher2.preferences.LauncherSettingsData
|
||||
|
||||
class Migration2 : DataMigration<LauncherSettingsData> {
|
||||
override suspend fun cleanUp() {
|
||||
}
|
||||
|
||||
override suspend fun shouldMigrate(currentData: LauncherSettingsData): Boolean {
|
||||
return currentData.schemaVersion < 2
|
||||
}
|
||||
|
||||
override suspend fun migrate(currentData: LauncherSettingsData): LauncherSettingsData {
|
||||
return currentData.copy(
|
||||
schemaVersion = 2,
|
||||
clockWidgetUseThemeColor = (currentData.clockWidgetStyle as? Digital1)?.variant == Digital1.Variant.MDY
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user