mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Removing use of onQuickstep event and determining the touchSlopPassed in Launcher
Bug: 124255113 Change-Id: If6fe77c7086a30775f78ec2a86251cb6bcd3c4c4
This commit is contained in:
@@ -52,8 +52,6 @@ public class MotionEventQueue {
|
||||
ACTION_VIRTUAL | (4 << ACTION_POINTER_INDEX_SHIFT);
|
||||
private static final int ACTION_SHOW_OVERVIEW_FROM_ALT_TAB =
|
||||
ACTION_VIRTUAL | (5 << ACTION_POINTER_INDEX_SHIFT);
|
||||
private static final int ACTION_QUICK_STEP =
|
||||
ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT);
|
||||
|
||||
private final InputEventDispatcher mDispatcher;
|
||||
private final InputEventReceiver mReceiver;
|
||||
@@ -98,9 +96,6 @@ public class MotionEventQueue {
|
||||
mConsumer.onShowOverviewFromAltTab();
|
||||
mConsumer.onQuickScrubStart();
|
||||
break;
|
||||
case ACTION_QUICK_STEP:
|
||||
mConsumer.onQuickStep(event);
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Invalid virtual event: " + event.getAction());
|
||||
}
|
||||
@@ -139,11 +134,6 @@ public class MotionEventQueue {
|
||||
queueVirtualAction(ACTION_QUICK_SCRUB_END, 0);
|
||||
}
|
||||
|
||||
public void onQuickStep(MotionEvent event) {
|
||||
event.setAction(ACTION_QUICK_STEP);
|
||||
queue(event);
|
||||
}
|
||||
|
||||
public void onNewGesture(@HitTarget int downHitTarget) {
|
||||
queueVirtualAction(ACTION_NEW_GESTURE, downHitTarget);
|
||||
}
|
||||
|
||||
@@ -80,21 +80,30 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
private final InputConsumerController mInputConsumer;
|
||||
private final SwipeSharedState mSwipeSharedState;
|
||||
|
||||
private final int mDisplayRotation;
|
||||
private final Rect mStableInsets = new Rect();
|
||||
|
||||
private final MotionEventQueue mEventQueue;
|
||||
private final MotionPauseDetector mMotionPauseDetector;
|
||||
private VelocityTracker mVelocityTracker;
|
||||
|
||||
private WindowTransformSwipeHandler mInteractionHandler;
|
||||
|
||||
private final boolean mIsDeferredDownTarget;
|
||||
private final PointF mDownPos = new PointF();
|
||||
private final PointF mLastPos = new PointF();
|
||||
private int mActivePointerId = INVALID_POINTER_ID;
|
||||
private boolean mPassedInitialSlop;
|
||||
// Used for non-deferred gestures to determine when to start dragging
|
||||
private int mQuickStepDragSlop;
|
||||
|
||||
private final float mDragSlop;
|
||||
private final float mTouchSlop;
|
||||
|
||||
// Slop used to check when we start moving window.
|
||||
private boolean mPassedDragSlop;
|
||||
// Slop used to determine when we say that the gesture has started.
|
||||
private boolean mPassedTouchSlop;
|
||||
|
||||
// TODO: Start displacement should have both x and y
|
||||
private float mStartDisplacement;
|
||||
private WindowTransformSwipeHandler mInteractionHandler;
|
||||
private int mDisplayRotation;
|
||||
private Rect mStableInsets = new Rect();
|
||||
|
||||
public OtherActivityTouchConsumer(Context base, RunningTaskInfo runningTaskInfo,
|
||||
RecentsModel recentsModel, Intent homeIntent, ActivityControlHelper activityControl,
|
||||
@@ -120,6 +129,15 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
mTouchInteractionLog.setTouchConsumer(this);
|
||||
mInputConsumer = inputConsumer;
|
||||
mSwipeSharedState = swipeSharedState;
|
||||
|
||||
Display display = getSystemService(WindowManager.class).getDefaultDisplay();
|
||||
mDisplayRotation = display.getRotation();
|
||||
WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);
|
||||
|
||||
mDragSlop = NavigationBarCompat.getQuickStepDragSlopPx();
|
||||
mTouchSlop = NavigationBarCompat.getQuickStepTouchSlopPx();
|
||||
// If active listener isn't null, we are continuing the previous gesture.
|
||||
mPassedTouchSlop = mPassedDragSlop = mSwipeSharedState.getActiveListener() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,9 +164,6 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
mActivePointerId = ev.getPointerId(0);
|
||||
mDownPos.set(ev.getX(), ev.getY());
|
||||
mLastPos.set(mDownPos);
|
||||
// If active listener isn't null, we are continuing the previous gesture.
|
||||
mPassedInitialSlop = mSwipeSharedState.getActiveListener() != null;
|
||||
mQuickStepDragSlop = NavigationBarCompat.getQuickStepDragSlopPx();
|
||||
|
||||
// Start the window animation on down to give more time for launcher to draw if the
|
||||
// user didn't start the gesture over the back button
|
||||
@@ -156,9 +171,6 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
startTouchTrackingForWindowAnimation(ev.getEventTime());
|
||||
}
|
||||
|
||||
Display display = getSystemService(WindowManager.class).getDefaultDisplay();
|
||||
mDisplayRotation = display.getRotation();
|
||||
WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);
|
||||
RaceConditionTracker.onEvent(DOWN_EVT, EXIT);
|
||||
break;
|
||||
}
|
||||
@@ -182,18 +194,38 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
}
|
||||
mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
|
||||
float displacement = getDisplacement(ev);
|
||||
if (!mPassedInitialSlop) {
|
||||
|
||||
if (!mPassedDragSlop) {
|
||||
if (!mIsDeferredDownTarget) {
|
||||
// Normal gesture, ensure we pass the drag slop before we start tracking
|
||||
// the gesture
|
||||
if (Math.abs(displacement) > mQuickStepDragSlop) {
|
||||
mPassedInitialSlop = true;
|
||||
if (Math.abs(displacement) > mDragSlop) {
|
||||
mPassedDragSlop = true;
|
||||
mStartDisplacement = displacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mPassedInitialSlop && mInteractionHandler != null) {
|
||||
if (!mPassedTouchSlop) {
|
||||
if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) >=
|
||||
mTouchSlop) {
|
||||
mPassedTouchSlop = true;
|
||||
|
||||
mTouchInteractionLog.startQuickStep();
|
||||
if (mIsDeferredDownTarget) {
|
||||
// Deferred gesture, start the animation and gesture tracking once
|
||||
// we pass the actual touch slop
|
||||
startTouchTrackingForWindowAnimation(ev.getEventTime());
|
||||
}
|
||||
if (!mPassedDragSlop) {
|
||||
mPassedDragSlop = true;
|
||||
mStartDisplacement = displacement;
|
||||
}
|
||||
notifyGestureStarted();
|
||||
}
|
||||
}
|
||||
|
||||
if (mPassedDragSlop && mInteractionHandler != null) {
|
||||
// Move
|
||||
dispatchMotion(ev, displacement - mStartDisplacement, null);
|
||||
|
||||
@@ -298,7 +330,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
* the animation can still be running.
|
||||
*/
|
||||
private void finishTouchTracking(MotionEvent ev) {
|
||||
if (mPassedInitialSlop && mInteractionHandler != null) {
|
||||
if (mPassedDragSlop && mInteractionHandler != null) {
|
||||
|
||||
mVelocityTracker.computeCurrentVelocity(1000,
|
||||
ViewConfiguration.get(this).getScaledMaximumFlingVelocity());
|
||||
@@ -360,11 +392,11 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
|
||||
@Override
|
||||
public void onQuickScrubStart() {
|
||||
if (!mPassedInitialSlop && mIsDeferredDownTarget && mInteractionHandler == null) {
|
||||
if (!mPassedDragSlop && mIsDeferredDownTarget && mInteractionHandler == null) {
|
||||
// If we deferred starting the window animation on touch down, then
|
||||
// start tracking now
|
||||
startTouchTrackingForWindowAnimation(SystemClock.uptimeMillis());
|
||||
mPassedInitialSlop = true;
|
||||
mPassedDragSlop = true;
|
||||
}
|
||||
|
||||
mTouchInteractionLog.startQuickScrub();
|
||||
@@ -390,21 +422,6 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickStep(MotionEvent ev) {
|
||||
mTouchInteractionLog.startQuickStep();
|
||||
if (mIsDeferredDownTarget) {
|
||||
// Deferred gesture, start the animation and gesture tracking once we pass the actual
|
||||
// touch slop
|
||||
startTouchTrackingForWindowAnimation(ev.getEventTime());
|
||||
}
|
||||
if (!mPassedInitialSlop) {
|
||||
mPassedInitialSlop = true;
|
||||
mStartDisplacement = getDisplacement(ev);
|
||||
}
|
||||
notifyGestureStarted();
|
||||
}
|
||||
|
||||
private float getDisplacement(MotionEvent ev) {
|
||||
float eventX = ev.getX();
|
||||
float eventY = ev.getY();
|
||||
|
||||
@@ -64,8 +64,6 @@ public class OverviewInteractionState {
|
||||
private final Handler mUiHandler;
|
||||
private final Handler mBgHandler;
|
||||
|
||||
private boolean mSwipeGestureInitializing = false;
|
||||
|
||||
// These are updated on the background thread
|
||||
private ISystemUiProxy mISystemUiProxy;
|
||||
private boolean mSwipeUpEnabled = true;
|
||||
@@ -177,15 +175,6 @@ public class OverviewInteractionState {
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public void setSwipeGestureInitializing(boolean swipeGestureInitializing) {
|
||||
mSwipeGestureInitializing = swipeGestureInitializing;
|
||||
}
|
||||
|
||||
public boolean swipeGestureInitializing() {
|
||||
return mSwipeGestureInitializing;
|
||||
}
|
||||
|
||||
public void notifySwipeUpSettingChanged(boolean swipeUpEnabled) {
|
||||
mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED);
|
||||
mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0).
|
||||
|
||||
247
quickstep/src/com/android/quickstep/OverviewTouchConsumer.java
Normal file
247
quickstep/src/com/android/quickstep/OverviewTouchConsumer.java
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static android.view.MotionEvent.ACTION_CANCEL;
|
||||
import static android.view.MotionEvent.ACTION_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_MOVE;
|
||||
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_POINTER_INDEX_SHIFT;
|
||||
import static android.view.MotionEvent.ACTION_UP;
|
||||
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
|
||||
/**
|
||||
* Touch consumer for handling touch on the recents/Launcher activity.
|
||||
*/
|
||||
public class OverviewTouchConsumer<T extends BaseDraggingActivity>
|
||||
implements TouchConsumer {
|
||||
|
||||
private static final String TAG = "OverviewTouchConsumer";
|
||||
|
||||
private final ActivityControlHelper<T> mActivityHelper;
|
||||
private final T mActivity;
|
||||
private final BaseDragLayer mTarget;
|
||||
private final int[] mLocationOnScreen = new int[2];
|
||||
private final PointF mDownPos = new PointF();
|
||||
private final int mTouchSlop;
|
||||
private final QuickScrubController mQuickScrubController;
|
||||
private final TouchInteractionLog mTouchInteractionLog;
|
||||
|
||||
private final boolean mStartingInActivityBounds;
|
||||
|
||||
private boolean mTrackingStarted = false;
|
||||
private boolean mInvalidated = false;
|
||||
|
||||
private float mLastProgress = 0;
|
||||
private boolean mStartPending = false;
|
||||
private boolean mEndPending = false;
|
||||
private boolean mWaitForWindowAvailable;
|
||||
|
||||
OverviewTouchConsumer(ActivityControlHelper<T> activityHelper, T activity,
|
||||
boolean startingInActivityBounds, TouchInteractionLog touchInteractionLog,
|
||||
boolean waitForWindowAvailable) {
|
||||
mActivityHelper = activityHelper;
|
||||
mActivity = activity;
|
||||
mTarget = activity.getDragLayer();
|
||||
mTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
|
||||
mStartingInActivityBounds = startingInActivityBounds;
|
||||
|
||||
mQuickScrubController = mActivity.<RecentsView>getOverviewPanel()
|
||||
.getQuickScrubController();
|
||||
mTouchInteractionLog = touchInteractionLog;
|
||||
mTouchInteractionLog.setTouchConsumer(this);
|
||||
|
||||
mWaitForWindowAvailable = waitForWindowAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MotionEvent ev) {
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
mTouchInteractionLog.addMotionEvent(ev);
|
||||
int action = ev.getActionMasked();
|
||||
if (action == ACTION_DOWN) {
|
||||
if (mStartingInActivityBounds) {
|
||||
startTouchTracking(ev, false /* updateLocationOffset */,
|
||||
false /* closeActiveWindows */);
|
||||
return;
|
||||
}
|
||||
mTrackingStarted = false;
|
||||
mDownPos.set(ev.getX(), ev.getY());
|
||||
} else if (!mTrackingStarted) {
|
||||
switch (action) {
|
||||
case ACTION_CANCEL:
|
||||
case ACTION_UP:
|
||||
startTouchTracking(ev, true /* updateLocationOffset */,
|
||||
false /* closeActiveWindows */);
|
||||
break;
|
||||
case ACTION_MOVE: {
|
||||
float displacement = mActivity.getDeviceProfile().isLandscape ?
|
||||
ev.getX() - mDownPos.x : ev.getY() - mDownPos.y;
|
||||
if (Math.abs(displacement) >= mTouchSlop) {
|
||||
// Start tracking only when mTouchSlop is crossed.
|
||||
startTouchTracking(ev, true /* updateLocationOffset */,
|
||||
true /* closeActiveWindows */);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mTrackingStarted) {
|
||||
sendEvent(ev);
|
||||
}
|
||||
|
||||
if (action == ACTION_UP || action == ACTION_CANCEL) {
|
||||
mInvalidated = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void startTouchTracking(MotionEvent ev, boolean updateLocationOffset,
|
||||
boolean closeActiveWindows) {
|
||||
if (updateLocationOffset) {
|
||||
mTarget.getLocationOnScreen(mLocationOnScreen);
|
||||
}
|
||||
|
||||
// Send down touch event
|
||||
MotionEvent down = MotionEvent.obtainNoHistory(ev);
|
||||
down.setAction(ACTION_DOWN);
|
||||
sendEvent(down);
|
||||
|
||||
mTrackingStarted = true;
|
||||
// Send pointer down for remaining pointers.
|
||||
int pointerCount = ev.getPointerCount();
|
||||
for (int i = 1; i < pointerCount; i++) {
|
||||
down.setAction(ACTION_POINTER_DOWN | (i << ACTION_POINTER_INDEX_SHIFT));
|
||||
sendEvent(down);
|
||||
}
|
||||
|
||||
down.recycle();
|
||||
|
||||
if (closeActiveWindows) {
|
||||
OverviewCallbacks.get(mActivity).closeAllWindows();
|
||||
ActivityManagerWrapper.getInstance()
|
||||
.closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
|
||||
mTouchInteractionLog.startQuickStep();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEvent(MotionEvent ev) {
|
||||
if (!mTarget.verifyTouchDispatch(this, ev)) {
|
||||
mInvalidated = true;
|
||||
return;
|
||||
}
|
||||
int flags = ev.getEdgeFlags();
|
||||
ev.setEdgeFlags(flags | TouchInteractionService.EDGE_NAV_BAR);
|
||||
ev.offsetLocation(-mLocationOnScreen[0], -mLocationOnScreen[1]);
|
||||
if (!mTrackingStarted) {
|
||||
mTarget.onInterceptTouchEvent(ev);
|
||||
}
|
||||
mTarget.onTouchEvent(ev);
|
||||
ev.offsetLocation(mLocationOnScreen[0], mLocationOnScreen[1]);
|
||||
ev.setEdgeFlags(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickScrubStart() {
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
mTouchInteractionLog.startQuickScrub();
|
||||
if (!mQuickScrubController.prepareQuickScrub(TAG)) {
|
||||
mInvalidated = true;
|
||||
mTouchInteractionLog.endQuickScrub("onQuickScrubStart");
|
||||
return;
|
||||
}
|
||||
OverviewCallbacks.get(mActivity).closeAllWindows();
|
||||
ActivityManagerWrapper.getInstance()
|
||||
.closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
|
||||
|
||||
mStartPending = true;
|
||||
Runnable action = () -> {
|
||||
if (!mQuickScrubController.prepareQuickScrub(TAG)) {
|
||||
mInvalidated = true;
|
||||
mTouchInteractionLog.endQuickScrub("onQuickScrubStart");
|
||||
return;
|
||||
}
|
||||
mActivityHelper.onQuickInteractionStart(mActivity, null, true,
|
||||
mTouchInteractionLog);
|
||||
mQuickScrubController.onQuickScrubProgress(mLastProgress);
|
||||
mStartPending = false;
|
||||
|
||||
if (mEndPending) {
|
||||
mQuickScrubController.onQuickScrubEnd();
|
||||
mEndPending = false;
|
||||
}
|
||||
};
|
||||
|
||||
if (mWaitForWindowAvailable) {
|
||||
mActivityHelper.executeOnWindowAvailable(mActivity, action);
|
||||
} else {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickScrubEnd() {
|
||||
mTouchInteractionLog.endQuickScrub("onQuickScrubEnd");
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
if (mStartPending) {
|
||||
mEndPending = true;
|
||||
} else {
|
||||
mQuickScrubController.onQuickScrubEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickScrubProgress(float progress) {
|
||||
mTouchInteractionLog.setQuickScrubProgress(progress);
|
||||
mLastProgress = progress;
|
||||
if (mInvalidated || mStartPending) {
|
||||
return;
|
||||
}
|
||||
mQuickScrubController.onQuickScrubProgress(progress);
|
||||
}
|
||||
|
||||
public static TouchConsumer newInstance(ActivityControlHelper activityHelper,
|
||||
boolean startingInActivityBounds, TouchInteractionLog touchInteractionLog) {
|
||||
return newInstance(activityHelper, startingInActivityBounds, touchInteractionLog,
|
||||
true /* waitForWindowAvailable */);
|
||||
}
|
||||
|
||||
public static TouchConsumer newInstance(ActivityControlHelper activityHelper,
|
||||
boolean startingInActivityBounds, TouchInteractionLog touchInteractionLog,
|
||||
boolean waitForWindowAvailable) {
|
||||
BaseDraggingActivity activity = activityHelper.getCreatedActivity();
|
||||
if (activity == null) {
|
||||
return TouchConsumer.NO_OP;
|
||||
}
|
||||
return new OverviewTouchConsumer(activityHelper, activity, startingInActivityBounds,
|
||||
touchInteractionLog, waitForWindowAvailable);
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,6 @@ public interface TouchConsumer extends Consumer<MotionEvent> {
|
||||
|
||||
default void onQuickScrubProgress(float progress) { }
|
||||
|
||||
default void onQuickStep(MotionEvent ev) { }
|
||||
|
||||
default void onShowOverviewFromAltTab() {}
|
||||
|
||||
default boolean isActive() {
|
||||
|
||||
@@ -17,20 +17,15 @@ package com.android.quickstep;
|
||||
|
||||
import static android.view.MotionEvent.ACTION_CANCEL;
|
||||
import static android.view.MotionEvent.ACTION_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_MOVE;
|
||||
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_POINTER_INDEX_SHIFT;
|
||||
import static android.view.MotionEvent.ACTION_UP;
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
|
||||
import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_NONE;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Region;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -40,13 +35,9 @@ import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Choreographer;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.MainThreadExecutor;
|
||||
import com.android.launcher3.util.TraceHelper;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.systemui.shared.recents.IOverviewProxy;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
@@ -95,12 +86,6 @@ public class TouchInteractionService extends Service {
|
||||
mEventQueue.queue(ev);
|
||||
|
||||
int action = ev.getActionMasked();
|
||||
if (action == ACTION_DOWN) {
|
||||
mOverviewInteractionState.setSwipeGestureInitializing(true);
|
||||
} else if (action == ACTION_UP || action == ACTION_CANCEL) {
|
||||
mOverviewInteractionState.setSwipeGestureInitializing(false);
|
||||
}
|
||||
|
||||
String name = sMotionEventNames.get(action);
|
||||
if (name != null){
|
||||
TraceHelper.partitionSection("SysUiBinder", name);
|
||||
@@ -115,7 +100,6 @@ public class TouchInteractionService extends Service {
|
||||
|
||||
public void onQuickScrubStart() {
|
||||
mEventQueue.onQuickScrubStart();
|
||||
mOverviewInteractionState.setSwipeGestureInitializing(false);
|
||||
TraceHelper.partitionSection("SysUiBinder", "onQuickScrubStart");
|
||||
}
|
||||
|
||||
@@ -151,11 +135,7 @@ public class TouchInteractionService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
public void onQuickStep(MotionEvent motionEvent) {
|
||||
mEventQueue.onQuickStep(motionEvent);
|
||||
mOverviewInteractionState.setSwipeGestureInitializing(false);
|
||||
TraceHelper.endSection("SysUiBinder", "onQuickStep");
|
||||
}
|
||||
public void onQuickStep(MotionEvent motionEvent) { }
|
||||
|
||||
@Override
|
||||
public void onTip(int actionType, int viewType) {
|
||||
@@ -252,212 +232,4 @@ public class TouchInteractionService extends Service {
|
||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
mTouchInteractionLog.dump(pw);
|
||||
}
|
||||
|
||||
public static class OverviewTouchConsumer<T extends BaseDraggingActivity>
|
||||
implements TouchConsumer {
|
||||
|
||||
private final ActivityControlHelper<T> mActivityHelper;
|
||||
private final T mActivity;
|
||||
private final BaseDragLayer mTarget;
|
||||
private final int[] mLocationOnScreen = new int[2];
|
||||
private final PointF mDownPos = new PointF();
|
||||
private final int mTouchSlop;
|
||||
private final QuickScrubController mQuickScrubController;
|
||||
private final TouchInteractionLog mTouchInteractionLog;
|
||||
|
||||
private final boolean mStartingInActivityBounds;
|
||||
|
||||
private boolean mTrackingStarted = false;
|
||||
private boolean mInvalidated = false;
|
||||
|
||||
private float mLastProgress = 0;
|
||||
private boolean mStartPending = false;
|
||||
private boolean mEndPending = false;
|
||||
private boolean mWaitForWindowAvailable;
|
||||
|
||||
OverviewTouchConsumer(ActivityControlHelper<T> activityHelper, T activity,
|
||||
boolean startingInActivityBounds, TouchInteractionLog touchInteractionLog,
|
||||
boolean waitForWindowAvailable) {
|
||||
mActivityHelper = activityHelper;
|
||||
mActivity = activity;
|
||||
mTarget = activity.getDragLayer();
|
||||
mTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
|
||||
mStartingInActivityBounds = startingInActivityBounds;
|
||||
|
||||
mQuickScrubController = mActivity.<RecentsView>getOverviewPanel()
|
||||
.getQuickScrubController();
|
||||
mTouchInteractionLog = touchInteractionLog;
|
||||
mTouchInteractionLog.setTouchConsumer(this);
|
||||
|
||||
mWaitForWindowAvailable = waitForWindowAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MotionEvent ev) {
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
mTouchInteractionLog.addMotionEvent(ev);
|
||||
int action = ev.getActionMasked();
|
||||
if (action == ACTION_DOWN) {
|
||||
if (mStartingInActivityBounds) {
|
||||
startTouchTracking(ev, false /* updateLocationOffset */);
|
||||
return;
|
||||
}
|
||||
mTrackingStarted = false;
|
||||
mDownPos.set(ev.getX(), ev.getY());
|
||||
} else if (!mTrackingStarted) {
|
||||
switch (action) {
|
||||
case ACTION_CANCEL:
|
||||
case ACTION_UP:
|
||||
startTouchTracking(ev, true /* updateLocationOffset */);
|
||||
break;
|
||||
case ACTION_MOVE: {
|
||||
float displacement = mActivity.getDeviceProfile().isLandscape ?
|
||||
ev.getX() - mDownPos.x : ev.getY() - mDownPos.y;
|
||||
if (Math.abs(displacement) >= mTouchSlop) {
|
||||
// Start tracking only when mTouchSlop is crossed.
|
||||
startTouchTracking(ev, true /* updateLocationOffset */);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mTrackingStarted) {
|
||||
sendEvent(ev);
|
||||
}
|
||||
|
||||
if (action == ACTION_UP || action == ACTION_CANCEL) {
|
||||
mInvalidated = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void startTouchTracking(MotionEvent ev, boolean updateLocationOffset) {
|
||||
if (updateLocationOffset) {
|
||||
mTarget.getLocationOnScreen(mLocationOnScreen);
|
||||
}
|
||||
|
||||
// Send down touch event
|
||||
MotionEvent down = MotionEvent.obtainNoHistory(ev);
|
||||
down.setAction(ACTION_DOWN);
|
||||
sendEvent(down);
|
||||
|
||||
mTrackingStarted = true;
|
||||
// Send pointer down for remaining pointers.
|
||||
int pointerCount = ev.getPointerCount();
|
||||
for (int i = 1; i < pointerCount; i++) {
|
||||
down.setAction(ACTION_POINTER_DOWN | (i << ACTION_POINTER_INDEX_SHIFT));
|
||||
sendEvent(down);
|
||||
}
|
||||
|
||||
down.recycle();
|
||||
}
|
||||
|
||||
private void sendEvent(MotionEvent ev) {
|
||||
if (!mTarget.verifyTouchDispatch(this, ev)) {
|
||||
mInvalidated = true;
|
||||
return;
|
||||
}
|
||||
int flags = ev.getEdgeFlags();
|
||||
ev.setEdgeFlags(flags | TouchInteractionService.EDGE_NAV_BAR);
|
||||
ev.offsetLocation(-mLocationOnScreen[0], -mLocationOnScreen[1]);
|
||||
if (!mTrackingStarted) {
|
||||
mTarget.onInterceptTouchEvent(ev);
|
||||
}
|
||||
mTarget.onTouchEvent(ev);
|
||||
ev.offsetLocation(mLocationOnScreen[0], mLocationOnScreen[1]);
|
||||
ev.setEdgeFlags(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickStep(MotionEvent ev) {
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
OverviewCallbacks.get(mActivity).closeAllWindows();
|
||||
ActivityManagerWrapper.getInstance()
|
||||
.closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
|
||||
mTouchInteractionLog.startQuickStep();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickScrubStart() {
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
mTouchInteractionLog.startQuickScrub();
|
||||
if (!mQuickScrubController.prepareQuickScrub(TAG)) {
|
||||
mInvalidated = true;
|
||||
mTouchInteractionLog.endQuickScrub("onQuickScrubStart");
|
||||
return;
|
||||
}
|
||||
OverviewCallbacks.get(mActivity).closeAllWindows();
|
||||
ActivityManagerWrapper.getInstance()
|
||||
.closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
|
||||
|
||||
mStartPending = true;
|
||||
Runnable action = () -> {
|
||||
if (!mQuickScrubController.prepareQuickScrub(TAG)) {
|
||||
mInvalidated = true;
|
||||
mTouchInteractionLog.endQuickScrub("onQuickScrubStart");
|
||||
return;
|
||||
}
|
||||
mActivityHelper.onQuickInteractionStart(mActivity, null, true,
|
||||
mTouchInteractionLog);
|
||||
mQuickScrubController.onQuickScrubProgress(mLastProgress);
|
||||
mStartPending = false;
|
||||
|
||||
if (mEndPending) {
|
||||
mQuickScrubController.onQuickScrubEnd();
|
||||
mEndPending = false;
|
||||
}
|
||||
};
|
||||
|
||||
if (mWaitForWindowAvailable) {
|
||||
mActivityHelper.executeOnWindowAvailable(mActivity, action);
|
||||
} else {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickScrubEnd() {
|
||||
mTouchInteractionLog.endQuickScrub("onQuickScrubEnd");
|
||||
if (mInvalidated) {
|
||||
return;
|
||||
}
|
||||
if (mStartPending) {
|
||||
mEndPending = true;
|
||||
} else {
|
||||
mQuickScrubController.onQuickScrubEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuickScrubProgress(float progress) {
|
||||
mTouchInteractionLog.setQuickScrubProgress(progress);
|
||||
mLastProgress = progress;
|
||||
if (mInvalidated || mStartPending) {
|
||||
return;
|
||||
}
|
||||
mQuickScrubController.onQuickScrubProgress(progress);
|
||||
}
|
||||
|
||||
public static TouchConsumer newInstance(ActivityControlHelper activityHelper,
|
||||
boolean startingInActivityBounds, TouchInteractionLog touchInteractionLog) {
|
||||
return newInstance(activityHelper, startingInActivityBounds, touchInteractionLog,
|
||||
true /* waitForWindowAvailable */);
|
||||
}
|
||||
|
||||
public static TouchConsumer newInstance(ActivityControlHelper activityHelper,
|
||||
boolean startingInActivityBounds, TouchInteractionLog touchInteractionLog,
|
||||
boolean waitForWindowAvailable) {
|
||||
BaseDraggingActivity activity = activityHelper.getCreatedActivity();
|
||||
if (activity == null) {
|
||||
return TouchConsumer.NO_OP;
|
||||
}
|
||||
return new OverviewTouchConsumer(activityHelper, activity, startingInActivityBounds,
|
||||
touchInteractionLog, waitForWindowAvailable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ import com.android.quickstep.ActivityControlHelper.AnimationFactory;
|
||||
import com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState;
|
||||
import com.android.quickstep.ActivityControlHelper.LayoutListener;
|
||||
import com.android.quickstep.TouchConsumer.InteractionType;
|
||||
import com.android.quickstep.TouchInteractionService.OverviewTouchConsumer;
|
||||
import com.android.quickstep.util.ClipAnimationHelper;
|
||||
import com.android.quickstep.util.RemoteAnimationTargetSet;
|
||||
import com.android.quickstep.util.SwipeAnimationTargetSet;
|
||||
|
||||
Reference in New Issue
Block a user