Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed swipe detection for low strictness #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

36 changes: 20 additions & 16 deletions app/src/main/java/com/finnmglas/launcher/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down