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

Commit 40209532 authored by Masanori Ogino's avatar Masanori Ogino
Browse files

Adjust mBiggerTouchSlopSquare to the suitable value

If the scaling factor is larger than 1.0 (i.e. 1.5),
then mTouchSlopSquare(576) is bigger than mBiggerTouchSlopSquare(400).
The double tap condition should be bigger than a single tap's one.
This causes the fail of the following CTS test cases in the device has
over 240 density.
- android.view.cts.GestureDetectorTest
  * testOnTouchEvent
- android.view.cts.GestureDetector_SimpleOnGestureListenerTest
  * testSimpleOnGestureListener
To fix this issue, I'll add a new public method
ViewConfiguration#getScaledLargeTouchSlop() then the value returned
from that method is used as a slop area of mLargeTouchSlop.

Change-Id: I0e61c13670e1300be1ccf45a89ef89410496fb48
parent a220a297
Loading
Loading
Loading
Loading

api/current.xml

100644 → 100755
+11 −0
Original line number Original line Diff line number Diff line
@@ -190704,6 +190704,17 @@
 visibility="public"
 visibility="public"
>
>
</method>
</method>
<method name="getScaledLargeTouchSlop"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getScaledMaximumDrawingCacheSize"
<method name="getScaledMaximumDrawingCacheSize"
 return="int"
 return="int"
 abstract="false"
 abstract="false"
+6 −5
Original line number Original line Diff line number Diff line
@@ -193,10 +193,8 @@ public class GestureDetector {
        }
        }
    }
    }


    // TODO: ViewConfiguration
    private int mBiggerTouchSlopSquare = 20 * 20;

    private int mTouchSlopSquare;
    private int mTouchSlopSquare;
    private int mLargeTouchSlopSquare;
    private int mDoubleTapSlopSquare;
    private int mDoubleTapSlopSquare;
    private int mMinimumFlingVelocity;
    private int mMinimumFlingVelocity;
    private int mMaximumFlingVelocity;
    private int mMaximumFlingVelocity;
@@ -384,10 +382,11 @@ public class GestureDetector {
        mIgnoreMultitouch = ignoreMultitouch;
        mIgnoreMultitouch = ignoreMultitouch;


        // Fallback to support pre-donuts releases
        // Fallback to support pre-donuts releases
        int touchSlop, doubleTapSlop;
        int touchSlop, largeTouchSlop, doubleTapSlop;
        if (context == null) {
        if (context == null) {
            //noinspection deprecation
            //noinspection deprecation
            touchSlop = ViewConfiguration.getTouchSlop();
            touchSlop = ViewConfiguration.getTouchSlop();
            largeTouchSlop = touchSlop + 2;
            doubleTapSlop = ViewConfiguration.getDoubleTapSlop();
            doubleTapSlop = ViewConfiguration.getDoubleTapSlop();
            //noinspection deprecation
            //noinspection deprecation
            mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
            mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
@@ -395,11 +394,13 @@ public class GestureDetector {
        } else {
        } else {
            final ViewConfiguration configuration = ViewConfiguration.get(context);
            final ViewConfiguration configuration = ViewConfiguration.get(context);
            touchSlop = configuration.getScaledTouchSlop();
            touchSlop = configuration.getScaledTouchSlop();
            largeTouchSlop = configuration.getScaledLargeTouchSlop();
            doubleTapSlop = configuration.getScaledDoubleTapSlop();
            doubleTapSlop = configuration.getScaledDoubleTapSlop();
            mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
            mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
            mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
            mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
        }
        }
        mTouchSlopSquare = touchSlop * touchSlop;
        mTouchSlopSquare = touchSlop * touchSlop;
        mLargeTouchSlopSquare = largeTouchSlop * largeTouchSlop;
        mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
        mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
    }
    }


