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,52 +1151,78 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
val deltaY = e2.y - e1.y
|
val deltaY = e2.y - e1.y
|
||||||
val deltaX = e2.x - e1.x
|
val deltaX = e2.x - e1.x
|
||||||
|
|
||||||
// Swipe right
|
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
||||||
if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("right")) {
|
// Swipe right
|
||||||
if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) {
|
if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled(
|
||||||
canLaunchShortcut = false
|
"right"
|
||||||
appUtils.launchApp(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!])
|
)
|
||||||
} else {
|
) {
|
||||||
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
|
if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) {
|
||||||
}
|
canLaunchShortcut = false
|
||||||
}
|
appUtils.launchApp(
|
||||||
else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && !sharedPreferenceManager.isGestureEnabled("right")) {
|
rightSwipeActivity.first!!.componentName,
|
||||||
canLaunchShortcut = false
|
launcherApps.profiles[rightSwipeActivity.second!!]
|
||||||
if (gestureUtils.isAccessibilityServiceEnabled(
|
)
|
||||||
ScreenLockService::class.java
|
} else {
|
||||||
|
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"
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
val intent = Intent(this@MainActivity, ScreenLockService::class.java)
|
|
||||||
intent.action = "RECENTS"
|
|
||||||
startService(intent)
|
|
||||||
finishAndRemoveTask()
|
|
||||||
} else {
|
|
||||||
gestureUtils.promptEnableAccessibility()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swipe up
|
|
||||||
else if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
|
||||||
canLaunchShortcut = false
|
|
||||||
openAppMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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")
|
|
||||||
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
|
canLaunchShortcut = false
|
||||||
appUtils.launchApp(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!])
|
if (gestureUtils.isAccessibilityServiceEnabled(
|
||||||
} else {
|
ScreenLockService::class.java
|
||||||
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
|
)
|
||||||
|
) {
|
||||||
|
val intent = Intent(this@MainActivity, ScreenLockService::class.java)
|
||||||
|
intent.action = "RECENTS"
|
||||||
|
startService(intent)
|
||||||
|
finishAndRemoveTask()
|
||||||
|
} else {
|
||||||
|
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
|
||||||
|
if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||||
|
canLaunchShortcut = false
|
||||||
|
openAppMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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")
|
||||||
|
expandMethod.invoke(statusBarService)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue