Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64edc22c authored by Tony Wickham's avatar Tony Wickham
Browse files

Space out empty taskbar hotseat views when on home screen

This ensures the taskbar hotseat aligns with the home screen
hotseat, as the latter supports empty cells. When in apps,
the taskbar still collapses the empty cells.

Test: Turn off hotseat predictions, remove some hotseat items,
and ensure the taskbar hotseat spreads out when on home.

Bug: 179886115
Bug: 171917176
Change-Id: I6047c3c5691685edcd8b3519e0305812b1295550
parent 634f6008
Loading
Loading
Loading
Loading
+34 −2
Original line number Diff line number Diff line
@@ -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();
    }

    /**
+22 −3
Original line number Diff line number Diff line
@@ -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);