Moving NavigationMode to display controller

Navigation mode affects display properties like bounds and
most listeners already had a similar display listener. This
will remove race conditions when managing the two events.

Bug: 221961069
Test: Presubmit
Change-Id: If7a22e006e6b969ecddf075001066809aa72995c
This commit is contained in:
Sunny Goyal
2022-03-04 10:49:01 -08:00
parent 1ffc81c7ba
commit 4403d078a6
31 changed files with 317 additions and 462 deletions
@@ -25,10 +25,11 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSP
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
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.TWO_BUTTONS;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
import android.animation.AnimatorSet;
@@ -65,6 +66,7 @@ import com.android.launcher3.taskbar.TaskbarManager;
import com.android.launcher3.uioverrides.RecentsViewStateController;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.NavigationMode;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.RunnableList;
@@ -72,9 +74,6 @@ import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.OverviewCommandHelper;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TouchInteractionService.TISBinder;
@@ -102,8 +101,7 @@ import java.util.stream.Stream;
/**
* Extension of Launcher activity to provide quickstep specific functionality
*/
public abstract class BaseQuickstepLauncher extends Launcher
implements NavigationModeChangeListener {
public abstract class BaseQuickstepLauncher extends Launcher {
private DepthController mDepthController = new DepthController(this);
private QuickstepTransitionManager mAppTransitionManager;
@@ -131,7 +129,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);
addMultiWindowModeChangedListener(mDepthController);
initUnfoldTransitionProgressProvider();
}
@@ -161,8 +158,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
mUnfoldTransitionProgressProvider.destroy();
}
SysUINavigationMode.INSTANCE.get(this).removeModeChangeListener(this);
mTISBindHelper.onDestroy();
if (mTaskbarManager != null) {
mTaskbarManager.clearActivity(this);
@@ -188,14 +183,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
return mAppTransitionManager;
}
@Override
public void onNavigationModeChanged(Mode newMode) {
getDragLayer().recreateControllers();
if (mActionsView != null) {
mActionsView.updateVerticalMargin(newMode);
}
}
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
@@ -305,7 +292,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
protected void setupViews() {
super.setupViews();
SysUINavigationMode.INSTANCE.get(this).updateMode();
mActionsView = findViewById(R.id.overview_actions_view);
RecentsView overviewPanel = (RecentsView) getOverviewPanel();
SplitSelectStateController controller =
@@ -313,7 +299,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
getStateManager(), getDepthController());
overviewPanel.init(mActionsView, controller);
mActionsView.setDp(getDeviceProfile());
mActionsView.updateVerticalMargin(SysUINavigationMode.getMode(this));
mActionsView.updateVerticalMargin(DisplayController.getNavigationMode(this));
mAppTransitionManager = new QuickstepTransitionManager(this);
mAppTransitionManager.registerRemoteAnimations();
@@ -434,7 +420,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
@Override
public float[] getNormalOverviewScaleAndOffset() {
return SysUINavigationMode.getMode(this).hasGestures
return DisplayController.getNavigationMode(this).hasGestures
? new float[] {1, 1} : new float[] {1.1f, NO_OFFSET};
}
@@ -464,7 +450,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
}
public boolean shouldBackButtonBeHidden(LauncherState toState) {
Mode mode = SysUINavigationMode.getMode(this);
NavigationMode mode = DisplayController.getNavigationMode(this);
boolean shouldBackButtonBeHidden = mode.hasGestures
&& toState.hasFlag(FLAG_HIDE_BACK_BUTTON)
&& hasWindowFocus()
@@ -482,7 +468,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
*/
private void onLauncherStateOrFocusChanged() {
boolean shouldBackButtonBeHidden = shouldBackButtonBeHidden(getStateManager().getState());
if (SysUINavigationMode.getMode(this) == TWO_BUTTONS) {
if (DisplayController.getNavigationMode(this) == TWO_BUTTONS) {
UiThreadHelper.setBackButtonAlphaAsync(this, SET_BACK_BUTTON_ALPHA,
shouldBackButtonBeHidden ? 0f : 1f, true /* animate */);
}
@@ -612,6 +598,13 @@ public abstract class BaseQuickstepLauncher extends Launcher
if ((flags & CHANGE_ACTIVE_SCREEN) != 0) {
getStateManager().moveToRestState();
}
if ((flags & CHANGE_NAVIGATION_MODE) != 0) {
getDragLayer().recreateControllers();
if (mActionsView != null) {
mActionsView.updateVerticalMargin(info.navigationMode);
}
}
}
@Override
@@ -627,7 +620,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
WindowInsets oldInsets) {
// Override the tappable insets to be 0 on the bottom for gesture nav (otherwise taskbar
// would count towards it). This is used for the bottom protection in All Apps for example.
if (SysUINavigationMode.getMode(this) == NO_BUTTON) {
if (DisplayController.getNavigationMode(this) == NO_BUTTON) {
Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement());
Insets newTappableInsets = Insets.of(oldTappableInsets.left, oldTappableInsets.top,
oldTappableInsets.right, 0);