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

Commit 5acc9e40 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update the bubble overflow to match new visuals" into tm-dev am: c37e762e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17015413

Change-Id: I9998a73b16eef2759877d552780fd2bdaeda5ed1
parents 81e2769f c37e762e
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -19,9 +19,8 @@
    android:id="@+id/bubble_overflow_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="@dimen/bubble_overflow_padding"
    android:paddingLeft="@dimen/bubble_overflow_padding"
    android:paddingRight="@dimen/bubble_overflow_padding"
    android:paddingLeft="@dimen/bubble_overflow_container_padding_horizontal"
    android:paddingRight="@dimen/bubble_overflow_container_padding_horizontal"
    android:orientation="vertical"
    android:layout_gravity="center_horizontal">

+3 −6
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
    android:orientation="vertical">

    <com.android.wm.shell.bubbles.BadgedImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/bubble_view"
        android:layout_gravity="center"
        android:layout_width="@dimen/bubble_size"
@@ -30,16 +29,14 @@

    <TextView
        android:id="@+id/bubble_view_name"
        android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
        android:textSize="13sp"
        android:textSize="14sp"
        android:layout_width="@dimen/bubble_name_width"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:lines="2"
        android:lines="1"
        android:ellipsize="end"
        android:layout_gravity="center"
        android:paddingTop="@dimen/bubble_overflow_text_padding"
        android:paddingEnd="@dimen/bubble_overflow_text_padding"
        android:paddingStart="@dimen/bubble_overflow_text_padding"
        android:gravity="center"/>
        android:gravity="center_horizontal|top"/>
</LinearLayout>
+9 −4
Original line number Diff line number Diff line
@@ -139,16 +139,21 @@
         If this value changes then R.dimen.bubble_expanded_view_min_height in CtsVerifier
         should also be updated. -->
    <dimen name="bubble_expanded_default_height">180dp</dimen>
    <!-- On large screens the width of the expanded view is restricted to this size. -->
    <dimen name="bubble_expanded_view_phone_landscape_overflow_width">412dp</dimen>
    <!-- The width of the overflow view on large screens or in landscape on phone. -->
    <dimen name="bubble_expanded_view_overflow_width">380dp</dimen>
    <!-- Inset to apply to the icon in the overflow button. -->
    <dimen name="bubble_overflow_icon_inset">30dp</dimen>
    <!-- Default (and minimum) height of bubble overflow -->
    <dimen name="bubble_overflow_height">480dp</dimen>
    <!-- Bubble overflow padding when there are no bubbles  -->
    <dimen name="bubble_overflow_empty_state_padding">16dp</dimen>
    <!-- Padding of container for overflow bubbles -->
    <dimen name="bubble_overflow_padding">15dp</dimen>
    <!-- Horizontal padding of the overflow container. Total desired padding is 16dp but the items
         already have 5dp added to each side. -->
    <dimen name="bubble_overflow_container_padding_horizontal">11dp</dimen>
    <!-- Horizontal padding between items in the overflow view, half of the desired amount. -->
    <dimen name="bubble_overflow_item_padding_horizontal">5dp</dimen>
    <!-- Vertical padding between items in the overflow view, half the desired amount. -->
    <dimen name="bubble_overflow_item_padding_vertical">16dp</dimen>
    <!-- Padding of label for bubble overflow view -->
    <dimen name="bubble_overflow_text_padding">7dp</dimen>
    <!-- Height of bubble overflow empty state illustration -->
+26 −8
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_OVERFLOW;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;

import android.annotation.NonNull;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
@@ -58,6 +60,8 @@ public class BubbleOverflowContainerView extends LinearLayout {
    private TextView mEmptyStateTitle;
    private TextView mEmptyStateSubtitle;
    private ImageView mEmptyStateImage;
    private int mHorizontalMargin;
    private int mVerticalMargin;
    private BubbleController mController;
    private BubbleOverflowAdapter mAdapter;
    private RecyclerView mRecyclerView;
@@ -77,12 +81,6 @@ public class BubbleOverflowContainerView extends LinearLayout {
            super(context, columns);
        }

//        @Override
//        public boolean canScrollVertically() {
//            // TODO (b/162006693): this should be based on items in the list & available height
//            return true;
//        }

        @Override
        public int getColumnCountForAccessibility(RecyclerView.Recycler recycler,
                RecyclerView.State state) {
@@ -98,6 +96,17 @@ public class BubbleOverflowContainerView extends LinearLayout {
        }
    }

    private class OverflowItemDecoration extends RecyclerView.ItemDecoration {
        @Override
        public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
                @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
            outRect.left = mHorizontalMargin;
            outRect.top = mVerticalMargin;
            outRect.right = mHorizontalMargin;
            outRect.bottom = mVerticalMargin;
        }
    }

    public BubbleOverflowContainerView(Context context) {
        this(context, null);
    }
