Add clock widget parts preferences
This commit is contained in:
@@ -8,6 +8,7 @@ import androidx.datastore.dataStore
|
||||
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||
import de.mm20.launcher2.preferences.migrations.FactorySettingsMigration
|
||||
import de.mm20.launcher2.preferences.migrations.Migration_1_2
|
||||
import de.mm20.launcher2.preferences.migrations.Migration_2_3
|
||||
|
||||
typealias LauncherDataStore = DataStore<Settings>
|
||||
|
||||
@@ -15,7 +16,11 @@ internal val Context.dataStore: LauncherDataStore by dataStore(
|
||||
fileName = "settings.pb",
|
||||
serializer = SettingsSerializer,
|
||||
produceMigrations = {
|
||||
listOf(FactorySettingsMigration(it), Migration_1_2())
|
||||
listOf(
|
||||
FactorySettingsMigration(it),
|
||||
Migration_1_2(),
|
||||
Migration_2_3()
|
||||
)
|
||||
},
|
||||
corruptionHandler = ReplaceFileCorruptionHandler {
|
||||
CrashReporter.logException(it)
|
||||
@@ -24,4 +29,4 @@ internal val Context.dataStore: LauncherDataStore by dataStore(
|
||||
}
|
||||
)
|
||||
|
||||
internal const val SchemaVersion = 2
|
||||
internal const val SchemaVersion = 3
|
||||
@@ -35,6 +35,10 @@ fun createFactorySettings(context: Context): Settings {
|
||||
.newBuilder()
|
||||
.setLayout(Settings.ClockWidgetSettings.ClockWidgetLayout.Vertical)
|
||||
.setClockStyle(Settings.ClockWidgetSettings.ClockStyle.DigitalClock1)
|
||||
.setAlarmPart(true)
|
||||
.setBatteryPart(true)
|
||||
.setDatePart(true)
|
||||
.setMusicPart(true)
|
||||
.build()
|
||||
)
|
||||
.setFavorites(
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_2_3: VersionedMigration(2, 3) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setClockWidget(
|
||||
builder.clockWidget.toBuilder()
|
||||
.setAlarmPart(true)
|
||||
.setBatteryPart(true)
|
||||
.setDatePart(true)
|
||||
.setMusicPart(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,10 @@ message Settings {
|
||||
EmptyClock = 4;
|
||||
}
|
||||
ClockStyle clock_style = 2;
|
||||
bool date_part = 3;
|
||||
bool music_part = 4;
|
||||
bool battery_part = 5;
|
||||
bool alarm_part = 6;
|
||||
}
|
||||
ClockWidgetSettings clock_widget = 7;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user