Rewrite of the underlying layout and gesture handling
This commit is contained in:
Valerie
2025-05-27 00:02:12 +02:00
committed by GitHub
parent fe322fc558
commit a24d1b8798
68 changed files with 3889 additions and 2593 deletions
+8
View File
@@ -19,6 +19,14 @@
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AssistantTheme" parent="LauncherTheme">
<item name="android:windowShowWallpaper">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowEnterTransition">@android:transition/fade</item>
<item name="android:windowExitTransition">@android:transition/fade</item>
</style>
<style name="DialogTheme" parent="BaseTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
@@ -668,6 +668,8 @@
<string name="preference_compact_tags">Compact tags</string>
<string name="preference_compact_tags_summary">Hide tag labels or icons to reduce the space occupied by tags</string>
<string name="preference_widgets_edit_button_summary">Show a button to add, remove and rearrange widgets</string>
<string name="preference_widgets_on_home_screen">Widgets on home screen</string>
<string name="preference_widgets_on_home_screen_summary">Show widgets on the home screen instead of an extra page</string>
<string name="preference_screen_homescreen">Home screen</string>
<string name="preference_screen_homescreen_summary">Clock, search bar, wallpaper, system bars</string>
<string name="preference_screen_icons">Grid &amp; icons</string>
@@ -772,11 +774,13 @@
<string name="preference_gesture_swipe_down">Swipe down</string>
<string name="preference_gesture_swipe_left">Swipe left</string>
<string name="preference_gesture_swipe_right">Swipe right</string>
<string name="preference_gesture_swipe_up">Swipe up</string>
<string name="preference_gesture_double_tap">Double tap</string>
<string name="preference_gesture_long_press">Long press</string>
<string name="preference_gesture_home_button">Home button/gesture</string>
<string name="gesture_action_none">Do nothing</string>
<string name="gesture_action_open_search">Open search</string>
<string name="gesture_action_widgets">Widgets</string>
<string name="gesture_action_launch_app">Launch app</string>
<string name="gesture_action_notifications">Open notification drawer</string>
<string name="gesture_action_lock_screen">Turn off screen</string>
@@ -1023,4 +1027,6 @@
<item quantity="other">in %1$d minutes</item>
</plurals>
<string name="departure_time_departed">departed</string>
<string name="bad_configuration_title">Congratulations, you\'ve locked yourself out!</string>
<string name="bad_configuration_summary">You\'ve discovered a combination of settings that makes both the search and settings inaccessible — effectively locking you out of the launcher.</string>
</resources>
@@ -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(),
),
) {
@@ -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
}
}
@@ -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