Custom color schemes v2 - part 3
Store preferences and apply color schemes
This commit is contained in:
@@ -22,7 +22,7 @@ internal val Context.dataStore: LauncherDataStore by dataStore(
|
||||
}
|
||||
)
|
||||
|
||||
internal const val SchemaVersion = 16
|
||||
internal const val SchemaVersion = 17
|
||||
|
||||
internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
|
||||
return listOf(
|
||||
@@ -42,5 +42,6 @@ internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
|
||||
Migration_13_14(),
|
||||
Migration_14_15(),
|
||||
Migration_15_16(),
|
||||
Migration_16_17(),
|
||||
)
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||
import de.mm20.launcher2.preferences.Settings.SearchBarSettings.SearchBarColors
|
||||
import de.mm20.launcher2.preferences.ktx.toSettingsColorsScheme
|
||||
import scheme.Scheme
|
||||
import java.util.UUID
|
||||
|
||||
fun createFactorySettings(context: Context): Settings {
|
||||
return Settings.newBuilder()
|
||||
@@ -12,16 +13,9 @@ fun createFactorySettings(context: Context): Settings {
|
||||
Settings.AppearanceSettings
|
||||
.newBuilder()
|
||||
.setTheme(Settings.AppearanceSettings.Theme.System)
|
||||
.setColorScheme(Settings.AppearanceSettings.ColorScheme.Default)
|
||||
.setDimWallpaper(false)
|
||||
.setBlurWallpaper(true)
|
||||
.setCustomColors(
|
||||
Settings.AppearanceSettings.CustomColors.newBuilder()
|
||||
.setAdvancedMode(false)
|
||||
.setBaseColors(DefaultCustomColorsBase)
|
||||
.setLightScheme(DefaultLightCustomColorScheme)
|
||||
.setDarkScheme(DefaultDarkCustomColorScheme)
|
||||
)
|
||||
.setThemeId(UUID(0L, 0L).toString())
|
||||
.setFont(Settings.AppearanceSettings.Font.Outfit)
|
||||
.build()
|
||||
)
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
import java.util.UUID
|
||||
|
||||
class Migration_16_17: VersionedMigration(16, 17) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setAppearance(
|
||||
builder.appearance.toBuilder()
|
||||
.setThemeId(
|
||||
when(builder.appearance.colorScheme) {
|
||||
Settings.AppearanceSettings.ColorScheme.BlackAndWhite -> UUID(0L, 1L)
|
||||
Settings.AppearanceSettings.ColorScheme.Custom -> UUID(1L, 1L)
|
||||
else -> UUID(0L, 0L)
|
||||
}.toString()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ message Settings {
|
||||
Custom = 3;
|
||||
EasterEgg = 4;
|
||||
}
|
||||
ColorScheme color_scheme = 6;
|
||||
ColorScheme color_scheme = 6 [deprecated = true];
|
||||
message CustomColors {
|
||||
bool advanced_mode = 1;
|
||||
message BaseColors {
|
||||
@@ -72,7 +72,7 @@ message Settings {
|
||||
Scheme light_scheme = 3;
|
||||
Scheme dark_scheme = 4;
|
||||
}
|
||||
CustomColors custom_colors = 8;
|
||||
CustomColors custom_colors = 8 [deprecated = true];
|
||||
bool dim_wallpaper = 7;
|
||||
|
||||
/**
|
||||
@@ -87,6 +87,8 @@ message Settings {
|
||||
Font font = 10;
|
||||
|
||||
bool blur_wallpaper = 11;
|
||||
// UUID of the selected theme
|
||||
string theme_id = 12;
|
||||
}
|
||||
AppearanceSettings appearance = 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user