Fix issue with quickswitch not updating system bar flags

- Separate the calls to minimize split and to update the flags (we only
  want to minimize in split when swiping up, but we want to update the
  flags when quickswitching as well)

Bug: 155410195
Change-Id: I56308cc0fbaa8a855383012738f129671d72feff
This commit is contained in:
Winson Chung
2020-04-30 11:26:08 -07:00
parent 0199fa46de
commit a7ac7192c3
8 changed files with 51 additions and 31 deletions
@@ -215,7 +215,7 @@ public final class FallbackActivityInterface implements
}
@Override
public boolean shouldMinimizeSplitScreen() {
public boolean allowMinimizeSplitScreen() {
// TODO: Remove this once b/77875376 is fixed
return false;
}
@@ -250,8 +250,11 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa
public void updateFinalShift() {
mTransformParams.setProgress(mCurrentShift.value);
if (mRecentsAnimationController != null) {
mRecentsAnimationController.setWindowThresholdCrossed(!mInQuickSwitchMode
&& (mCurrentShift.value > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD));
boolean swipeUpThresholdPassed = mCurrentShift.value > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
mRecentsAnimationController.setUseLauncherSystemBarFlags(mInQuickSwitchMode
|| swipeUpThresholdPassed);
mRecentsAnimationController.setSplitScreenMinimized(!mInQuickSwitchMode
&& swipeUpThresholdPassed);
}
if (!mInQuickSwitchMode && !mDeviceState.isFullyGesturalNavMode()) {
@@ -408,7 +408,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
}
@Override
public boolean shouldMinimizeSplitScreen() {
public boolean allowMinimizeSplitScreen() {
return true;
}
@@ -630,17 +630,21 @@ public class LauncherSwipeHandler<T extends BaseDraggingActivity>
* @param windowProgress 0 == app, 1 == overview
*/
private void updateSysUiFlags(float windowProgress) {
if (mRecentsView != null) {
if (mRecentsAnimationController != null && mRecentsView != null) {
TaskView runningTask = mRecentsView.getRunningTaskView();
TaskView centermostTask = mRecentsView.getTaskViewNearestToCenterOfScreen();
int centermostTaskFlags = centermostTask == null ? 0
: centermostTask.getThumbnail().getSysUiStatusNavFlags();
boolean useHomeScreenFlags = windowProgress > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
boolean swipeUpThresholdPassed = windowProgress > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
boolean quickswitchThresholdPassed = centermostTask != runningTask;
// We will handle the sysui flags based on the centermost task view.
if (mRecentsAnimationController != null) {
mRecentsAnimationController.setWindowThresholdCrossed(centermostTaskFlags != 0
&& useHomeScreenFlags);
}
int sysuiFlags = useHomeScreenFlags ? 0 : centermostTaskFlags;
mRecentsAnimationController.setUseLauncherSystemBarFlags(
(swipeUpThresholdPassed || quickswitchThresholdPassed)
&& centermostTaskFlags != 0);
mRecentsAnimationController.setSplitScreenMinimized(swipeUpThresholdPassed);
int sysuiFlags = swipeUpThresholdPassed ? 0 : centermostTaskFlags;
mActivity.getSystemUiController().updateUiState(UI_STATE_OVERVIEW, sysuiFlags);
}
}
@@ -105,7 +105,7 @@ public interface BaseActivityInterface<T extends BaseDraggingActivity> {
Rect getOverviewWindowBounds(Rect homeBounds, RemoteAnimationTargetCompat target);
boolean shouldMinimizeSplitScreen();
boolean allowMinimizeSplitScreen();
default boolean deferStartingActivity(RecentsAnimationDeviceState deviceState, MotionEvent ev) {
return true;
@@ -19,13 +19,11 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.graphics.Rect;
import android.util.ArraySet;
import android.util.Log;
import androidx.annotation.BinderThread;
import androidx.annotation.UiThread;
import com.android.launcher3.Utilities;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.Preconditions;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
@@ -41,15 +39,15 @@ public class RecentsAnimationCallbacks implements
com.android.systemui.shared.system.RecentsAnimationListener {
private final Set<RecentsAnimationListener> mListeners = new ArraySet<>();
private final boolean mShouldMinimizeSplitScreen;
private final boolean mAllowMinimizeSplitScreen;
// TODO(141886704): Remove these references when they are no longer needed
private RecentsAnimationController mController;
private boolean mCancelled;
public RecentsAnimationCallbacks(boolean shouldMinimizeSplitScreen) {
mShouldMinimizeSplitScreen = shouldMinimizeSplitScreen;
public RecentsAnimationCallbacks(boolean allowMinimizeSplitScreen) {
mAllowMinimizeSplitScreen = allowMinimizeSplitScreen;
}
@UiThread
@@ -94,7 +92,7 @@ public class RecentsAnimationCallbacks implements
RecentsAnimationTargets targets = new RecentsAnimationTargets(appTargets,
wallpaperTargets, homeContentInsets, minimizedHomeBounds);
mController = new RecentsAnimationController(animationController,
mShouldMinimizeSplitScreen, this::onAnimationFinished);
mAllowMinimizeSplitScreen, this::onAnimationFinished);
if (mCancelled) {
Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(),
@@ -49,21 +49,22 @@ public class RecentsAnimationController {
private final RecentsAnimationControllerCompat mController;
private final Consumer<RecentsAnimationController> mOnFinishedListener;
private final boolean mShouldMinimizeSplitScreen;
private final boolean mAllowMinimizeSplitScreen;
private InputConsumerController mInputConsumerController;
private Supplier<InputConsumer> mInputProxySupplier;
private InputConsumer mInputConsumer;
private boolean mWindowThresholdCrossed = false;
private boolean mUseLauncherSysBarFlags = false;
private boolean mSplitScreenMinimized = false;
private boolean mTouchInProgress;
private boolean mFinishPending;
public RecentsAnimationController(RecentsAnimationControllerCompat controller,
boolean shouldMinimizeSplitScreen,
boolean allowMinimizeSplitScreen,
Consumer<RecentsAnimationController> onFinishedListener) {
mController = controller;
mOnFinishedListener = onFinishedListener;
mShouldMinimizeSplitScreen = shouldMinimizeSplitScreen;
mAllowMinimizeSplitScreen = allowMinimizeSplitScreen;
}
/**
@@ -76,16 +77,31 @@ public class RecentsAnimationController {
/**
* Indicates that the gesture has crossed the window boundary threshold and system UI can be
* update the represent the window behind
* update the system bar flags accordingly.
*/
public void setWindowThresholdCrossed(boolean windowThresholdCrossed) {
if (mWindowThresholdCrossed != windowThresholdCrossed) {
mWindowThresholdCrossed = windowThresholdCrossed;
public void setUseLauncherSystemBarFlags(boolean useLauncherSysBarFlags) {
if (mUseLauncherSysBarFlags != useLauncherSysBarFlags) {
mUseLauncherSysBarFlags = useLauncherSysBarFlags;
UI_HELPER_EXECUTOR.execute(() -> {
mController.setAnimationTargetsBehindSystemBars(!useLauncherSysBarFlags);
});
}
}
/**
* Indicates that the gesture has crossed the window boundary threshold and we should minimize
* if we are in splitscreen.
*/
public void setSplitScreenMinimized(boolean splitScreenMinimized) {
if (!mAllowMinimizeSplitScreen) {
return;
}
if (mSplitScreenMinimized != splitScreenMinimized) {
mSplitScreenMinimized = splitScreenMinimized;
UI_HELPER_EXECUTOR.execute(() -> {
mController.setAnimationTargetsBehindSystemBars(!windowThresholdCrossed);
SystemUiProxy p = SystemUiProxy.INSTANCE.getNoCreate();
if (p != null && mShouldMinimizeSplitScreen) {
p.setSplitScreenMinimized(windowThresholdCrossed);
if (p != null) {
p.setSplitScreenMinimized(splitScreenMinimized);
}
});
}
@@ -26,7 +26,6 @@ import androidx.annotation.UiThread;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.testing.TestProtocol;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -67,7 +66,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
final BaseActivityInterface activityInterface = gestureState.getActivityInterface();
mLastGestureState = gestureState;
mCallbacks = new RecentsAnimationCallbacks(activityInterface.shouldMinimizeSplitScreen());
mCallbacks = new RecentsAnimationCallbacks(activityInterface.allowMinimizeSplitScreen());
mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() {
@Override
public void onRecentsAnimationStart(RecentsAnimationController controller,