Merge "Start quickswitch on task switch instead of touch down" into ub-launcher3-rvc-dev
This commit is contained in:
commit
39cc356a53
|
@ -29,6 +29,7 @@ import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK;
|
|||
import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK;
|
||||
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
|
||||
import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINISHED;
|
||||
import static com.android.quickstep.GestureState.STATE_END_TARGET_SET;
|
||||
import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED;
|
||||
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
|
||||
|
@ -253,6 +254,10 @@ public abstract class BaseSwipeUpHandlerV2<T extends StatefulActivity<?>, Q exte
|
|||
mStateCallback.runOnceAtState(STATE_HANDLER_INVALIDATED | STATE_RESUME_LAST_TASK,
|
||||
this::notifyTransitionCancelled);
|
||||
|
||||
mGestureState.runOnceAtState(STATE_END_TARGET_SET,
|
||||
() -> mDeviceState.onEndTargetCalculated(mGestureState.getEndTarget(),
|
||||
mActivityInterface));
|
||||
|
||||
if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
|
||||
mStateCallback.addChangeListener(STATE_APP_CONTROLLER_RECEIVED | STATE_LAUNCHER_PRESENT
|
||||
| STATE_SCREENSHOT_VIEW_SHOWN | STATE_CAPTURE_SCREENSHOT,
|
||||
|
@ -1232,7 +1237,6 @@ public abstract class BaseSwipeUpHandlerV2<T extends StatefulActivity<?>, Q exte
|
|||
}
|
||||
ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true);
|
||||
doLogGesture(HOME);
|
||||
mDeviceState.enableMultipleRegions(false);
|
||||
}
|
||||
|
||||
protected abstract void finishRecentsControllerToHome(Runnable callback);
|
||||
|
@ -1248,7 +1252,6 @@ public abstract class BaseSwipeUpHandlerV2<T extends StatefulActivity<?>, Q exte
|
|||
|
||||
SystemUiProxy.INSTANCE.get(mContext).onOverviewShown(false, TAG);
|
||||
doLogGesture(RECENTS);
|
||||
mDeviceState.onSwipeUpToOverview(mActivityInterface);
|
||||
reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -613,7 +613,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
|||
if (!isFixedRotationTransformEnabled()) {
|
||||
return;
|
||||
}
|
||||
mDeviceState.enableMultipleRegions(baseInputConsumer instanceof OtherActivityInputConsumer);
|
||||
baseInputConsumer.notifyOrientationSetup();
|
||||
}
|
||||
|
||||
private InputConsumer newBaseConsumer(GestureState previousGestureState,
|
||||
|
|
|
@ -403,6 +403,11 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
|||
TraceHelper.INSTANCE.endSection(traceToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOrientationSetup() {
|
||||
mDeviceState.onStartGesture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsumerAboutToBeSwitched() {
|
||||
Preconditions.assertUIThread();
|
||||
|
|
|
@ -69,6 +69,11 @@ public interface InputConsumer {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle and specific setup necessary based on the orientation of the device
|
||||
*/
|
||||
default void notifyOrientationSetup() {}
|
||||
|
||||
/**
|
||||
* Returns the active input consumer is in the hierarchy of this input consumer.
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,6 @@ import android.view.Surface;
|
|||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.ResourceUtils;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.quickstep.util.RecentsOrientedState.SurfaceRotation;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
@ -67,6 +66,14 @@ class OrientationTouchTransformer {
|
|||
private boolean mEnableMultipleRegions;
|
||||
private Resources mResources;
|
||||
private OrientationRectF mLastRectTouched;
|
||||
/**
|
||||
* The rotation of the last touched nav bar. Derived from {@link #mLastRectTouched}, but has a
|
||||
* longer lifetime than the rect. Note this is different than {@link #mQuickStepStartingRotation}
|
||||
* as it always updates its value on every touch whereas mQuickstepStartingRotation only
|
||||
* updates when device rotation matches touch rotation. Maybe this will be only one necessary
|
||||
* after TODO(b/154580671) is in. TBD.
|
||||
*/
|
||||
private int mLastRectRotation;
|
||||
private SysUINavigationMode.Mode mMode;
|
||||
private QuickStepContractInfo mContractInfo;
|
||||
|
||||
|
@ -143,15 +150,17 @@ class OrientationTouchTransformer {
|
|||
* ALSO, you BETTER call this with {@param enableMultipleRegions} set to false once you're done.
|
||||
*
|
||||
* @param enableMultipleRegions Set to true to start tracking multiple nav bar regions
|
||||
* @param info The current displayInfo
|
||||
* @param info The current displayInfo which will be the start of the quickswitch gesture
|
||||
*/
|
||||
void enableMultipleRegions(boolean enableMultipleRegions, DefaultDisplay.Info info) {
|
||||
mEnableMultipleRegions = enableMultipleRegions &&
|
||||
mMode != SysUINavigationMode.Mode.TWO_BUTTONS;
|
||||
if (!enableMultipleRegions) {
|
||||
mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED;
|
||||
resetSwipeRegions(info);
|
||||
if (mEnableMultipleRegions) {
|
||||
mQuickStepStartingRotation = info.rotation;
|
||||
} else if (!enableMultipleRegions) {
|
||||
mLastRectRotation = mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED;
|
||||
}
|
||||
resetSwipeRegions(info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,11 +252,7 @@ class OrientationTouchTransformer {
|
|||
}
|
||||
|
||||
int getCurrentActiveRotation() {
|
||||
if (mLastRectTouched == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return mLastRectTouched.mRotation;
|
||||
}
|
||||
return mLastRectRotation;
|
||||
}
|
||||
|
||||
int getQuickStepStartingRotation() {
|
||||
|
@ -286,7 +291,8 @@ class OrientationTouchTransformer {
|
|||
}
|
||||
if (rect.applyTransform(event, false)) {
|
||||
mLastRectTouched = rect;
|
||||
if (mCurrentDisplayRotation == mLastRectTouched.mRotation) {
|
||||
mLastRectRotation = rect.mRotation;
|
||||
if (mEnableMultipleRegions && mCurrentDisplayRotation == mLastRectRotation) {
|
||||
// Start a touch session for the default nav region for the display
|
||||
mQuickStepStartingRotation = mLastRectTouched.mRotation;
|
||||
resetSwipeRegions();
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.android.quickstep;
|
|||
import static android.content.Intent.ACTION_USER_UNLOCKED;
|
||||
|
||||
import static com.android.launcher3.util.DefaultDisplay.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DefaultDisplay.CHANGE_FRAME_DELAY;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS;
|
||||
|
@ -103,7 +104,8 @@ public class RecentsAnimationDeviceState implements
|
|||
private TaskStackChangeListener mFrozenTaskListener = new TaskStackChangeListener() {
|
||||
@Override
|
||||
public void onRecentTaskListFrozenChanged(boolean frozen) {
|
||||
if (frozen) {
|
||||
mTaskListFrozen = frozen;
|
||||
if (frozen || mInOverview) {
|
||||
return;
|
||||
}
|
||||
enableMultipleRegions(false);
|
||||
|
@ -124,6 +126,7 @@ public class RecentsAnimationDeviceState implements
|
|||
* TODO: (b/156984037) For when user rotates after entering overview
|
||||
*/
|
||||
private boolean mInOverview;
|
||||
private boolean mTaskListFrozen;
|
||||
|
||||
public RecentsAnimationDeviceState(Context context) {
|
||||
mContext = context;
|
||||
|
@ -243,7 +246,8 @@ public class RecentsAnimationDeviceState implements
|
|||
|
||||
@Override
|
||||
public void onDisplayInfoChanged(DefaultDisplay.Info info, int flags) {
|
||||
if (info.id != getDisplayId()) {
|
||||
if (info.id != getDisplayId() || (flags & CHANGE_FRAME_DELAY) == CHANGE_FRAME_DELAY) {
|
||||
// ignore displays that aren't running launcher and frame refresh rate changes
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -506,7 +510,7 @@ public class RecentsAnimationDeviceState implements
|
|||
* *May* apply a transform on the motion event if it lies in the nav bar region for another
|
||||
* orientation that is currently being tracked as a part of quickstep
|
||||
*/
|
||||
public void setOrientationTransformIfNeeded(MotionEvent event) {
|
||||
void setOrientationTransformIfNeeded(MotionEvent event) {
|
||||
// negative coordinates bug b/143901881
|
||||
if (event.getX() < 0 || event.getY() < 0) {
|
||||
event.setLocation(Math.max(0, event.getX()), Math.max(0, event.getY()));
|
||||
|
@ -514,25 +518,54 @@ public class RecentsAnimationDeviceState implements
|
|||
mOrientationTouchTransformer.transform(event);
|
||||
}
|
||||
|
||||
void onSwipeUpToOverview(BaseActivityInterface activityInterface) {
|
||||
mInOverview = true;
|
||||
activityInterface.onExitOverview(this, () -> {
|
||||
mInOverview = false;
|
||||
enableMultipleRegions(false);
|
||||
});
|
||||
void enableMultipleRegions(boolean enable) {
|
||||
mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo());
|
||||
notifySysuiForRotation(mOrientationTouchTransformer.getQuickStepStartingRotation());
|
||||
}
|
||||
|
||||
void enableMultipleRegions(boolean enable) {
|
||||
if (mInOverview) {
|
||||
return;
|
||||
private void notifySysuiForRotation(int rotation) {
|
||||
UI_HELPER_EXECUTOR.execute(() ->
|
||||
SystemUiProxy.INSTANCE.get(mContext).onQuickSwitchToNewTask(rotation));
|
||||
}
|
||||
|
||||
public void onStartGesture() {
|
||||
if (mTaskListFrozen) {
|
||||
// Prioritize whatever nav bar user touches once in quickstep
|
||||
// This case is specifically when user changes what nav bar they are using mid
|
||||
// quickswitch session before tasks list is unfrozen
|
||||
notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onEndTargetCalculated(GestureState.GestureEndTarget endTarget,
|
||||
BaseActivityInterface activityInterface) {
|
||||
if (endTarget == GestureState.GestureEndTarget.RECENTS) {
|
||||
mInOverview = true;
|
||||
if (!mTaskListFrozen) {
|
||||
// If we're in landscape w/o ever quickswitching, show the navbar in landscape
|
||||
enableMultipleRegions(true);
|
||||
}
|
||||
activityInterface.onExitOverview(this, () -> {
|
||||
mInOverview = false;
|
||||
enableMultipleRegions(false);
|
||||
});
|
||||
} else if (endTarget == GestureState.GestureEndTarget.HOME) {
|
||||
enableMultipleRegions(false);
|
||||
} else if (endTarget == GestureState.GestureEndTarget.NEW_TASK) {
|
||||
if (mOrientationTouchTransformer.getQuickStepStartingRotation() == -1) {
|
||||
// First gesture to start quickswitch
|
||||
enableMultipleRegions(true);
|
||||
} else {
|
||||
notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
|
||||
}
|
||||
} else if (endTarget == GestureState.GestureEndTarget.LAST_TASK) {
|
||||
if (!mTaskListFrozen) {
|
||||
// touched nav bar but didn't go anywhere and not quickswitching, do nothing
|
||||
return;
|
||||
}
|
||||
notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
|
||||
}
|
||||
mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo());
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
int quickStepStartingRotation =
|
||||
mOrientationTouchTransformer.getQuickStepStartingRotation();
|
||||
SystemUiProxy.INSTANCE.get(mContext)
|
||||
.onQuickSwitchToNewTask(quickStepStartingRotation);
|
||||
});
|
||||
}
|
||||
|
||||
public int getCurrentActiveRotation() {
|
||||
|
|
Loading…
Reference in New Issue