diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java index 69ca9835cf..544bc99869 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java @@ -25,6 +25,7 @@ import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTT import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.app.ActivityOptions; import android.content.ComponentName; import android.graphics.PixelFormat; @@ -84,6 +85,8 @@ public class TaskbarController { // Contains all loaded Hotseat items. private ItemInfo[] mLatestLoadedHotseatItems; + private boolean mIsAnimatingToLauncher; + public TaskbarController(BaseQuickstepLauncher launcher, TaskbarContainerView taskbarContainerView) { mLauncher = launcher; @@ -169,6 +172,14 @@ public class TaskbarController { public View.OnLongClickListener getItemOnLongClickListener() { return mDragController::startDragOnLongClick; } + + @Override + public int getEmptyHotseatViewVisibility() { + // When on the home screen, we want the empty hotseat views to take up their full + // space so that the others line up with the home screen hotseat. + return mLauncher.hasBeenResumed() || mIsAnimatingToLauncher + ? View.INVISIBLE : View.GONE; + } }; } @@ -290,8 +301,6 @@ public class TaskbarController { * @param toState If known, the state we will end up in when reaching Launcher. */ public Animator createAnimToLauncher(@Nullable LauncherState toState, long duration) { - alignRealHotseatWithTaskbar(); - PendingAnimation anim = new PendingAnimation(duration); anim.add(mTaskbarVisibilityController.createAnimToBackgroundAlpha(0, duration)); if (toState != null) { @@ -299,6 +308,22 @@ public class TaskbarController { } anim.addFloat(mTaskbarView, SCALE_PROPERTY, mTaskbarView.getScaleX(), getTaskbarScaleOnHome(), LINEAR); + + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mIsAnimatingToLauncher = true; + mTaskbarView.updateHotseatItemsVisibility(); + } + + @Override + public void onAnimationEnd(Animator animation) { + mIsAnimatingToLauncher = false; + } + }); + + anim.addOnFrameCallback(this::alignRealHotseatWithTaskbar); + return anim.buildAnim(); } @@ -306,6 +331,12 @@ public class TaskbarController { PendingAnimation anim = new PendingAnimation(duration); anim.add(mTaskbarVisibilityController.createAnimToBackgroundAlpha(1, duration)); anim.addFloat(mTaskbarView, SCALE_PROPERTY, mTaskbarView.getScaleX(), 1f, LINEAR); + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mTaskbarView.updateHotseatItemsVisibility(); + } + }); return anim.buildAnim(); } @@ -447,6 +478,7 @@ public class TaskbarController { protected interface TaskbarViewCallbacks { View.OnClickListener getItemOnClickListener(); View.OnLongClickListener getItemOnLongClickListener(); + int getEmptyHotseatViewVisibility(); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index 72c792f308..ed27f2ffc6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -182,25 +182,44 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa && hotseatItemInfo instanceof WorkspaceItemInfo) { ((BubbleTextView) hotseatView).applyFromWorkspaceItem( (WorkspaceItemInfo) hotseatItemInfo); - hotseatView.setVisibility(VISIBLE); hotseatView.setOnClickListener(mControllerCallbacks.getItemOnClickListener()); hotseatView.setOnLongClickListener( mControllerCallbacks.getItemOnLongClickListener()); } else if (isFolder) { - hotseatView.setVisibility(VISIBLE); hotseatView.setOnClickListener(mControllerCallbacks.getItemOnClickListener()); hotseatView.setOnLongClickListener( mControllerCallbacks.getItemOnLongClickListener()); } else { - hotseatView.setVisibility(GONE); hotseatView.setOnClickListener(null); hotseatView.setOnLongClickListener(null); } + updateHotseatItemVisibility(hotseatView); } updateHotseatRecentsDividerVisibility(); } + protected void updateHotseatItemsVisibility() { + for (int i = mHotseatStartIndex; i <= mHotseatEndIndex; i++) { + updateHotseatItemVisibility(getChildAt(i)); + } + } + + private void updateHotseatItemVisibility(View hotseatView) { + if (hotseatView.getTag() != null) { + hotseatView.setVisibility(VISIBLE); + } else { + int oldVisibility = hotseatView.getVisibility(); + int newVisibility = mControllerCallbacks.getEmptyHotseatViewVisibility(); + hotseatView.setVisibility(newVisibility); + if (oldVisibility == GONE && newVisibility != GONE) { + // By default, the layout transition only runs when going to VISIBLE, + // but we want it to run when going to GONE to INVISIBLE as well. + getLayoutTransition().showChild(this, hotseatView, oldVisibility); + } + } + } + private View addDivider(int dividerIndex) { View divider = inflate(R.layout.taskbar_divider); addView(divider, dividerIndex);