From 75d90e3b1c0fda0b432b6417af1235a3da997378 Mon Sep 17 00:00:00 2001 From: ottoptj Date: Tue, 24 Sep 2024 15:52:19 +0300 Subject: [PATCH] Improved horizontal swiping --- app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 54ec718..9e79569 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -1039,8 +1039,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh } // Swipe left - else if (deltaX < -swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){ + else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){ if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) { + canLaunchShortcut = false launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null) } else { Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show() @@ -1049,8 +1050,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh // Swipe right - else if (deltaX > -swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("right")) { + else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("right")) { if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) { + canLaunchShortcut = false launcherApps.startMainActivity(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!], null, null) } else { Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show()