Space out empty taskbar hotseat views when on home screen am: 64edc22c8b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/13764911

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie406453c421f336a66607e1ccba33f23b5868d19
This commit is contained in:
Tony Wickham authored and Automerger Merge Worker committed 2021-03-05 04:52:23 +00:00
commit 84f8bb7810
2 files changed
+56 -5

No files matched your search

@@ -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();
}
/**
@@ -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);