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:
KorigamiK
2025-04-02 19:59:13 +02:00
committed by GitHub
co-authored by MM20
parent b2cf7f5e5e
commit 2c2c88b93c
13 changed files with 674 additions and 498 deletions
@@ -557,8 +557,12 @@
<string name="preference_category_grid">Grid</string>
<string name="preference_grid_icon_size">Icon size</string>
<string name="preference_grid_column_count">Number of columns</string>
<string name="preference_grid_list_style">Show app results in a list</string>
<string name="preference_grid_list_icons">Show app icons in list</string>
<string name="preference_grid_labels">Show labels</string>
<string name="preference_grid_labels_summary">Show the app name below the icon</string>
<string name="preference_grid_list_style_summary">Show applications in a list view instead of grid</string>
<string name="preference_grid_list_icons_summary">Show icons in the list view</string>
<string name="preference_screen_debug">Debug</string>
<string name="preference_screen_debug_summary">Troubleshooting tools</string>
<string name="preference_category_widgets">Widgets</string>
@@ -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,
@@ -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)
}
}
}
}