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

Commit 0e5149b1 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Support hiding / showing the bubble overflow on BubbleStackView" into main

parents 66c34f27 010a105a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.statusbar.IStatusBarService;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.wm.shell.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.WindowManagerShellWrapper;
@@ -1866,7 +1867,11 @@ public class BubbleController implements ConfigurationChangeListener,

        @Override
        public void bubbleOverflowChanged(boolean hasBubbles) {
            // TODO (b/334175587): tell stack view to hide / show the overflow
            if (Flags.enableOptionalBubbleOverflow()) {
                if (mStackView != null) {
                    mStackView.showOverflow(hasBubbles);
                }
            }
        }
    };

+4 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import androidx.recyclerview.widget.RecyclerView;

import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ContrastColorUtil;
import com.android.wm.shell.Flags;
import com.android.wm.shell.R;

import java.util.ArrayList;
@@ -195,7 +196,9 @@ public class BubbleOverflowContainerView extends LinearLayout {
    }

    void updateEmptyStateVisibility() {
        mEmptyState.setVisibility(mOverflowBubbles.isEmpty() ? View.VISIBLE : View.GONE);
        boolean showEmptyState = mOverflowBubbles.isEmpty()
                && !Flags.enableOptionalBubbleOverflow();
        mEmptyState.setVisibility(showEmptyState ? View.VISIBLE : View.GONE);
        mRecyclerView.setVisibility(mOverflowBubbles.isEmpty() ? View.GONE : View.VISIBLE);
    }

+67 −35
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.wm.shell.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.animation.Interpolators;
import com.android.wm.shell.bubbles.BubblesNavBarMotionEventHandler.MotionEventListener;
@@ -863,6 +864,7 @@ public class BubbleStackView extends FrameLayout
        }
    };

    private boolean mShowingOverflow;
    private BubbleOverflow mBubbleOverflow;
    private StackEducationView mStackEduView;
    private StackEducationView.Manager mStackEducationViewManager;
@@ -992,18 +994,12 @@ public class BubbleStackView extends FrameLayout

        mBubbleOverflow = mBubbleData.getOverflow();

        resetOverflowView();
        mBubbleContainer.addView(mBubbleOverflow.getIconView(),
                mBubbleContainer.getChildCount() /* index */,
                new FrameLayout.LayoutParams(mPositioner.getBubbleSize(),
                        mPositioner.getBubbleSize()));
        updateOverflow();
        mBubbleOverflow.getIconView().setOnClickListener((View v) -> {
            mBubbleData.setShowingOverflow(true);
            mBubbleData.setSelectedBubble(mBubbleOverflow);
            mBubbleData.setExpanded(true);
        });

        if (Flags.enableOptionalBubbleOverflow()) {
            showOverflow(mBubbleData.hasOverflowBubbles());
        } else {
            mShowingOverflow = true; // if the flags not on this is always true
            setUpOverflow();
        }
        mScrim = new View(getContext());
        mScrim.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        mScrim.setBackgroundDrawable(new ColorDrawable(
@@ -1220,6 +1216,19 @@ public class BubbleStackView extends FrameLayout
        }
    };

    private void setUpOverflow() {
        resetOverflowView();
        mBubbleContainer.addView(mBubbleOverflow.getIconView(),
                mBubbleContainer.getChildCount() /* index */,
                new FrameLayout.LayoutParams(mBubbleSize, mBubbleSize));
        updateOverflow();
        mBubbleOverflow.getIconView().setOnClickListener((View v) -> {
            mBubbleData.setShowingOverflow(true);
            mBubbleData.setSelectedBubble(mBubbleOverflow);
            mBubbleData.setExpanded(true);
        });
    }

    private void setUpDismissView() {
        if (mDismissView != null) {
            removeView(mDismissView);
@@ -1458,24 +1467,56 @@ public class BubbleStackView extends FrameLayout
                b.getExpandedView().updateFontSize();
            }
        }
        if (mBubbleOverflow != null && mBubbleOverflow.getExpandedView() != null) {
        if (mShowingOverflow && mBubbleOverflow != null
                && mBubbleOverflow.getExpandedView() != null) {
            mBubbleOverflow.getExpandedView().updateFontSize();
        }
    }

    void updateLocale() {
        if (mBubbleOverflow != null && mBubbleOverflow.getExpandedView() != null) {
        if (mShowingOverflow && mBubbleOverflow != null
                && mBubbleOverflow.getExpandedView() != null) {
            mBubbleOverflow.getExpandedView().updateLocale();
        }
    }

    private void updateOverflow() {
        mBubbleOverflow.update();
        if (mShowingOverflow) {
            mBubbleContainer.reorderView(mBubbleOverflow.getIconView(),
                    mBubbleContainer.getChildCount() - 1 /* index */);
        }
        updateOverflowVisibility();
    }

    private void updateOverflowVisibility() {
        mBubbleOverflow.setVisible(mShowingOverflow
                && (mIsExpanded || mBubbleData.isShowingOverflow())
                ? VISIBLE
                : GONE);
    }

    private void updateOverflowDotVisibility(boolean expanding) {
        if (mShowingOverflow && mBubbleOverflow.showDot()) {
            mBubbleOverflow.getIconView().animateDotScale(expanding ? 1 : 0f, () -> {
                mBubbleOverflow.setVisible(expanding ? VISIBLE : GONE);
            });
        }
    }

    /**  Sets whether the overflow should be visible or not. */
    public void showOverflow(boolean showOverflow) {
        if (!Flags.enableOptionalBubbleOverflow()) return;
        if (mShowingOverflow != showOverflow) {
            mShowingOverflow = showOverflow;
            if (showOverflow) {
                setUpOverflow();
            } else if (mBubbleOverflow != null) {
                resetOverflowView();
            }
        }
    }

    /**
     * Handle theme changes.
     */
@@ -1535,7 +1576,10 @@ public class BubbleStackView extends FrameLayout
                b.getExpandedView().updateDimensions();
            }
        }
        mBubbleOverflow.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize));
        if (mShowingOverflow) {
            mBubbleOverflow.getIconView().setLayoutParams(
                    new LayoutParams(mBubbleSize, mBubbleSize));
        }
        mExpandedAnimationController.updateResources();
        mStackAnimationController.updateResources();
        mDismissView.updateResources();
