Loading quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java +6 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.MotionEvent.ACTION_POINTER_DOWN; import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPLEFT; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPRIGHT; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.FLING; Loading Loading @@ -81,7 +82,7 @@ public class AssistantTouchConsumer extends DelegateInputConsumer private final float mDistThreshold; private final long mTimeThreshold; private final int mAngleThreshold; private final float mSlop; private final float mSquaredSlop; private final ISystemUiProxy mSysUiProxy; private final Context mContext; private final SwipeDetector mSwipeDetector; Loading @@ -96,7 +97,8 @@ public class AssistantTouchConsumer extends DelegateInputConsumer mDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold); mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold); mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold); mSlop = QuickStepContract.getQuickStepDragSlopPx(); float slop = QuickStepContract.getQuickStepDragSlopPx(); mSquaredSlop = slop * slop; mActivityControlHelper = activityControlHelper; mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL); mSwipeDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); Loading Loading @@ -155,7 +157,8 @@ public class AssistantTouchConsumer extends DelegateInputConsumer if (!mPassedSlop) { // Normal gesture, ensure we pass the slop before we start tracking the gesture if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSlop) { if (squaredHypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSquaredSlop) { mPassedSlop = true; mStartDragPos.set(mLastPos.x, mLastPos.y); Loading quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +5 −6 Original line number Diff line number Diff line Loading @@ -15,11 +15,13 @@ */ package com.android.quickstep.inputconsumers; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; import android.content.Context; import android.content.Intent; import android.graphics.PointF; import android.view.MotionEvent; import android.view.ViewConfiguration; /** * A dummy input consumer used when the device is still locked, e.g. from secure camera. Loading @@ -32,8 +34,7 @@ public class DeviceLockedInputConsumer implements InputConsumer { public DeviceLockedInputConsumer(Context context) { mContext = context; float touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mTouchSlopSquared = touchSlop * touchSlop; mTouchSlopSquared = squaredTouchSlop(context); } @Override Loading @@ -48,9 +49,7 @@ public class DeviceLockedInputConsumer implements InputConsumer { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mTouchDown.set(x, y); } else if (ev.getAction() == MotionEvent.ACTION_MOVE) { float xSquared = (x - mTouchDown.x) * (x - mTouchDown.x); float ySquared = (y - mTouchDown.y) * (y - mTouchDown.y); if (xSquared + ySquared > mTouchSlopSquared) { if (squaredHypot(x - mTouchDown.x, y - mTouchDown.y) > mTouchSlopSquared) { // For now, just start the home intent so user is prompted to unlock the device. mContext.startActivity(new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME) Loading quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +5 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.INVALID_POINTER_ID; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE; import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE; import static com.android.launcher3.util.RaceConditionTracker.ENTER; Loading Loading @@ -109,7 +110,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC private int mActivePointerId = INVALID_POINTER_ID; private final float mDragSlop; private final float mTouchSlop; private final float mSquaredTouchSlop; // Slop used to check when we start moving window. private boolean mPassedDragSlop; Loading Loading @@ -157,7 +158,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mDisplayRotation = getSystemService(WindowManager.class).getDefaultDisplay().getRotation(); mDragSlop = QuickStepContract.getQuickStepDragSlopPx(); mTouchSlop = QuickStepContract.getQuickStepTouchSlopPx(); float slop = QuickStepContract.getQuickStepTouchSlopPx(); mSquaredTouchSlop = slop * slop; mPassedTouchSlop = mPassedDragSlop = continuingPreviousGesture; } Loading Loading @@ -256,7 +258,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC } if (!mPassedTouchSlop) { if (Math.hypot(displacementX, mLastPos.y - mDownPos.y) >= mTouchSlop) { if (squaredHypot(displacementX, mLastPos.y - mDownPos.y) >= mSquaredTouchSlop) { mPassedTouchSlop = true; if (mIsDeferredDownTarget) { Loading quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +6 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; import static com.android.launcher3.anim.Interpolators.ACCEL; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; Loading Loading @@ -281,7 +283,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl private boolean mHandleTaskStackChanges; private boolean mSwipeDownShouldLaunchApp; private boolean mTouchDownToStartHome; private final int mTouchSlop; private final float mSquaredTouchSlop; private int mDownX; private int mDownY; Loading Loading @@ -339,7 +341,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); mTaskTopMargin = getResources() .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mSquaredTouchSlop = squaredTouchSlop(context); mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents); mEmptyIcon.setCallback(this); Loading Loading @@ -496,7 +498,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl case MotionEvent.ACTION_MOVE: // Passing the touch slop will not allow dismiss to home if (mTouchDownToStartHome && (isHandlingTouch() || Math.hypot(mDownX - x, mDownY - y) > mTouchSlop)) { (isHandlingTouch() || squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop)) { mTouchDownToStartHome = false; } break; Loading src/com/android/launcher3/Utilities.java +10 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ import android.util.Pair; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.animation.Interpolator; import com.android.launcher3.compat.LauncherAppsCompat; Loading Loading @@ -726,6 +727,15 @@ public final class Utilities { return str.toString(); } public static float squaredHypot(float x, float y) { return x * x + y * y; } public static float squaredTouchSlop(Context context) { float slop = ViewConfiguration.get(context).getScaledTouchSlop(); return slop * slop; } private static class FixedSizeEmptyDrawable extends ColorDrawable { private final int mSize; Loading Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java +6 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.MotionEvent.ACTION_POINTER_DOWN; import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPLEFT; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPRIGHT; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.FLING; Loading Loading @@ -81,7 +82,7 @@ public class AssistantTouchConsumer extends DelegateInputConsumer private final float mDistThreshold; private final long mTimeThreshold; private final int mAngleThreshold; private final float mSlop; private final float mSquaredSlop; private final ISystemUiProxy mSysUiProxy; private final Context mContext; private final SwipeDetector mSwipeDetector; Loading @@ -96,7 +97,8 @@ public class AssistantTouchConsumer extends DelegateInputConsumer mDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold); mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold); mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold); mSlop = QuickStepContract.getQuickStepDragSlopPx(); float slop = QuickStepContract.getQuickStepDragSlopPx(); mSquaredSlop = slop * slop; mActivityControlHelper = activityControlHelper; mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL); mSwipeDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); Loading Loading @@ -155,7 +157,8 @@ public class AssistantTouchConsumer extends DelegateInputConsumer if (!mPassedSlop) { // Normal gesture, ensure we pass the slop before we start tracking the gesture if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSlop) { if (squaredHypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSquaredSlop) { mPassedSlop = true; mStartDragPos.set(mLastPos.x, mLastPos.y); Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +5 −6 Original line number Diff line number Diff line Loading @@ -15,11 +15,13 @@ */ package com.android.quickstep.inputconsumers; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; import android.content.Context; import android.content.Intent; import android.graphics.PointF; import android.view.MotionEvent; import android.view.ViewConfiguration; /** * A dummy input consumer used when the device is still locked, e.g. from secure camera. Loading @@ -32,8 +34,7 @@ public class DeviceLockedInputConsumer implements InputConsumer { public DeviceLockedInputConsumer(Context context) { mContext = context; float touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mTouchSlopSquared = touchSlop * touchSlop; mTouchSlopSquared = squaredTouchSlop(context); } @Override Loading @@ -48,9 +49,7 @@ public class DeviceLockedInputConsumer implements InputConsumer { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mTouchDown.set(x, y); } else if (ev.getAction() == MotionEvent.ACTION_MOVE) { float xSquared = (x - mTouchDown.x) * (x - mTouchDown.x); float ySquared = (y - mTouchDown.y) * (y - mTouchDown.y); if (xSquared + ySquared > mTouchSlopSquared) { if (squaredHypot(x - mTouchDown.x, y - mTouchDown.y) > mTouchSlopSquared) { // For now, just start the home intent so user is prompted to unlock the device. mContext.startActivity(new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME) Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +5 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.INVALID_POINTER_ID; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE; import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE; import static com.android.launcher3.util.RaceConditionTracker.ENTER; Loading Loading @@ -109,7 +110,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC private int mActivePointerId = INVALID_POINTER_ID; private final float mDragSlop; private final float mTouchSlop; private final float mSquaredTouchSlop; // Slop used to check when we start moving window. private boolean mPassedDragSlop; Loading Loading @@ -157,7 +158,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mDisplayRotation = getSystemService(WindowManager.class).getDefaultDisplay().getRotation(); mDragSlop = QuickStepContract.getQuickStepDragSlopPx(); mTouchSlop = QuickStepContract.getQuickStepTouchSlopPx(); float slop = QuickStepContract.getQuickStepTouchSlopPx(); mSquaredTouchSlop = slop * slop; mPassedTouchSlop = mPassedDragSlop = continuingPreviousGesture; } Loading Loading @@ -256,7 +258,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC } if (!mPassedTouchSlop) { if (Math.hypot(displacementX, mLastPos.y - mDownPos.y) >= mTouchSlop) { if (squaredHypot(displacementX, mLastPos.y - mDownPos.y) >= mSquaredTouchSlop) { mPassedTouchSlop = true; if (mIsDeferredDownTarget) { Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +6 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; import static com.android.launcher3.anim.Interpolators.ACCEL; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; Loading Loading @@ -281,7 +283,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl private boolean mHandleTaskStackChanges; private boolean mSwipeDownShouldLaunchApp; private boolean mTouchDownToStartHome; private final int mTouchSlop; private final float mSquaredTouchSlop; private int mDownX; private int mDownY; Loading Loading @@ -339,7 +341,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); mTaskTopMargin = getResources() .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mSquaredTouchSlop = squaredTouchSlop(context); mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents); mEmptyIcon.setCallback(this); Loading Loading @@ -496,7 +498,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl case MotionEvent.ACTION_MOVE: // Passing the touch slop will not allow dismiss to home if (mTouchDownToStartHome && (isHandlingTouch() || Math.hypot(mDownX - x, mDownY - y) > mTouchSlop)) { (isHandlingTouch() || squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop)) { mTouchDownToStartHome = false; } break; Loading
src/com/android/launcher3/Utilities.java +10 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ import android.util.Pair; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.animation.Interpolator; import com.android.launcher3.compat.LauncherAppsCompat; Loading Loading @@ -726,6 +727,15 @@ public final class Utilities { return str.toString(); } public static float squaredHypot(float x, float y) { return x * x + y * y; } public static float squaredTouchSlop(Context context) { float slop = ViewConfiguration.get(context).getScaledTouchSlop(); return slop * slop; } private static class FixedSizeEmptyDrawable extends ColorDrawable { private final int mSize; Loading