Add preferences for frequently used items in favorites

This commit is contained in:
MM20
2022-09-20 20:23:02 +02:00
parent d96019e063
commit 93f1f41d65
6 changed files with 175 additions and 40 deletions
@@ -22,7 +22,7 @@ internal val Context.dataStore: LauncherDataStore by dataStore(
}
)
internal const val SchemaVersion = 9
internal const val SchemaVersion = 10
internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
return listOf(
@@ -35,5 +35,6 @@ internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
Migration_6_7(),
Migration_7_8(),
Migration_8_9(),
Migration_9_10(),
)
}
@@ -57,6 +57,8 @@ fun createFactorySettings(context: Context): Settings {
Settings.FavoritesSettings
.newBuilder()
.setEnabled(true)
.setFrequentlyUsed(true)
.setFrequentlyUsedRows(1)
)
.setFileSearch(
Settings.FilesSearchSettings
@@ -0,0 +1,13 @@
package de.mm20.launcher2.preferences.migrations
import de.mm20.launcher2.preferences.Settings
class Migration_9_10: VersionedMigration(9, 10) {
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
return builder.setFavorites(
builder.favorites.toBuilder()
.setFrequentlyUsed(true)
.setFrequentlyUsedRows(1)
)
}
}
@@ -126,6 +126,8 @@ message Settings {
message FavoritesSettings {
bool enabled = 1;
bool frequently_used = 2;
int32 frequently_used_rows = 3;
}
FavoritesSettings favorites = 8;