From 99fd69d5d960a847b2cd05259a595016028b170c Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Wed, 28 May 2025 21:46:45 +0200 Subject: [PATCH] Remove home button gesture - It causes more problems than it solves - Who even uses 3 button nav in 2025? Close #1436 --- .../ui/launcher/LauncherScaffoldVM.kt | 7 ------ .../ui/launcher/SharedLauncherActivity.kt | 5 ---- .../ui/launcher/scaffold/LauncherScaffold.kt | 20 +--------------- .../gestures/GestureSettingsScreen.kt | 23 ------------------- .../gestures/GestureSettingsScreenVM.kt | 23 ------------------- .../preferences/LauncherSettingsData.kt | 1 - .../preferences/ui/GestureSettings.kt | 13 ----------- 7 files changed, 1 insertion(+), 91 deletions(-) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherScaffoldVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherScaffoldVM.kt index 48bba307..6879faf7 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherScaffoldVM.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/LauncherScaffoldVM.kt @@ -91,7 +91,6 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent { val swipeUpAction = settings.swipeUp val longPressAction = settings.longPress val doubleTapAction = settings.doubleTap - val homeButtonAction = settings.homeButton val swipeLeftAppKey = (swipeLeftAction as? GestureAction.Launch)?.key val swipeRightAppKey = (swipeRightAction as? GestureAction.Launch)?.key @@ -99,7 +98,6 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent { val swipeUpAppKey = (swipeUpAction as? GestureAction.Launch)?.key val longPressAppKey = (longPressAction as? GestureAction.Launch)?.key val doubleTapAppKey = (doubleTapAction as? GestureAction.Launch)?.key - val homeButtonAppKey = (homeButtonAction as? GestureAction.Launch)?.key val apps = listOfNotNull( swipeLeftAppKey, swipeRightAppKey, @@ -107,7 +105,6 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent { swipeUpAppKey, longPressAppKey, doubleTapAppKey, - homeButtonAppKey, ).let { searchableRepository.getByKeys(it).first() } GestureState( @@ -117,14 +114,12 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent { swipeUpAction = swipeUpAction, longPressAction = longPressAction, doubleTapAction = doubleTapAction, - homeButtonAction = homeButtonAction, swipeLeftApp = apps.find { it.key == swipeLeftAppKey }, swipeRightApp = apps.find { it.key == swipeRightAppKey }, swipeDownApp = apps.find { it.key == swipeDownAppKey }, swipeUpApp = apps.find { it.key == swipeUpAppKey }, longPressApp = apps.find { it.key == longPressAppKey }, doubleTapApp = apps.find { it.key == doubleTapAppKey }, - homeButtonApp = apps.find { it.key == homeButtonAppKey }, ) }.stateIn(viewModelScope, SharingStarted.Eagerly, null) } @@ -136,13 +131,11 @@ data class GestureState( val swipeUpAction: GestureAction = GestureAction.NoAction, val longPressAction: GestureAction = GestureAction.NoAction, val doubleTapAction: GestureAction = GestureAction.NoAction, - val homeButtonAction: GestureAction = GestureAction.NoAction, val swipeLeftApp: SavableSearchable? = null, val swipeRightApp: SavableSearchable? = null, val swipeDownApp: SavableSearchable? = null, val swipeUpApp: SavableSearchable? = null, val longPressApp: SavableSearchable? = null, val doubleTapApp: SavableSearchable? = null, - val homeButtonApp: SavableSearchable? = null, ) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt index 59abdc29..731ea88e 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt @@ -345,11 +345,6 @@ abstract class SharedLauncherActivity( gestures.longPressApp, Gesture.LongPress, ), - homeButton = getScaffoldGesture( - gestures.homeButtonAction, - gestures.homeButtonApp, - Gesture.HomeButton, - ), fixedSearchBar = fixedSearchBar, searchBarStyle = searchBarStyle, searchBarPosition = if (bottomSearchBar) SearchBarPosition.Bottom else SearchBarPosition.Top, diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt index 60b832dc..1b1a4cd1 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt @@ -142,7 +142,6 @@ internal data class ScaffoldConfiguration( val swipeRight: ScaffoldGesture? = null, val doubleTap: ScaffoldGesture? = null, val longPress: ScaffoldGesture? = null, - val homeButton: ScaffoldGesture? = null, /** * Position of the search bar */ @@ -208,7 +207,6 @@ private operator fun ScaffoldConfiguration.get(gesture: Gesture): ScaffoldGestur Gesture.SwipeRight -> swipeRight Gesture.DoubleTap -> doubleTap Gesture.LongPress -> longPress - Gesture.HomeButton -> homeButton Gesture.TapSearchBar -> searchBarTap } } @@ -221,7 +219,6 @@ enum class Gesture(val orientation: Orientation?) { DoubleTap(null), LongPress(null), TapSearchBar(null), - HomeButton(null), } internal class LauncherScaffoldState( @@ -753,11 +750,6 @@ internal class LauncherScaffoldState( performTapGesture(Gesture.LongPress) } - suspend fun onHomeButtonPress() { - performTapGesture(Gesture.HomeButton) - - } - suspend fun onSearchBarTap() { if (currentComponent is SearchComponent) return openSearch() @@ -1198,17 +1190,7 @@ internal fun LauncherScaffold( var pauseTime = 0L lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) { try { - if (pauseTime > 0L && System.currentTimeMillis() - pauseTime < 50L) { - if (!state.isLocked) { - if (state.currentProgress > 0f) { - state.onPredictiveBackEnd() - } else { - state.onHomeButtonPress() - } - } else { - activity.onBackPressedDispatcher.onBackPressed() - } - } else if (pauseTime > 0L && System.currentTimeMillis() - pauseTime > 5000L) { + if (pauseTime > 0L && System.currentTimeMillis() - pauseTime > 5000L) { if (!state.isLocked) { state.reset() searchVM.reset() diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreen.kt index 946ea060..9267d9d4 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreen.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreen.kt @@ -208,29 +208,6 @@ fun GestureSettingsScreen() { appIcon = longPressAppIcon, onAppChanged = { viewModel.setLongPressApp(it) } ) - - val homeButton by viewModel.homeButton.collectAsStateWithLifecycle(null) - AnimatedVisibility(hasPermission == false && requiresAccessibilityService(homeButton)) { - MissingPermissionBanner( - modifier = Modifier.padding(16.dp), - text = stringResource(R.string.missing_permission_accessibility_gesture_settings), - onClick = { viewModel.requestPermission(context as AppCompatActivity) } - ) - } - val homeButtonApp by viewModel.homeButtonApp.collectAsState(null) - val homeButtonAppIcon by remember(homeButtonApp?.key) { - viewModel.getIcon(homeButtonApp, appIconSize.toInt()) - }.collectAsState(null) - GesturePreference( - title = stringResource(R.string.preference_gesture_home_button), - icon = Icons.Rounded.Home, - value = homeButton, - onValueChanged = { viewModel.setHomeButton(it) }, - options = options, - app = homeButtonApp, - appIcon = homeButtonAppIcon, - onAppChanged = { viewModel.setHomeButtonApp(it) } - ) } } } diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreenVM.kt index 1471af46..69f31611 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreenVM.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/gestures/GestureSettingsScreenVM.kt @@ -7,7 +7,6 @@ import de.mm20.launcher2.icons.IconService import de.mm20.launcher2.icons.LauncherIcon import de.mm20.launcher2.permissions.PermissionGroup import de.mm20.launcher2.permissions.PermissionsManager -import de.mm20.launcher2.preferences.BaseLayout import de.mm20.launcher2.preferences.GestureAction import de.mm20.launcher2.preferences.ui.GestureSettings import de.mm20.launcher2.preferences.ui.UiSettings @@ -20,7 +19,6 @@ import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn -import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -46,8 +44,6 @@ class GestureSettingsScreenVM : ViewModel(), KoinComponent { .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null) val longPress = gestureSettings.longPress .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null) - val homeButton = gestureSettings.homeButton - .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null) fun setSwipeDown(action: GestureAction) { gestureSettings.setSwipeDown(action) @@ -73,10 +69,6 @@ class GestureSettingsScreenVM : ViewModel(), KoinComponent { gestureSettings.setLongPress(action) } - fun setHomeButton(action: GestureAction) { - gestureSettings.setHomeButton(action) - } - val swipeLeftApp: Flow = swipeLeft .flatMapLatest { if (it !is GestureAction.Launch || it.key == null) flowOf(null) @@ -161,21 +153,6 @@ class GestureSettingsScreenVM : ViewModel(), KoinComponent { setDoubleTap(GestureAction.Launch(searchable.key)) } - val homeButtonApp: Flow = homeButton - .flatMapLatest { - if (it !is GestureAction.Launch || it.key == null) flowOf(null) - else searchableRepository.getByKeys(listOf(it.key!!)).map { - it.firstOrNull() - } - } - .stateIn(viewModelScope, SharingStarted.WhileSubscribed(stopTimeoutMillis = 10000), null) - - fun setHomeButtonApp(searchable: SavableSearchable?) { - searchable?.let { searchableRepository.insert(it) } ?: return - setHomeButton(GestureAction.Launch(searchable.key)) - } - - fun requestPermission(context: AppCompatActivity) { permissionsManager.requestPermission(context, PermissionGroup.Accessibility) } diff --git a/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt b/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt index 4e1d4d4d..efde951b 100644 --- a/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt +++ b/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt @@ -133,7 +133,6 @@ data class LauncherSettingsData internal constructor( val gesturesSwipeUp: GestureAction = GestureAction.Widgets, val gesturesDoubleTap: GestureAction = GestureAction.ScreenLock, val gesturesLongPress: GestureAction = GestureAction.NoAction, - val gesturesHomeButton: GestureAction = GestureAction.NoAction, val animationsCharging: Boolean = true, diff --git a/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/GestureSettings.kt b/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/GestureSettings.kt index e8d6fe4e..5efea071 100644 --- a/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/GestureSettings.kt +++ b/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/GestureSettings.kt @@ -13,7 +13,6 @@ data class GestureSettingsData( val swipeUp: GestureAction, val doubleTap: GestureAction, val longPress: GestureAction, - val homeButton: GestureAction, ) class GestureSettings internal constructor( @@ -27,7 +26,6 @@ class GestureSettings internal constructor( swipeUp = it.gesturesSwipeUp, doubleTap = it.gesturesDoubleTap, longPress = it.gesturesLongPress, - homeButton = it.gesturesHomeButton, ) }.distinctUntilChanged() ) { @@ -49,9 +47,6 @@ class GestureSettings internal constructor( val longPress: Flow = dataStore.data.map { it.gesturesLongPress } .distinctUntilChanged() - val homeButton: Flow = dataStore.data.map { it.gesturesHomeButton } - .distinctUntilChanged() - fun setSwipeDown(action: GestureAction) { dataStore.update { it.copy(gesturesSwipeDown = action) @@ -87,12 +82,4 @@ class GestureSettings internal constructor( it.copy(gesturesLongPress = action) } } - - fun setHomeButton(action: GestureAction) { - dataStore.update { - it.copy(gesturesHomeButton = action) - } - } - - } \ No newline at end of file