@@ -534,7 +535,7 @@ public class GestureDetector {
                    mHandler.removeMessages(SHOW_PRESS);
                    mHandler.removeMessages(SHOW_PRESS);
                    mHandler.removeMessages(LONG_PRESS);
                    mHandler.removeMessages(LONG_PRESS);
                }
                }
                if (distance > mBiggerTouchSlopSquare) {
                if (distance > mLargeTouchSlopSquare) {
                    mAlwaysInBiggerTapRegion = false;
                    mAlwaysInBiggerTapRegion = false;
                }
                }
            } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
            } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
+17 −0
Original line number Original line Diff line number Diff line
@@ -101,6 +101,12 @@ public class ViewConfiguration {
     */
     */
    private static final int TOUCH_SLOP = 16;
    private static final int TOUCH_SLOP = 16;
    
    
    /**
     * Distance a touch can wander before we think the user is the first touch
     * in a sequence of double tap
     */
    private static final int LARGE_TOUCH_SLOP = 18;

    /**
    /**
     * Distance a touch can wander before we think the user is attempting a paged scroll
     * Distance a touch can wander before we think the user is attempting a paged scroll
     * (in dips)
     * (in dips)
@@ -156,6 +162,7 @@ public class ViewConfiguration {
    private final int mMaximumFlingVelocity;
    private final int mMaximumFlingVelocity;
    private final int mScrollbarSize;
    private final int mScrollbarSize;
    private final int mTouchSlop;
    private final int mTouchSlop;
    private final int mLargeTouchSlop;
    private final int mPagingTouchSlop;
    private final int mPagingTouchSlop;
    private final int mDoubleTapSlop;
    private final int mDoubleTapSlop;
    private final int mWindowTouchSlop;
    private final int mWindowTouchSlop;
@@ -177,6 +184,7 @@ public class ViewConfiguration {
        mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
        mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
        mScrollbarSize = SCROLL_BAR_SIZE;
        mScrollbarSize = SCROLL_BAR_SIZE;
        mTouchSlop = TOUCH_SLOP;
        mTouchSlop = TOUCH_SLOP;
        mLargeTouchSlop = LARGE_TOUCH_SLOP;
        mPagingTouchSlop = PAGING_TOUCH_SLOP;
        mPagingTouchSlop = PAGING_TOUCH_SLOP;
        mDoubleTapSlop = DOUBLE_TAP_SLOP;
        mDoubleTapSlop = DOUBLE_TAP_SLOP;
        mWindowTouchSlop = WINDOW_TOUCH_SLOP;
        mWindowTouchSlop = WINDOW_TOUCH_SLOP;
@@ -206,6 +214,7 @@ public class ViewConfiguration {
        mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
        mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
        mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
        mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
        mTouchSlop = (int) (density * TOUCH_SLOP + 0.5f);
        mTouchSlop = (int) (density * TOUCH_SLOP + 0.5f);
        mLargeTouchSlop =  (int) (density * LARGE_TOUCH_SLOP + 0.5f);
        mPagingTouchSlop = (int) (density * PAGING_TOUCH_SLOP + 0.5f);
        mPagingTouchSlop = (int) (density * PAGING_TOUCH_SLOP + 0.5f);
        mDoubleTapSlop = (int) (density * DOUBLE_TAP_SLOP + 0.5f);
        mDoubleTapSlop = (int) (density * DOUBLE_TAP_SLOP + 0.5f);
        mWindowTouchSlop = (int) (density * WINDOW_TOUCH_SLOP + 0.5f);
        mWindowTouchSlop = (int) (density * WINDOW_TOUCH_SLOP + 0.5f);
@@ -366,6 +375,14 @@ public class ViewConfiguration {
        return mTouchSlop;
        return mTouchSlop;
    }
    }
    
    
    /**
     * @return Distance a touch can wander before we think the user is the first touch
     *         in a sequence of double tap
     */
    public int getScaledLargeTouchSlop() {
        return mLargeTouchSlop;
    }

    /**
    /**
     * @return Distance a touch can wander before we think the user is scrolling a full page
     * @return Distance a touch can wander before we think the user is scrolling a full page
     *         in dips
     *         in dips