Merge "Check for isTaskbarPresent in addition to isTransientTaskbar when the method is called outside of taskbar." into tm-qpr-dev

This commit is contained in:
Jon Miranda
2022-11-24 01:28:18 +00:00
committed by Android (Google) Code Review
3 changed files with 50 additions and 63 deletions

View File

@@ -316,6 +316,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
private final float mQuickSwitchScaleScrollThreshold;
private final int mTaskbarAppWindowThreshold;
private final int mTaskbarHomeOverviewThreshold;
private final int mTaskbarCatchUpThreshold;
private boolean mTaskbarAlreadyOpen;
private final boolean mIsTransientTaskbar;
@@ -344,21 +345,29 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
mContinuingLastGesture = continuingLastGesture;
Resources res = context.getResources();
mTaskbarAppWindowThreshold = res
.getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
? R.dimen.taskbar_app_window_threshold_v2
: R.dimen.taskbar_app_window_threshold);
mTaskbarCatchUpThreshold = res.getDimensionPixelSize(R.dimen.taskbar_catch_up_threshold);
mIsTransientTaskbar = DisplayController.isTransientTaskbar(mActivity);
mQuickSwitchScaleScrollThreshold = res
.getDimension(R.dimen.quick_switch_scaling_scroll_threshold);
mSplashMainWindowShiftLength = -res
.getDimensionPixelSize(R.dimen.starting_surface_exit_animation_window_shift_length);
initAfterSubclassConstructor();
initTransitionEndpoints(mRemoteTargetHandles[0].getTaskViewSimulator()
.getOrientationState().getLauncherDeviceProfile());
initStateCallbacks();
mIsTransientTaskbar = mDp.isTaskbarPresent
&& DisplayController.isTransientTaskbar(mActivity);
TaskbarUIController controller = mActivityInterface.getTaskbarController();
mTaskbarAlreadyOpen = controller != null && !controller.isTaskbarStashed();
mTaskbarAppWindowThreshold = res
.getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
? R.dimen.taskbar_app_window_threshold_v2
: R.dimen.taskbar_app_window_threshold);
mTaskbarHomeOverviewThreshold = res.getDimensionPixelSize(
ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
? R.dimen.taskbar_home_overview_threshold_v2
: R.dimen.taskbar_home_overview_threshold);
mTaskbarCatchUpThreshold = res.getDimensionPixelSize(R.dimen.taskbar_catch_up_threshold);
}
@Nullable
@@ -737,18 +746,12 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
}
/**
* Sets whether or not we should clamp the scroll offset.
* This is used to avoid x-axis movement when swiping up transient taskbar.
* @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is
* met.
* Returns threshold that needs to be met in order for motion pause to be allowed.
*/
public void setClampScrollOffset(boolean clampScrollOffset) {
if (mRecentsView == null) {
mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT,
() -> mRecentsView.setClampScrollOffset(clampScrollOffset));
return;
}
mRecentsView.setClampScrollOffset(clampScrollOffset);
public float getThresholdToAllowMotionPause() {
return mIsTransientTaskbar
? mTaskbarHomeOverviewThreshold
: 0;
}
public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) {
@@ -947,10 +950,33 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
}
notifyGestureStartedAsync();
setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */);
if (mIsTransientTaskbar && !mTaskbarAlreadyOpen && !isLikelyToStartNewTask) {
setClampScrollOffset(true);
}
mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED);
mGestureStarted = true;
}
/**
* Sets whether or not we should clamp the scroll offset.
* This is used to avoid x-axis movement when swiping up transient taskbar.
* @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is
* met.
*/
private void setClampScrollOffset(boolean clampScrollOffset) {
if (!mIsTransientTaskbar) {
return;
}
if (mRecentsView == null) {
mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT,
() -> mRecentsView.setClampScrollOffset(clampScrollOffset));
return;
}
mRecentsView.setClampScrollOffset(clampScrollOffset);
}
/**
* Notifies the launcher that the swipe gesture has started. This can be called multiple times.
*/
@@ -1177,6 +1203,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
float currentShift = mCurrentShift.value;
final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity,
isFling, isCancel);
setClampScrollOffset(false);
// Set the state, but don't notify until the animation completes
mGestureState.setEndTarget(endTarget, false /* isAtomic */);
mAnimationFactory.setEndTarget(endTarget);
@@ -1969,15 +1997,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|| app.windowConfiguration.getActivityType() == ACTIVITY_TYPE_HOME;
}
/**
* To be called at the end of constructor of subclasses. This calls various methods which can
* depend on proper class initialization.
*/
protected void initAfterSubclassConstructor() {
initTransitionEndpoints(mRemoteTargetHandles[0].getTaskViewSimulator()
.getOrientationState().getLauncherDeviceProfile());
}
protected void performHapticFeedback() {
VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC);
}
@@ -2231,13 +2250,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
return scaleProgress;
}
/**
* Updates the current status of taskbar during this swipe.
*/
public void setTaskbarAlreadyOpen(boolean taskbarAlreadyOpen) {
mTaskbarAlreadyOpen = taskbarAlreadyOpen;
}
/**
* Overrides the gesture displacement to keep the app window at the bottom of the screen while
* the transient taskbar is being swiped in.

View File

@@ -27,7 +27,6 @@ import static com.android.launcher3.PagedView.ACTION_MOVE_ALLOW_EASY_FLING;
import static com.android.launcher3.PagedView.DEBUG_FAILED_QUICKSWITCH;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_REVISED_THRESHOLDS;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.TraceHelper.FLAG_CHECK_FOR_RACE_CONDITIONS;
import static com.android.launcher3.util.VelocityUtils.PX_PER_MS;
@@ -48,11 +47,9 @@ import androidx.annotation.UiThread;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.taskbar.TaskbarUIController;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.tracing.InputConsumerProto;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.AbsSwipeUpHandler;
@@ -134,10 +131,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
// Might be displacement in X or Y, depending on the direction we are swiping from the nav bar.
private float mStartDisplacement;
private final boolean mIsTransientTaskbar;
private final boolean mTaskbarAlreadyOpen;
private final int mTaskbarHomeOverviewThreshold;
public OtherActivityInputConsumer(Context base, RecentsAnimationDeviceState deviceState,
TaskAnimationManager taskAnimationManager, GestureState gestureState,
boolean isDeferredDownTarget, Consumer<OtherActivityInputConsumer> onCompleteCallback,
@@ -161,14 +154,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
mInputMonitorCompat = inputMonitorCompat;
mInputEventReceiver = inputEventReceiver;
TaskbarUIController controller = mActivityInterface.getTaskbarController();
mTaskbarAlreadyOpen = controller != null && !controller.isTaskbarStashed();
mIsTransientTaskbar = DisplayController.isTransientTaskbar(base);
mTaskbarHomeOverviewThreshold = base.getResources()
.getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
? R.dimen.taskbar_home_overview_threshold_v2
: R.dimen.taskbar_home_overview_threshold);
boolean continuingPreviousGesture = mTaskAnimationManager.isRecentsAnimationRunning();
mIsDeferredDownTarget = !continuingPreviousGesture && isDeferredDownTarget;
@@ -340,10 +325,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
}
if (mDeviceState.isFullyGesturalNavMode()) {
boolean minSwipeMet = upDist >= mMotionPauseMinDisplacement;
if (mIsTransientTaskbar) {
minSwipeMet = upDist >= mTaskbarHomeOverviewThreshold;
}
boolean minSwipeMet = upDist >= Math.max(mMotionPauseMinDisplacement,
mInteractionHandler.getThresholdToAllowMotionPause());
mInteractionHandler.setCanSlowSwipeGoHome(minSwipeMet);
mMotionPauseDetector.setDisallowPause(!minSwipeMet
|| isLikelyToStartNewTask);
@@ -379,11 +362,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
// Notify the handler that the gesture has actually started
mInteractionHandler.onGestureStarted(isLikelyToStartNewTask);
mInteractionHandler.setTaskbarAlreadyOpen(mTaskbarAlreadyOpen);
if (mIsTransientTaskbar && !mTaskbarAlreadyOpen && !isLikelyToStartNewTask) {
mInteractionHandler.setClampScrollOffset(true);
}
}
private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
@@ -479,9 +457,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
@UiThread
private void onInteractionGestureFinished() {
Preconditions.assertUIThread();
if (mInteractionHandler != null) {
mInteractionHandler.setClampScrollOffset(false);
}
removeListener();
mInteractionHandler = null;
cleanupAfterGesture();

View File

@@ -1632,7 +1632,7 @@ public class TaskView extends FrameLayout implements Reusable {
*/
private static RectF getInsetsToDrawInFullscreen(PreviewPositionHelper pph,
DeviceProfile dp, boolean isTaskbarTransient) {
if (isTaskbarTransient) {
if (dp.isTaskbarPresent && isTaskbarTransient) {
return pph.getClippedInsets();
}
return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps