From 20efc7135483d2f3ad51f27ccd41e1b730aa3975 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 18 Sep 2022 22:32:11 +0200 Subject: [PATCH] ignore move gestures after long pressing the desktop --- .../simplemobiletools/launcher/activities/MainActivity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 4bc668b..79c2fb4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -40,6 +40,7 @@ class MainActivity : SimpleActivity(), FlingListener { private var mCurrentFragmentY = 0 private var mScreenHeight = 0 private var mIgnoreUpEvent = false + private var mIgnoreMoveEvents = false private lateinit var mDetector: GestureDetectorCompat override fun onCreate(savedInstanceState: Bundle?) { @@ -108,7 +109,7 @@ class MainActivity : SimpleActivity(), FlingListener { } MotionEvent.ACTION_MOVE -> { - if (mTouchDownY != -1) { + if (mTouchDownY != -1 && !mIgnoreMoveEvents) { val diffY = mTouchDownY - event.y val newY = mCurrentFragmentY - diffY all_apps_fragment.y = Math.min(Math.max(0f, newY), mScreenHeight.toFloat()) @@ -118,6 +119,7 @@ class MainActivity : SimpleActivity(), FlingListener { MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> { mTouchDownY = -1 + mIgnoreMoveEvents = false if (!mIgnoreUpEvent) { if (all_apps_fragment.y < mScreenHeight * 0.7) { showFragment(all_apps_fragment) @@ -162,6 +164,7 @@ class MainActivity : SimpleActivity(), FlingListener { return } + mIgnoreMoveEvents = true main_holder.performHapticFeedback() val clickedPackageName = home_screen_grid.gridClicked(x - home_screen_grid.marginLeft, y - home_screen_grid.marginTop) if (clickedPackageName.isNotEmpty()) {