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

@ -1205,6 +1205,19 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
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
}

View file

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