mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Separate vertical and horizontal swipes
This commit is contained in:
parent
47091543d0
commit
796417768d
1 changed files with 65 additions and 39 deletions
|
|
@ -1151,16 +1151,29 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
val deltaY = e2.y - e1.y
|
||||
val deltaX = e2.x - e1.x
|
||||
|
||||
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
||||
// Swipe right
|
||||
if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("right")) {
|
||||
if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled(
|
||||
"right"
|
||||
)
|
||||
) {
|
||||
if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) {
|
||||
canLaunchShortcut = false
|
||||
appUtils.launchApp(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!])
|
||||
appUtils.launchApp(
|
||||
rightSwipeActivity.first!!.componentName,
|
||||
launcherApps.profiles[rightSwipeActivity.second!!]
|
||||
)
|
||||
} else {
|
||||
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
this@MainActivity,
|
||||
getString(R.string.launch_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && !sharedPreferenceManager.isGestureEnabled("right")) {
|
||||
} else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && !sharedPreferenceManager.isGestureEnabled(
|
||||
"right"
|
||||
)
|
||||
) {
|
||||
canLaunchShortcut = false
|
||||
if (gestureUtils.isAccessibilityServiceEnabled(
|
||||
ScreenLockService::class.java
|
||||
|
|
@ -1174,9 +1187,30 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
gestureUtils.promptEnableAccessibility()
|
||||
}
|
||||
}
|
||||
// Swipe left
|
||||
else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled(
|
||||
"left"
|
||||
)
|
||||
) {
|
||||
println(leftSwipeActivity)
|
||||
if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) {
|
||||
canLaunchShortcut = false
|
||||
appUtils.launchApp(
|
||||
leftSwipeActivity.first!!.componentName,
|
||||
launcherApps.profiles[leftSwipeActivity.second!!]
|
||||
)
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this@MainActivity,
|
||||
getString(R.string.launch_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Swipe up
|
||||
else if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||
if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||
canLaunchShortcut = false
|
||||
openAppMenu()
|
||||
}
|
||||
|
|
@ -1184,20 +1218,12 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
// Swipe down
|
||||
else if (deltaY > swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||
val statusBarService = getSystemService(Context.STATUS_BAR_SERVICE)
|
||||
val statusBarManager: Class<*> = Class.forName("android.app.StatusBarManager")
|
||||
val expandMethod: Method = statusBarManager.getMethod("expandNotificationsPanel")
|
||||
val statusBarManager: Class<*> =
|
||||
Class.forName("android.app.StatusBarManager")
|
||||
val expandMethod: Method =
|
||||
statusBarManager.getMethod("expandNotificationsPanel")
|
||||
expandMethod.invoke(statusBarService)
|
||||
}
|
||||
|
||||
// Swipe left
|
||||
else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){
|
||||
println(leftSwipeActivity)
|
||||
if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) {
|
||||
canLaunchShortcut = false
|
||||
appUtils.launchApp(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!])
|
||||
} else {
|
||||
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue