Improved horizontal swiping

This commit is contained in:
ottoptj 2024-09-24 15:52:19 +03:00
commit 75d90e3b1c

View file

@ -1039,8 +1039,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
} }
// Swipe left // 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) { if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) {
canLaunchShortcut = false
launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null) launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null)
} else { } else {
Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show() Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show()
@ -1049,8 +1050,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
// Swipe right // 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) { if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) {
canLaunchShortcut = false
launcherApps.startMainActivity(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!], null, null) launcherApps.startMainActivity(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!], null, null)
} else { } else {
Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show() Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show()