Merge "Using correct slop for checking quickstep gesture" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-06-19 23:06:52 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 7 deletions

View File

@@ -21,7 +21,9 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import android.annotation.IntDef;
import android.content.Context;
import android.content.res.Resources;
import android.view.ViewConfiguration;
import android.view.WindowManagerPolicyConstants;
import com.android.internal.policy.ScreenDecorationsUtils;
@@ -100,6 +102,18 @@ public class QuickStepContract {
return str.toString();
}
/**
* Ratio of quickstep touch slop (when system takes over the touch) to view touch slop
*/
public static final float QUICKSTEP_TOUCH_SLOP_RATIO = 3;
/**
* Touch slop for quickstep gesture
*/
public static final float getQuickStepTouchSlopPx(Context context) {
return QUICKSTEP_TOUCH_SLOP_RATIO * ViewConfiguration.get(context).getScaledTouchSlop();
}
/**
* Touch slopes and thresholds for quick step operations. Drag slop is the point where the
* home button press/long press over are ignored and will start to drag when exceeded and the

View File

@@ -249,13 +249,8 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
x = (int)ev.getRawX();
y = (int)ev.getRawY();
boolean exceededTouchSlopX = Math.abs(x - mTouchDownX) > (mIsVertical
? QuickStepContract.getQuickScrubTouchSlopPx()
: QuickStepContract.getQuickStepTouchSlopPx());
boolean exceededTouchSlopY = Math.abs(y - mTouchDownY) > (mIsVertical
? QuickStepContract.getQuickStepTouchSlopPx()
: QuickStepContract.getQuickScrubTouchSlopPx());
if (exceededTouchSlopX || exceededTouchSlopY) {
float slop = QuickStepContract.getQuickStepTouchSlopPx(getContext());
if (Math.abs(x - mTouchDownX) > slop || Math.abs(y - mTouchDownY) > slop) {
// When quick step is enabled, prevent animating the ripple triggered by
// setPressed and decide to run it on touch up
setPressed(false);