From 8794f7ca23bfd5679787ca8f4af578c382a3b0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 20 Jul 2023 12:40:28 +0200 Subject: [PATCH] Decrease move gesture sensitivity --- .../launcher/activities/MainActivity.kt | 101 ++++++++++++++++-- .../launcher/views/HomeScreenGrid.kt | 2 +- app/src/main/res/values/dimens.xml | 2 +- 3 files changed, 95 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt index f0d4661..e8c72af 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -93,7 +93,7 @@ class MainActivity : SimpleActivity(), FlingListener { mScreenHeight = realScreenSize.y mAllAppsFragmentY = mScreenHeight mWidgetsFragmentY = mScreenHeight - mMoveGestureThreshold = resources.getDimension(R.dimen.move_gesture_threshold).toInt() + mMoveGestureThreshold = resources.getDimensionPixelSize(R.dimen.move_gesture_threshold) arrayOf(all_apps_fragment as MyFragment, widgets_fragment as MyFragment).forEach { fragment -> fragment.setupFragment(this) @@ -338,7 +338,7 @@ class MainActivity : SimpleActivity(), FlingListener { home_screen_grid.draggedItemMoved(event.x.toInt(), event.y.toInt()) } - if (mTouchDownY != -1 && !mIgnoreMoveEvents) { + if (hasFingerMoved && !mIgnoreMoveEvents) { val diffY = mTouchDownY - event.y if (isWidgetsFragmentExpanded()) { @@ -384,7 +384,7 @@ class MainActivity : SimpleActivity(), FlingListener { // some devices ACTION_MOVE keeps triggering for the whole long press duration, but we are interested in real moves only, when coords change private fun hasFingerMoved(event: MotionEvent) = mTouchDownX != -1 && mTouchDownY != -1 && - (Math.abs(mTouchDownX - event.x) > mMoveGestureThreshold) || (Math.abs(mTouchDownY - event.y) > mMoveGestureThreshold) + ((Math.abs(mTouchDownX - event.x) > mMoveGestureThreshold) || (Math.abs(mTouchDownY - event.y) > mMoveGestureThreshold)) private fun refetchLaunchers() { val launchers = getAllAppLaunchers() @@ -765,7 +765,24 @@ class MainActivity : SimpleActivity(), FlingListener { val defaultDialerPackage = (getSystemService(Context.TELECOM_SERVICE) as TelecomManager).defaultDialerPackage appLaunchers.firstOrNull { it.packageName == defaultDialerPackage }?.apply { val dialerIcon = - HomeScreenGridItem(null, 0, config.homeRowCount - 1, 0, config.homeRowCount - 1, 0, defaultDialerPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null, true) + HomeScreenGridItem( + null, + 0, + config.homeRowCount - 1, + 0, + config.homeRowCount - 1, + 0, + defaultDialerPackage, + "", + title, + ITEM_TYPE_ICON, + "", + -1, + "", + "", + null, + true + ) homeScreenGridItems.add(dialerIcon) } } catch (e: Exception) { @@ -775,7 +792,24 @@ class MainActivity : SimpleActivity(), FlingListener { val defaultSMSMessengerPackage = Telephony.Sms.getDefaultSmsPackage(this) appLaunchers.firstOrNull { it.packageName == defaultSMSMessengerPackage }?.apply { val SMSMessengerIcon = - HomeScreenGridItem(null, 1, config.homeRowCount - 1, 1, config.homeRowCount - 1, 0, defaultSMSMessengerPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null, true) + HomeScreenGridItem( + null, + 1, + config.homeRowCount - 1, + 1, + config.homeRowCount - 1, + 0, + defaultSMSMessengerPackage, + "", + title, + ITEM_TYPE_ICON, + "", + -1, + "", + "", + null, + true + ) homeScreenGridItems.add(SMSMessengerIcon) } } catch (e: Exception) { @@ -787,7 +821,24 @@ class MainActivity : SimpleActivity(), FlingListener { val defaultBrowserPackage = resolveInfo!!.activityInfo.packageName appLaunchers.firstOrNull { it.packageName == defaultBrowserPackage }?.apply { val browserIcon = - HomeScreenGridItem(null, 2, config.homeRowCount - 1, 2, config.homeRowCount - 1, 0, defaultBrowserPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null, true) + HomeScreenGridItem( + null, + 2, + config.homeRowCount - 1, + 2, + config.homeRowCount - 1, + 0, + defaultBrowserPackage, + "", + title, + ITEM_TYPE_ICON, + "", + -1, + "", + "", + null, + true + ) homeScreenGridItems.add(browserIcon) } } catch (e: Exception) { @@ -798,7 +849,24 @@ class MainActivity : SimpleActivity(), FlingListener { val storePackage = potentialStores.firstOrNull { isPackageInstalled(it) && appLaunchers.map { it.packageName }.contains(it) } if (storePackage != null) { appLaunchers.firstOrNull { it.packageName == storePackage }?.apply { - val storeIcon = HomeScreenGridItem(null, 3, config.homeRowCount - 1, 3, config.homeRowCount - 1, 0, storePackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null, true) + val storeIcon = HomeScreenGridItem( + null, + 3, + config.homeRowCount - 1, + 3, + config.homeRowCount - 1, + 0, + storePackage, + "", + title, + ITEM_TYPE_ICON, + "", + -1, + "", + "", + null, + true + ) homeScreenGridItems.add(storeIcon) } } @@ -811,7 +879,24 @@ class MainActivity : SimpleActivity(), FlingListener { val defaultCameraPackage = resolveInfo!!.activityInfo.packageName appLaunchers.firstOrNull { it.packageName == defaultCameraPackage }?.apply { val cameraIcon = - HomeScreenGridItem(null, 4, config.homeRowCount - 1, 4, config.homeRowCount - 1, 0, defaultCameraPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null, true) + HomeScreenGridItem( + null, + 4, + config.homeRowCount - 1, + 4, + config.homeRowCount - 1, + 0, + defaultCameraPackage, + "", + title, + ITEM_TYPE_ICON, + "", + -1, + "", + "", + null, + true + ) homeScreenGridItems.add(cameraIcon) } } catch (e: Exception) { diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt index f7ffda3..7a425c2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -1060,7 +1060,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel companion object { private const val ANIMATION_DURATION = 700L - private const val PAGE_CHANGE_BLOCKING_DURATION = ANIMATION_DURATION + 200L + private const val PAGE_CHANGE_BLOCKING_DURATION = ANIMATION_DURATION private const val PAGE_CHANGE_HOLD_THRESHOLD = 500L private enum class PageChangeArea { diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ef22951..233b20b 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,7 +5,7 @@ 140dp 10dp 8dp - 5dp + 20dp 4dp 1dp 4dp