From 3a0688ed8b33946ab1f21c9e52b2b1242dc5b0da Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 23 Feb 2022 16:56:23 -0800 Subject: [PATCH] Update the bubble overflow to match new visuals * The overflow has a more restricted size than previous and this size should be used even on large screens, not just in phone landscape. * Updates the padding between columns & rows in the overflow view * Reduces the line length of items in the overflow Test: visual - look at overflow on large tablet, small tablet and phone across configurations Bug: 217211205 Change-Id: I8fe8b0bd8b6c07393583d81540506a74eaa4fc10 --- .../res/layout/bubble_overflow_container.xml | 5 ++- .../Shell/res/layout/bubble_overflow_view.xml | 9 ++--- libs/WindowManager/Shell/res/values/dimen.xml | 13 ++++--- .../bubbles/BubbleOverflowContainerView.java | 34 ++++++++++++++----- .../wm/shell/bubbles/BubblePositioner.java | 20 +++++++---- 5 files changed, 54 insertions(+), 27 deletions(-) diff --git a/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml b/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml index 76fe3c9bb8627..cb516cdbe49b0 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml @@ -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"> diff --git a/libs/WindowManager/Shell/res/layout/bubble_overflow_view.xml b/libs/WindowManager/Shell/res/layout/bubble_overflow_view.xml index 05b15060946d0..78de76a5465bb 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_overflow_view.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_overflow_view.xml @@ -22,7 +22,6 @@ android:orientation="vertical"> + android:gravity="center_horizontal|top"/> diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 2c96786bb5215..ad38975f1f3a6 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -139,16 +139,21 @@ If this value changes then R.dimen.bubble_expanded_view_min_height in CtsVerifier should also be updated. --> 180dp - - 412dp + + 380dp 30dp 480dp 16dp - - 15dp + + 11dp + + 5dp + + 16dp 7dp diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java index 5e9d97f23c577..fcd0ed7308eff 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java @@ -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