Layout rewrite please read https://github.com/MM2-0/Kvaesitso/discussions/1431
Rewrite of the underlying layout and gesture handling
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import de.mm20.launcher2.preferences.migrations.Migration2
|
||||
import de.mm20.launcher2.preferences.migrations.Migration3
|
||||
import de.mm20.launcher2.preferences.migrations.Migration4
|
||||
import de.mm20.launcher2.preferences.migrations.Migration5
|
||||
import de.mm20.launcher2.settings.BaseSettings
|
||||
|
||||
internal class LauncherDataStore(
|
||||
@@ -16,6 +17,7 @@ internal class LauncherDataStore(
|
||||
Migration2(),
|
||||
Migration3(),
|
||||
Migration4(),
|
||||
Migration5(),
|
||||
),
|
||||
) {
|
||||
|
||||
|
||||
+11
-2
@@ -4,15 +4,17 @@ import android.content.Context
|
||||
import de.mm20.launcher2.search.SearchFilters
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonNames
|
||||
|
||||
@Serializable
|
||||
data class LauncherSettingsData internal constructor(
|
||||
val schemaVersion: Int = 3,
|
||||
val schemaVersion: Int = 5,
|
||||
|
||||
val uiColorScheme: ColorScheme = ColorScheme.System,
|
||||
val uiTheme: ThemeDescriptor = ThemeDescriptor.Default,
|
||||
val uiCompatModeColors: Boolean = false,
|
||||
val uiFont: Font = Font.Outfit,
|
||||
@Deprecated("No longer in use, only used for migration")
|
||||
val uiBaseLayout: BaseLayout = BaseLayout.PullDown,
|
||||
val uiOrientation: ScreenOrientation = ScreenOrientation.Auto,
|
||||
|
||||
@@ -39,10 +41,12 @@ data class LauncherSettingsData internal constructor(
|
||||
val clockWidgetBatteryPart: Boolean = true,
|
||||
val clockWidgetMusicPart: Boolean = true,
|
||||
val clockWidgetDatePart: Boolean = true,
|
||||
@Deprecated("Use homeScreenWidgets")
|
||||
val clockWidgetFillHeight: Boolean = true,
|
||||
val clockWidgetAlignment: ClockWidgetAlignment = ClockWidgetAlignment.Bottom,
|
||||
|
||||
val homeScreenDock: Boolean = false,
|
||||
val homeScreenWidgets: Boolean = false,
|
||||
|
||||
val favoritesEnabled: Boolean = true,
|
||||
val favoritesFrequentlyUsed: Boolean = true,
|
||||
@@ -123,9 +127,10 @@ data class LauncherSettingsData internal constructor(
|
||||
|
||||
val widgetsEditButton: Boolean = true,
|
||||
|
||||
val gesturesSwipeDown: GestureAction = GestureAction.Notifications,
|
||||
val gesturesSwipeDown: GestureAction = GestureAction.Search,
|
||||
val gesturesSwipeLeft: GestureAction = GestureAction.NoAction,
|
||||
val gesturesSwipeRight: GestureAction = GestureAction.NoAction,
|
||||
val gesturesSwipeUp: GestureAction = GestureAction.Widgets,
|
||||
val gesturesDoubleTap: GestureAction = GestureAction.ScreenLock,
|
||||
val gesturesLongPress: GestureAction = GestureAction.NoAction,
|
||||
val gesturesHomeButton: GestureAction = GestureAction.NoAction,
|
||||
@@ -366,6 +371,10 @@ sealed interface GestureAction {
|
||||
@SerialName("search")
|
||||
data object Search : GestureAction
|
||||
|
||||
@Serializable
|
||||
@SerialName("widgets")
|
||||
data object Widgets : GestureAction
|
||||
|
||||
@Serializable
|
||||
@SerialName("power_menu")
|
||||
data object PowerMenu : GestureAction
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import androidx.datastore.core.DataMigration
|
||||
import de.mm20.launcher2.preferences.BaseLayout
|
||||
import de.mm20.launcher2.preferences.GestureAction
|
||||
import de.mm20.launcher2.preferences.LauncherSettingsData
|
||||
|
||||
class Migration5 : DataMigration<LauncherSettingsData> {
|
||||
override suspend fun cleanUp() {
|
||||
}
|
||||
|
||||
override suspend fun migrate(currentData: LauncherSettingsData): LauncherSettingsData {
|
||||
return currentData.copy(
|
||||
schemaVersion = 5,
|
||||
gesturesSwipeDown = if (currentData.uiBaseLayout == BaseLayout.PullDown) GestureAction.Search else currentData.gesturesSwipeDown,
|
||||
gesturesSwipeLeft = if (currentData.uiBaseLayout == BaseLayout.Pager) GestureAction.Search else currentData.gesturesSwipeLeft,
|
||||
gesturesSwipeRight = if (currentData.uiBaseLayout == BaseLayout.PagerReversed) GestureAction.Search else currentData.gesturesSwipeRight,
|
||||
gesturesSwipeUp = GestureAction.Widgets,
|
||||
homeScreenWidgets = !currentData.clockWidgetFillHeight,
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun shouldMigrate(currentData: LauncherSettingsData): Boolean {
|
||||
return currentData.schemaVersion < 5
|
||||
}
|
||||
}
|
||||
+1
-13
@@ -64,23 +64,11 @@ class ClockWidgetSettings internal constructor(
|
||||
}
|
||||
|
||||
val fillHeight
|
||||
get() = launcherDataStore.data.map { it.clockWidgetFillHeight }
|
||||
|
||||
fun setFillHeight(fillHeight: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(clockWidgetFillHeight = fillHeight)
|
||||
}
|
||||
}
|
||||
get() = launcherDataStore.data.map { !it.homeScreenWidgets }
|
||||
|
||||
val dock
|
||||
get() = launcherDataStore.data.map { it.homeScreenDock }
|
||||
|
||||
fun setDock(dock: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(homeScreenDock = dock)
|
||||
}
|
||||
}
|
||||
|
||||
val alignment
|
||||
get() = launcherDataStore.data.map { it.clockWidgetAlignment }
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ data class GestureSettingsData(
|
||||
val swipeDown: GestureAction,
|
||||
val swipeLeft: GestureAction,
|
||||
val swipeRight: GestureAction,
|
||||
val swipeUp: GestureAction,
|
||||
val doubleTap: GestureAction,
|
||||
val longPress: GestureAction,
|
||||
val homeButton: GestureAction,
|
||||
@@ -23,6 +24,7 @@ class GestureSettings internal constructor(
|
||||
swipeDown = it.gesturesSwipeDown,
|
||||
swipeLeft = it.gesturesSwipeLeft,
|
||||
swipeRight = it.gesturesSwipeRight,
|
||||
swipeUp = it.gesturesSwipeUp,
|
||||
doubleTap = it.gesturesDoubleTap,
|
||||
longPress = it.gesturesLongPress,
|
||||
homeButton = it.gesturesHomeButton,
|
||||
@@ -38,6 +40,9 @@ class GestureSettings internal constructor(
|
||||
val swipeRight: Flow<GestureAction> = dataStore.data.map { it.gesturesSwipeRight }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val swipeUp: Flow<GestureAction> = dataStore.data.map { it.gesturesSwipeUp }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val doubleTap: Flow<GestureAction> = dataStore.data.map { it.gesturesDoubleTap }
|
||||
.distinctUntilChanged()
|
||||
|
||||
@@ -65,6 +70,12 @@ class GestureSettings internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setSwipeUp(action: GestureAction) {
|
||||
dataStore.update {
|
||||
it.copy(gesturesSwipeUp = action)
|
||||
}
|
||||
}
|
||||
|
||||
fun setDoubleTap(action: GestureAction) {
|
||||
dataStore.update {
|
||||
it.copy(gesturesDoubleTap = action)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package de.mm20.launcher2.preferences.ui
|
||||
|
||||
import de.mm20.launcher2.preferences.BaseLayout
|
||||
import de.mm20.launcher2.preferences.ColorScheme
|
||||
import de.mm20.launcher2.preferences.Font
|
||||
import de.mm20.launcher2.preferences.IconShape
|
||||
@@ -225,20 +224,9 @@ class UiSettings internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
val baseLayout
|
||||
get() = launcherDataStore.data.map {
|
||||
it.uiBaseLayout
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setBaseLayout(baseLayout: BaseLayout) {
|
||||
launcherDataStore.update {
|
||||
it.copy(uiBaseLayout = baseLayout)
|
||||
}
|
||||
}
|
||||
|
||||
val clockFillScreen
|
||||
get() = launcherDataStore.data.map {
|
||||
it.clockWidgetFillHeight
|
||||
it.homeScreenWidgets
|
||||
}.distinctUntilChanged()
|
||||
|
||||
val searchBarStyle
|
||||
@@ -347,6 +335,23 @@ class UiSettings internal constructor(
|
||||
it.homeScreenDock
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setDock(dock: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(homeScreenDock = dock)
|
||||
}
|
||||
}
|
||||
|
||||
val homeScreenWidgets
|
||||
get() = launcherDataStore.data.map {
|
||||
it.homeScreenWidgets
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setHomeScreenWidgets(widgets: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(homeScreenWidgets = widgets)
|
||||
}
|
||||
}
|
||||
|
||||
val widgetEditButton
|
||||
get() = launcherDataStore.data.map {
|
||||
it.widgetsEditButton
|
||||
|
||||
Reference in New Issue
Block a user