mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
commit
649444e730
2 changed files with 31 additions and 12 deletions
|
|
@ -1170,8 +1170,31 @@ 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 (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!!])
|
||||||
|
} 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")) {
|
||||||
|
if (gestureUtils.isAccessibilityServiceEnabled(
|
||||||
|
ScreenLockService::class.java
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
val intent = Intent(this@MainActivity, ScreenLockService::class.java)
|
||||||
|
intent.action = "RECENTS"
|
||||||
|
startService(intent)
|
||||||
|
finishAndRemoveTask()
|
||||||
|
} else {
|
||||||
|
gestureUtils.promptEnableAccessibility()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Swipe up
|
// Swipe up
|
||||||
if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
else if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||||
canLaunchShortcut = false
|
canLaunchShortcut = false
|
||||||
openAppMenu()
|
openAppMenu()
|
||||||
}
|
}
|
||||||
|
|
@ -1194,17 +1217,6 @@ 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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Swipe right
|
|
||||||
else 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!!])
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue