Add flags to stash taskbar for app pinning and empty hotseat

Test: pin an app from overview, watch taskbar stash automatically until unpinning
Test: turn off suggestions for hotseat, remove all items and watch taskbar stash automatically when opening an app
Fixes: 190192993
Fixes: 193937948
Change-Id: Ia7260c60a820af1a48c9e4a400a52753baf34d41
This commit is contained in:
Tony Wickham
2021-10-07 23:29:41 -07:00
parent 772732de9e
commit db0c2f1b79
4 changed files with 31 additions and 2 deletions
@@ -321,6 +321,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
mControllers.taskbarViewController.setRecentsButtonDisabled(
mControllers.navbarButtonsViewController.isRecentsDisabled());
mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
mControllers.taskbarStashController.updateStateForSysuiFlags(systemUiStateFlags);
}
public void onRotationProposal(int rotation, boolean isValid) {
@@ -45,6 +45,9 @@ public class TaskbarModelCallbacks implements
private final TaskbarActivityContext mContext;
private final TaskbarView mContainer;
// Initialized in init.
private TaskbarControllers mControllers;
private boolean mBindInProgress = false;
public TaskbarModelCallbacks(
@@ -53,6 +56,10 @@ public class TaskbarModelCallbacks implements
mContainer = container;
}
public void init(TaskbarControllers controllers) {
mControllers = controllers;
}
@Override
public void startBinding() {
mBindInProgress = true;
@@ -161,6 +168,7 @@ public class TaskbarModelCallbacks implements
int predictionSize = mPredictedItems.size();
int predictionNextIndex = 0;
boolean isHotseatEmpty = true;
for (int i = 0; i < hotseatItemInfos.length; i++) {
hotseatItemInfos[i] = mHotseatItems.get(i);
if (hotseatItemInfos[i] == null && predictionNextIndex < predictionSize) {
@@ -168,7 +176,14 @@ public class TaskbarModelCallbacks implements
hotseatItemInfos[i].screenId = i;
predictionNextIndex++;
}
if (hotseatItemInfos[i] != null) {
isHotseatEmpty = false;
}
}
mContainer.updateHotseatItems(hotseatItemInfos);
mControllers.taskbarStashController.updateStateForFlag(
TaskbarStashController.FLAG_STASHED_IN_APP_EMPTY, isHotseatEmpty);
mControllers.taskbarStashController.applyState();
}
}
@@ -19,6 +19,7 @@ import static android.view.HapticFeedbackConstants.LONG_PRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -44,10 +45,13 @@ public class TaskbarStashController {
public static final int FLAG_IN_APP = 1 << 0;
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 2;
public static final int FLAG_STASHED_IN_APP_PINNED = 1 << 2; // app pinning
public static final int FLAG_STASHED_IN_APP_EMPTY = 1 << 3; // no hotseat icons
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 4;
// If we're in an app and any of these flags are enabled, taskbar should be stashed.
public static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL;
public static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL
| FLAG_STASHED_IN_APP_PINNED | FLAG_STASHED_IN_APP_EMPTY;
/**
* How long to stash/unstash when manually invoked via long press.
@@ -368,6 +372,13 @@ public class TaskbarStashController {
return mStatePropertyHolder.setState(mState, duration, false);
}
/** Called when some system ui state has changed. (See SYSUI_STATE_... in QuickstepContract) */
public void updateStateForSysuiFlags(int systemUiStateFlags) {
updateStateForFlag(FLAG_STASHED_IN_APP_PINNED,
hasAnyFlag(systemUiStateFlags, SYSUI_STATE_SCREEN_PINNING));
applyState();
}
/**
* Updates the proper flag to indicate whether the task bar should be stashed.
*
@@ -85,6 +85,8 @@ public class TaskbarViewController {
mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
mTaskbarIconScaleForStash.updateValue(1f);
mModelCallbacks.init(controllers);
LauncherAppState.getInstance(mActivity).getModel().addCallbacksAndLoad(mModelCallbacks);
}