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

Commit 12e08f3a authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am 26cab064: Merge "Allow two finger pan and scale on touchscreens with...

am 26cab064: Merge "Allow two finger pan and scale on touchscreens with FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT." into gingerbread

Merge commit '26cab064' into gingerbread-plus-aosp

* commit '26cab064':
  Allow two finger pan and scale on touchscreens with
parents ec06144c 26cab064
Loading
Loading
Loading
Loading
+28 −13
Original line number Diff line number Diff line
@@ -463,6 +463,11 @@ public class WebView extends AbsoluteLayout
    private static final int TOUCH_DONE_MODE = 7;
    private static final int TOUCH_PINCH_DRAG = 8;

    /**
     * True if we have a touch panel capable of detecting smooth pan/scale at the same time
     */
    private boolean mAllowPanAndScale;

    // Whether to forward the touch events to WebCore
    private boolean mForwardTouchEvents = false;

@@ -976,9 +981,11 @@ public class WebView extends AbsoluteLayout

    void updateMultiTouchSupport(Context context) {
        WebSettings settings = getSettings();
        mSupportMultiTouch = context.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)
        final PackageManager pm = context.getPackageManager();
        mSupportMultiTouch = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)
                && settings.supportZoom() && settings.getBuiltInZoomControls();
        mAllowPanAndScale = pm.hasSystemFeature(
                PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
        if (mSupportMultiTouch && (mScaleDetector == null)) {
            mScaleDetector = new ScaleGestureDetector(context,
                    new ScaleDetectorListener());
@@ -5018,12 +5025,14 @@ public class WebView extends AbsoluteLayout
        // FIXME: we may consider to give WebKit an option to handle multi-touch
        // events later.
        if (mSupportMultiTouch && ev.getPointerCount() > 1) {
            if (mMinZoomScale < mMaxZoomScale) {
            if (mAllowPanAndScale || mMinZoomScale < mMaxZoomScale) {
                mScaleDetector.onTouchEvent(ev);
                if (mScaleDetector.isInProgress()) {
                    mLastTouchTime = eventTime;
                    if (!mAllowPanAndScale) {
                        return true;
                    }
                }
                x = mScaleDetector.getFocusX();
                y = mScaleDetector.getFocusY();
                action = ev.getAction() & MotionEvent.ACTION_MASK;
@@ -5224,6 +5233,11 @@ public class WebView extends AbsoluteLayout
                        mLastTouchTime = eventTime;
                        break;
                    }

                    // Only lock dragging to one axis if we don't have a scale in progress.
                    // Scaling implies free-roaming movement. Note we'll only ever get here
                    // if mAllowPanAndScale is true.
                    if (mScaleDetector != null && !mScaleDetector.isInProgress()) {
                        // if it starts nearly horizontal or vertical, enforce it
                        int ax = Math.abs(deltaX);
                        int ay = Math.abs(deltaY);
@@ -5234,6 +5248,7 @@ public class WebView extends AbsoluteLayout
                            mSnapScrollMode = SNAP_Y;
                            mSnapPositive = deltaY > 0;
                        }
                    }

                    mTouchMode = TOUCH_DRAG_MODE;
                    mLastTouchX = x;