@@ -161,6 +170,9 @@ public class BubbleOverflowContainerView extends LinearLayout {
        final int columns = res.getInteger(R.integer.bubbles_overflow_columns);
        mRecyclerView.setLayoutManager(
                new OverflowGridLayoutManager(getContext(), columns));
        if (mRecyclerView.getItemDecorationCount() == 0) {
            mRecyclerView.addItemDecoration(new OverflowItemDecoration());
        }
        mAdapter = new BubbleOverflowAdapter(getContext(), mOverflowBubbles,
                mController::promoteBubbleFromOverflow,
                mController.getPositioner());
@@ -188,6 +200,13 @@ public class BubbleOverflowContainerView extends LinearLayout {
        final int mode = res.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
        final boolean isNightMode = (mode == Configuration.UI_MODE_NIGHT_YES);

        mHorizontalMargin = res.getDimensionPixelSize(
                R.dimen.bubble_overflow_item_padding_horizontal);
        mVerticalMargin = res.getDimensionPixelSize(R.dimen.bubble_overflow_item_padding_vertical);
        if (mRecyclerView != null) {
            mRecyclerView.invalidateItemDecorations();
        }

        mEmptyStateImage.setImageDrawable(isNightMode
                ? res.getDrawable(R.drawable.bubble_ic_empty_overflow_dark)
                : res.getDrawable(R.drawable.bubble_ic_empty_overflow_light));
@@ -277,8 +296,7 @@ class BubbleOverflowAdapter extends RecyclerView.Adapter<BubbleOverflowAdapter.V
    }

    @Override
    public BubbleOverflowAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
            int viewType) {
    public BubbleOverflowAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        // Set layout for overflow bubble view.
        LinearLayout overflowView = (LinearLayout) LayoutInflater.from(parent.getContext())
+14 −6
Original line number Diff line number Diff line
@@ -212,10 +212,7 @@ public class BubblePositioner {
            mExpandedViewLargeScreenInsetFurthestEdge = mExpandedViewPadding;
        }

        mOverflowWidth = mIsLargeScreen
                ? mExpandedViewLargeScreenWidth
                : res.getDimensionPixelSize(
                        R.dimen.bubble_expanded_view_phone_landscape_overflow_width);
        mOverflowWidth = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_overflow_width);
        mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
        mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);
        mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin);
@@ -348,6 +345,15 @@ public class BubblePositioner {
        mImeHeight = height;
    }

    private int getExpandedViewLargeScreenInsetFurthestEdge(boolean isOverflow) {
        if (isOverflow && mIsLargeScreen) {
            return mScreenRect.width()
                    - mExpandedViewLargeScreenInsetClosestEdge
                    - mOverflowWidth;
        }
        return mExpandedViewLargeScreenInsetFurthestEdge;
    }

    /**
     * Calculates the padding for the bubble expanded view.
     *
@@ -362,6 +368,8 @@ public class BubblePositioner {
     */
    public int[] getExpandedViewContainerPadding(boolean onLeft, boolean isOverflow) {
        final int pointerTotalHeight = mPointerHeight - mPointerOverlap;
        final int expandedViewLargeScreenInsetFurthestEdge =
                getExpandedViewLargeScreenInsetFurthestEdge(isOverflow);
        if (mIsLargeScreen) {
            // Note:
            // If we're in portrait OR if we're a small tablet, then the two insets values will
@@ -369,10 +377,10 @@ public class BubblePositioner {
            // [left, top, right, bottom]
            mPaddings[0] = onLeft
                    ? mExpandedViewLargeScreenInsetClosestEdge - pointerTotalHeight
                    : mExpandedViewLargeScreenInsetFurthestEdge;
                    : expandedViewLargeScreenInsetFurthestEdge;
            mPaddings[1] = 0;
            mPaddings[2] = onLeft
                    ? mExpandedViewLargeScreenInsetFurthestEdge
                    ? expandedViewLargeScreenInsetFurthestEdge
                    : mExpandedViewLargeScreenInsetClosestEdge - pointerTotalHeight;
            // Overflow doesn't show manage button / get padding from it so add padding here
            mPaddings[3] = isOverflow ? mExpandedViewPadding : 0;