Show recent apps with swipe

This commit is contained in:
He4eT 2024-12-28 13:43:20 +01:00
commit 1d02aa8d78
2 changed files with 21 additions and 1 deletions

View file

@ -1196,7 +1196,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
} }
// Swipe right // Swipe right
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")) {
if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) { if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) {
canLaunchShortcut = false canLaunchShortcut = false
@ -1205,6 +1205,19 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
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")) {
if (gestureUtils.isAccessibilityServiceEnabled(
ScreenLockService::class.java
)
) {
val intent = Intent(this@MainActivity, ScreenLockService::class.java)
intent.action = "RECENTS"
startService(intent)
finishAndRemoveTask()
} else {
gestureUtils.promptEnableAccessibility()
}
}
} }
return true return true
} }

View file

@ -16,6 +16,9 @@ class ScreenLockService : AccessibilityService() {
if (intent != null && intent.action == "LOCK_SCREEN") { if (intent != null && intent.action == "LOCK_SCREEN") {
performLockScreen() performLockScreen()
} }
if (intent != null && intent.action == "RECENTS") {
performShowRecents()
}
stopSelf() stopSelf()
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }
@ -23,4 +26,8 @@ class ScreenLockService : AccessibilityService() {
private fun performLockScreen() { private fun performLockScreen() {
performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN) performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
} }
private fun performShowRecents() {
performGlobalAction(GLOBAL_ACTION_RECENTS)
}
} }