From 355692b0dafe66903ea78a963e2ec0c913025ff9 Mon Sep 17 00:00:00 2001 From: yoshiki iguchi Date: Mon, 15 Jan 2018 11:14:25 +0900 Subject: [PATCH] Add canChildBeDraggable() method to SwipeHelper's callback This callback checks the given child is actually draggable or not. This method is need for ARC, since a child may not be draggable in some cases. FYI: ag/3244118 is the CL for NYC ARC. Bug: 63874929 Bug: 62602530 Test: Compile and ran 'runtest systemui' Change-Id: I085f1c1c72240529a19e0dcb1f543e7cb36899f0 --- .../src/com/android/systemui/SwipeHelper.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 592dda073d32b..a64ce296c76c1 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; +import android.annotation.NonNull; import android.content.Context; import android.content.res.Resources; import android.graphics.RectF; @@ -316,10 +317,12 @@ public class SwipeHelper implements Gefingerpoken { float deltaPerpendicular = perpendicularPos - mPerpendicularInitialTouchPos; if (Math.abs(delta) > mPagingTouchSlop && Math.abs(delta) > Math.abs(deltaPerpendicular)) { - mCallback.onBeginDrag(mCurrView); - mDragging = true; - mInitialTouchPos = getPos(ev); - mTranslation = getTranslation(mCurrView); + if (mCallback.canChildBeDragged(mCurrView)) { + mCallback.onBeginDrag(mCurrView); + mDragging = true; + mInitialTouchPos = getPos(ev); + mTranslation = getTranslation(mCurrView); + } cancelLongPress(); } } @@ -722,5 +725,10 @@ public class SwipeHelper implements Gefingerpoken { * @return The factor the falsing threshold should be multiplied with */ float getFalsingThresholdFactor(); + + /** + * @return If true, the given view is draggable. + */ + default boolean canChildBeDragged(@NonNull View animView) { return true; } } }