@@ -1699,7 +1743,7 @@ public class BubbleStackView extends FrameLayout
                    bubble.getIconView().setContentDescription(getResources().getString(
                            R.string.bubble_content_description_single, titleStr, appName));
                } else {
                    final int moreCount = mBubbleContainer.getChildCount() - 1;
                    final int moreCount = getBubbleCount();
                    bubble.getIconView().setContentDescription(getResources().getString(
                            R.string.bubble_content_description_stack,
                            titleStr, appName, moreCount));
@@ -1752,7 +1796,8 @@ public class BubbleStackView extends FrameLayout

            View bubbleOverflowIconView =
                    mBubbleOverflow != null ? mBubbleOverflow.getIconView() : null;
            if (bubbleOverflowIconView != null && !mBubbleData.getBubbles().isEmpty()) {
            if (mShowingOverflow && bubbleOverflowIconView != null
                    && !mBubbleData.getBubbles().isEmpty()) {
                Bubble lastBubble =
                        mBubbleData.getBubbles().get(mBubbleData.getBubbles().size() - 1);
                View lastBubbleIconView = lastBubble.getIconView();
@@ -1928,20 +1973,6 @@ public class BubbleStackView extends FrameLayout
        }
    }

    private void updateOverflowVisibility() {
        mBubbleOverflow.setVisible((mIsExpanded || mBubbleData.isShowingOverflow())
                ? VISIBLE
                : GONE);
    }

    private void updateOverflowDotVisibility(boolean expanding) {
        if (mBubbleOverflow.showDot()) {
            mBubbleOverflow.getIconView().animateDotScale(expanding ? 1 : 0f, () -> {
                mBubbleOverflow.setVisible(expanding ? VISIBLE : GONE);
            });
        }
    }

    // via BubbleData.Listener
    void updateBubble(Bubble bubble) {
        animateInFlyoutForBubble(bubble);
@@ -3428,8 +3459,9 @@ public class BubbleStackView extends FrameLayout
     * @return the number of bubbles in the stack view.
     */
    public int getBubbleCount() {
        // Subtract 1 for the overflow button that is always in the bubble container.
        return mBubbleContainer.getChildCount() - 1;
        final int childCount = mBubbleContainer.getChildCount();
        // Subtract 1 for the overflow button if it's showing.
        return mShowingOverflow ? childCount - 1 : childCount;
    }

    /**