Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bc30d31 authored by Adam Powell's avatar Adam Powell
Browse files

Change behavior of multitouch in scrolling views.

New pointers touching the screen always become the active pointer.

Still to do: allow flings until another pointer moves enough to stop
it. Currently flings will be immediately stopped by the other pointers
still contacting the screen.

Change-Id: Ic1c7bf98dcf40252593cec0ab1f0d524aaeed8e4
parent 4fdc6ebb
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -3241,6 +3241,27 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mLastY = y;
            break;
        }

        case MotionEvent.ACTION_POINTER_DOWN: {
            // New pointers take over dragging duties
            final int index = ev.getActionIndex();
            final int id = ev.getPointerId(index);
            final int x = (int) ev.getX(index);
            final int y = (int) ev.getY(index);
            mMotionCorrection = 0;
            mActivePointerId = id;
            mMotionX = x;
            mMotionY = y;
            final int motionPosition = pointToPosition(x, y);
            if (motionPosition >= 0) {
                // Remember where the motion event started
                v = getChildAt(motionPosition - mFirstPosition);
                mMotionViewOriginalTop = v.getTop();
                mMotionPosition = motionPosition;
            }
            mLastY = y;
            break;
        }
        }

        return true;
@@ -3412,9 +3433,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mMotionY = (int) ev.getY(newPointerIndex);
            mMotionCorrection = 0;
            mActivePointerId = ev.getPointerId(newPointerIndex);
            if (mVelocityTracker != null) {
                mVelocityTracker.clear();
            }
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -475,8 +475,16 @@ public class HorizontalScrollView extends FrameLayout {
                    invalidate();
                }
                break;
            case MotionEvent.ACTION_POINTER_DOWN: {
                final int index = ev.getActionIndex();
                final float x = ev.getX(index);
                mLastMotionX = x;
                mActivePointerId = ev.getPointerId(index);
                break;
            }
            case MotionEvent.ACTION_POINTER_UP:
                onSecondaryPointerUp(ev);
                mLastMotionX = ev.getX(ev.findPointerIndex(mActivePointerId));
                break;
        }

+8 −0
Original line number Diff line number Diff line
@@ -607,8 +607,16 @@ public class ScrollView extends FrameLayout {
                    endDrag();
                }
                break;
            case MotionEvent.ACTION_POINTER_DOWN: {
                final int index = ev.getActionIndex();
                final float y = ev.getY(index);
                mLastMotionY = y;
                mActivePointerId = ev.getPointerId(index);
                break;
            }
            case MotionEvent.ACTION_POINTER_UP:
                onSecondaryPointerUp(ev);
                mLastMotionY = ev.getY(ev.findPointerIndex(mActivePointerId));
                break;
        }
        return true;