Feat: App list view (#1170)
* Feat: grid icon visibility settings and migration support * fix: remove unnecessary padding * Feat: Create List View Settings * fix FavoritesPartProvider * small fix * fix favorites * Remove useless datastore migration * Change app list default value * Revert migration 3 * Hide list icon preference if list is not enabled * Use ListResults for app list --------- Co-authored-by: MM20 <15646950+MM2-0@users.noreply.github.com>
This commit is contained in:
+3
-2
@@ -1,14 +1,13 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import de.mm20.launcher2.preferences.search.LocationSearchSettings
|
||||
import de.mm20.launcher2.search.SearchFilters
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class LauncherSettingsData internal constructor(
|
||||
val schemaVersion: Int = 2,
|
||||
val schemaVersion: Int = 3,
|
||||
|
||||
val uiColorScheme: ColorScheme = ColorScheme.System,
|
||||
val uiTheme: ThemeDescriptor = ThemeDescriptor.Default,
|
||||
@@ -83,6 +82,8 @@ data class LauncherSettingsData internal constructor(
|
||||
val gridColumnCount: Int = 5,
|
||||
val gridIconSize: Int = 48,
|
||||
val gridLabels: Boolean = true,
|
||||
val gridList: Boolean = false,
|
||||
val gridListIcons: Boolean = true,
|
||||
|
||||
val searchBarStyle: SearchBarStyle = SearchBarStyle.Transparent,
|
||||
val searchBarColors: SearchBarColors = SearchBarColors.Auto,
|
||||
|
||||
+3
-1
@@ -2,6 +2,7 @@ package de.mm20.launcher2.preferences
|
||||
|
||||
import androidx.datastore.core.CorruptionException
|
||||
import androidx.datastore.core.Serializer
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.decodeFromStream
|
||||
@@ -21,6 +22,7 @@ internal object LauncherSettingsDataSerializer : Serializer<LauncherSettingsData
|
||||
override val defaultValue: LauncherSettingsData
|
||||
get() = LauncherSettingsData(schemaVersion = 0)
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
override suspend fun readFrom(input: InputStream): LauncherSettingsData {
|
||||
try {
|
||||
return json.decodeFromStream(input)
|
||||
@@ -36,4 +38,4 @@ internal object LauncherSettingsDataSerializer : Serializer<LauncherSettingsData
|
||||
override suspend fun writeTo(t: LauncherSettingsData, output: OutputStream) {
|
||||
json.encodeToStream(t, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ data class GridSettings(
|
||||
val columnCount: Int = 5,
|
||||
val iconSize: Int = 48,
|
||||
val showLabels: Boolean = true,
|
||||
val showList: Boolean = false,
|
||||
val showListIcons: Boolean = true,
|
||||
)
|
||||
|
||||
class UiSettings internal constructor(
|
||||
@@ -48,6 +50,8 @@ class UiSettings internal constructor(
|
||||
get() = launcherDataStore.data.map {
|
||||
GridSettings(
|
||||
showLabels = it.gridLabels,
|
||||
showList = it.gridList,
|
||||
showListIcons = it.gridListIcons,
|
||||
iconSize = it.gridIconSize,
|
||||
columnCount = it.gridColumnCount,
|
||||
)
|
||||
@@ -71,6 +75,17 @@ class UiSettings internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setGridShowList(showList: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(gridList = showList)
|
||||
}
|
||||
}
|
||||
|
||||
fun setGridShowListIcons(showIcons: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(gridListIcons = showIcons)
|
||||
}
|
||||
}
|
||||
|
||||
val cardStyle
|
||||
get() = launcherDataStore.data.map {
|
||||
@@ -342,4 +357,4 @@ class UiSettings internal constructor(
|
||||
it.copy(widgetsEditButton = editButton)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user