mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
fix #54
This commit is contained in:
parent
77800b27c3
commit
b6965b0b10
1 changed files with 8 additions and 4 deletions
|
@ -8,6 +8,7 @@ import android.util.DisplayMetrics
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.ViewConfiguration
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.GestureDetectorCompat
|
import androidx.core.view.GestureDetectorCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -200,17 +201,20 @@ class HomeActivity : UIObject, AppCompatActivity(),
|
||||||
val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe()
|
val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe()
|
||||||
val edgeStrictness = 0.15
|
val edgeStrictness = 0.15
|
||||||
|
|
||||||
|
val threshold = ViewConfiguration.get(this).scaledTouchSlop
|
||||||
|
|
||||||
var gesture = if (abs(diffX) > abs(diffY)) { // horizontal swipe
|
var gesture = if (abs(diffX) > abs(diffY)) { // horizontal swipe
|
||||||
if (diffX > width / 4)
|
if (diffX > threshold)
|
||||||
Gesture.SWIPE_LEFT
|
Gesture.SWIPE_LEFT
|
||||||
else if (diffX < -width / 4)
|
else if (diffX < -threshold)
|
||||||
Gesture.SWIPE_RIGHT
|
Gesture.SWIPE_RIGHT
|
||||||
else null
|
else null
|
||||||
} else { // vertical swipe
|
} else { // vertical swipe
|
||||||
// Only open if the swipe was not from the phones top edge
|
// Only open if the swipe was not from the phones top edge
|
||||||
if (diffY < -height / 8 && e1.y > 100)
|
// TODO: replace 100px by sensible dp value (e.g. twice the height of the status bar)
|
||||||
|
if (diffY < -threshold && e1.y > 100)
|
||||||
Gesture.SWIPE_DOWN
|
Gesture.SWIPE_DOWN
|
||||||
else if (diffY > height / 8)
|
else if (diffY > threshold)
|
||||||
Gesture.SWIPE_UP
|
Gesture.SWIPE_UP
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue