diff --git a/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt index 14e04d5..7875473 100644 --- a/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt @@ -69,23 +69,10 @@ class HomeActivity : UIObject, AppCompatActivity() { LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f ) - - // Initialise layout binding = HomeBinding.inflate(layoutInflater) - setContentView(binding.root) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - binding.root.setOnApplyWindowInsetsListener { _, windowInsets -> - val insets = windowInsets.systemGestureInsets - touchGestureDetector.setSystemGestureInsets(insets) - - windowInsets - } - } - - // Handle back key / gesture on Android 13+, cf. onKeyDown() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { diff --git a/app/src/main/java/de/jrpie/android/launcher/ui/TouchGestureDetector.kt b/app/src/main/java/de/jrpie/android/launcher/ui/TouchGestureDetector.kt index 9000fa8..74b8351 100644 --- a/app/src/main/java/de/jrpie/android/launcher/ui/TouchGestureDetector.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/TouchGestureDetector.kt @@ -1,13 +1,10 @@ package de.jrpie.android.launcher.ui import android.content.Context -import android.graphics.Insets -import android.os.Build import android.os.Handler import android.os.Looper import android.view.MotionEvent import android.view.ViewConfiguration -import androidx.annotation.RequiresApi import de.jrpie.android.launcher.actions.Gesture import de.jrpie.android.launcher.preferences.LauncherPreferences import kotlin.math.abs @@ -34,29 +31,20 @@ class TouchGestureDetector( private val longPressHandler = Handler(Looper.getMainLooper()) - private var systemGestureInsetTop = 100 - private var systemGestureInsetBottom = 0 - private var systemGestureInsetLeft = 0 - private var systemGestureInsetRight = 0 - data class Vector(val x: Float, val y: Float) { fun absSquared(): Float { return this.x * this.x + this.y * this.y } - fun plus(vector: Vector): Vector { return Vector(this.x + vector.x, this.y + vector.y) } - fun max(other: Vector): Vector { return Vector(max(this.x, other.x), max(this.y, other.y)) } - fun min(other: Vector): Vector { return Vector(min(this.x, other.x), min(this.y, other.y)) } - operator fun minus(vector: Vector): Vector { return Vector(this.x - vector.x, this.y - vector.y) } @@ -73,35 +61,16 @@ class TouchGestureDetector( fun sizeSquared(): Float { return (max - min).absSquared() } - fun getDirection(): Vector { return last - start } - fun update(vector: Vector) { min = min.min(vector) max = max.max(vector) last = vector } } - - private fun PointerPath.startIntersectsSystemGestureInsets(): Boolean { - // ignore x, since this makes edge swipes very hard to execute - return start.y < systemGestureInsetTop - || start.y > height - systemGestureInsetBottom - } - - private fun PointerPath.intersectsSystemGestureInsets(): Boolean { - return min.x < systemGestureInsetLeft - || min.y < systemGestureInsetTop - || max.x > width - systemGestureInsetRight - || max.y > height - systemGestureInsetBottom - } - private fun PointerPath.isTap(): Boolean { - if (intersectsSystemGestureInsets()) { - return false - } return sizeSquared() < TOUCH_SLOP_SQUARE } @@ -159,8 +128,8 @@ class TouchGestureDetector( } // add new pointers - for (i in 0.. { - if (startEndMax.x + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.x) { + if(startEndMax.x + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.x) { gesture = Gesture.SWIPE_LARGER } else if (startEndMin.x - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.x) { gesture = Gesture.SWIPE_SMALLER } } - Gesture.SWIPE_UP -> { - if (startEndMax.x + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.x) { + if(startEndMax.x + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.x) { gesture = Gesture.SWIPE_LARGER_REVERSE } else if (startEndMin.x - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.x) { gesture = Gesture.SWIPE_SMALLER_REVERSE } } - Gesture.SWIPE_RIGHT -> { - if (startEndMax.y + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.y) { + if(startEndMax.y + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.y) { gesture = Gesture.SWIPE_V } else if (startEndMin.y - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.y) { gesture = Gesture.SWIPE_LAMBDA } } - Gesture.SWIPE_LEFT -> { - if (startEndMax.y + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.y) { + if(startEndMax.y + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.y) { gesture = Gesture.SWIPE_V_REVERSE } else if (startEndMin.y - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.y) { gesture = Gesture.SWIPE_LAMBDA_REVERSE } } - - else -> {} + else -> { } } if (edgeActions) { @@ -318,12 +283,4 @@ class TouchGestureDetector( gesture?.invoke(context) } } - - @RequiresApi(Build.VERSION_CODES.Q) - fun setSystemGestureInsets(insets: Insets) { - systemGestureInsetTop = insets.top - systemGestureInsetBottom = insets.bottom - systemGestureInsetLeft = insets.left - systemGestureInsetRight = insets.right - } } \ No newline at end of file