From cc2e7710c824549c367d97a81a1646d27c6c8993 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Thu, 7 Apr 2022 00:02:35 +0200 Subject: [PATCH] Fixed swipe detection for low strictness --- .idea/runConfigurations.xml | 12 ------- .../com/finnmglas/launcher/HomeActivity.kt | 36 ++++++++++--------- 2 files changed, 20 insertions(+), 28 deletions(-) delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt b/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt index 2339805..ef83a3c 100644 --- a/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt @@ -156,22 +156,26 @@ class HomeActivity: UIObject, AppCompatActivity(), // strictness = opposite of sensitivity. TODO - May have to be adjusted val strictness = (4 / bufferedPointerCount) * ((100 - launcherPreferences.getInt(PREF_SLIDE_SENSITIVITY, 50)) / 50) - // Only open if the swipe was not from the phones top edge - if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100) { - if (bufferedPointerCount == 1) launch(downApp, this, R.anim.top_down) - else if (bufferedPointerCount == 2 && doubleActions) launch(doubleDownApp, this, R.anim.top_down) - } - else if (diffY > height / 8 && abs(diffY) > strictness * abs(diffX)) { - if (bufferedPointerCount == 1) launch(upApp, this, R.anim.bottom_up) - else if (bufferedPointerCount == 2 && doubleActions) launch(doubleUpApp, this, R.anim.bottom_up) - } - else if (diffX > width / 4 && abs(diffX) > strictness * abs(diffY)) { - if (bufferedPointerCount == 1) launch(leftApp,this, R.anim.right_left) - else if (bufferedPointerCount == 2 && doubleActions) launch(doubleLeftApp,this, R.anim.right_left) - } - else if (diffX < -width / 4 && abs(diffX) > strictness * abs(diffY)) { - if (bufferedPointerCount == 1) launch(rightApp, this, R.anim.left_right) - else if (bufferedPointerCount == 2 && doubleActions) launch(doubleRightApp, this, R.anim.left_right) + + if(abs(diffX) > abs(diffY)) { // horizontal swipe + if (diffX > width / 4 && abs(diffX) > strictness * abs(diffY)) { + if (bufferedPointerCount == 1) launch(leftApp,this, R.anim.right_left) + else if (bufferedPointerCount == 2 && doubleActions) launch(doubleLeftApp,this, R.anim.right_left) + } + else if (diffX < -width / 4 && abs(diffX) > strictness * abs(diffY)) { + if (bufferedPointerCount == 1) launch(rightApp, this, R.anim.left_right) + else if (bufferedPointerCount == 2 && doubleActions) launch(doubleRightApp, this, R.anim.left_right) + } + } else { // vertical swipe + // Only open if the swipe was not from the phones top edge + if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100) { + if (bufferedPointerCount == 1) launch(downApp, this, R.anim.top_down) + else if (bufferedPointerCount == 2 && doubleActions) launch(doubleDownApp, this, R.anim.top_down) + } + else if (diffY > height / 8 && abs(diffY) > strictness * abs(diffX)) { + if (bufferedPointerCount == 1) launch(upApp, this, R.anim.bottom_up) + else if (bufferedPointerCount == 2 && doubleActions) launch(doubleUpApp, this, R.anim.bottom_up) + } } return true