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

Commit 37aafac3 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Restrict the width of bubble expanded view on large screens" into sc-dev am: 23f3d341

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

Change-Id: I0526bf39d79e0f79a757f80b73f991ab729584dd
parents ea88d955 23f3d341
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -27,24 +27,26 @@


    <androidx.recyclerview.widget.RecyclerView
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/bubble_overflow_recycler"
        android:id="@+id/bubble_overflow_recycler"
        android:layout_gravity="center_horizontal"
        android:nestedScrollingEnabled="false"
        android:nestedScrollingEnabled="false"
        android:layout_width="wrap_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:gravity="center"/>


    <LinearLayout
    <LinearLayout
        android:id="@+id/bubble_overflow_empty_state"
        android:id="@+id/bubble_overflow_empty_state"
        android:layout_width="wrap_content"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/bubble_overflow_empty_state_padding"
        android:paddingLeft="@dimen/bubble_overflow_empty_state_padding"
        android:paddingRight="@dimen/bubble_overflow_empty_state_padding"
        android:paddingRight="@dimen/bubble_overflow_empty_state_padding"
        android:orientation="vertical"
        android:orientation="vertical"
        android:gravity="center">
        android:gravity="center">


        <ImageView
        <ImageView
            android:id="@+id/bubble_overflow_empty_state_image"
            android:layout_width="@dimen/bubble_empty_overflow_image_height"
            android:layout_width="@dimen/bubble_empty_overflow_image_height"
            android:layout_height="@dimen/bubble_empty_overflow_image_height"
            android:layout_height="@dimen/bubble_empty_overflow_image_height"
            android:id="@+id/bubble_overflow_empty_state_image"
            android:scaleType="fitCenter"
            android:scaleType="fitCenter"
            android:layout_gravity="center"/>
            android:layout_gravity="center"/>


@@ -60,12 +62,12 @@


        <TextView
        <TextView
            android:id="@+id/bubble_overflow_empty_subtitle"
            android:id="@+id/bubble_overflow_empty_subtitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="@*android:string/config_bodyFontFamily"
            android:fontFamily="@*android:string/config_bodyFontFamily"
            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
            android:textColor="?android:attr/textColorSecondary"
            android:textColor="?android:attr/textColorSecondary"
            android:text="@string/bubble_overflow_empty_subtitle"
            android:text="@string/bubble_overflow_empty_subtitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/bubble_empty_overflow_subtitle_padding"
            android:paddingBottom="@dimen/bubble_empty_overflow_subtitle_padding"
            android:gravity="center"/>
            android:gravity="center"/>
    </LinearLayout>
    </LinearLayout>
+3 −1
Original line number Original line Diff line number Diff line
@@ -32,12 +32,14 @@
        android:id="@+id/bubble_view_name"
        android:id="@+id/bubble_view_name"
        android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
        android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
        android:textSize="13sp"
        android:textSize="13sp"
        android:layout_width="fill_parent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:maxLines="1"
        android:lines="2"
        android:lines="2"
        android:ellipsize="end"
        android:ellipsize="end"
        android:layout_gravity="center"
        android:layout_gravity="center"
        android:paddingTop="@dimen/bubble_overflow_text_padding"
        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"/>
</LinearLayout>
</LinearLayout>
+3 −1
Original line number Original line Diff line number Diff line
@@ -125,7 +125,9 @@
    <dimen name="bubble_expanded_view_slop">8dp</dimen>
    <dimen name="bubble_expanded_view_slop">8dp</dimen>
    <!-- Default (and minimum) height of the expanded view shown when the bubble is expanded -->
    <!-- Default (and minimum) height of the expanded view shown when the bubble is expanded -->
    <dimen name="bubble_expanded_default_height">180dp</dimen>
    <dimen name="bubble_expanded_default_height">180dp</dimen>
    <!-- Default height of bubble overflow -->
    <!-- On large screens the width of the expanded view is restricted to this size. -->
    <dimen name="bubble_expanded_view_tablet_width">412dp</dimen>
    <!-- Default (and minimum) height of bubble overflow -->
    <dimen name="bubble_overflow_height">480dp</dimen>
    <dimen name="bubble_overflow_height">480dp</dimen>
    <!-- Bubble overflow padding when there are no bubbles  -->
    <!-- Bubble overflow padding when there are no bubbles  -->
    <dimen name="bubble_overflow_empty_state_padding">16dp</dimen>
    <dimen name="bubble_overflow_empty_state_padding">16dp</dimen>
+8 −4
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.bubbles;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;


import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPANDED_VIEW;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPANDED_VIEW;
@@ -335,7 +336,10 @@ public class BubbleExpandedView extends LinearLayout {
            mOverflowView = (BubbleOverflowContainerView) LayoutInflater.from(getContext()).inflate(
            mOverflowView = (BubbleOverflowContainerView) LayoutInflater.from(getContext()).inflate(
                    R.layout.bubble_overflow_container, null /* root */);
                    R.layout.bubble_overflow_container, null /* root */);
            mOverflowView.setBubbleController(mController);
            mOverflowView.setBubbleController(mController);
            mExpandedViewContainer.addView(mOverflowView);
            FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
            mExpandedViewContainer.addView(mOverflowView, lp);
            mExpandedViewContainer.setLayoutParams(
                    new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
            bringChildToFront(mOverflowView);
            bringChildToFront(mOverflowView);
            mSettingsIcon.setVisibility(GONE);
            mSettingsIcon.setVisibility(GONE);
        } else {
        } else {
@@ -600,9 +604,9 @@ public class BubbleExpandedView extends LinearLayout {
            return;
            return;
        }
        }


        if (mBubble != null || mIsOverflow) {
        if ((mBubble != null && mTaskView != null) || mIsOverflow) {
            float desiredHeight = mIsOverflow
            float desiredHeight = mIsOverflow
                    ? mOverflowHeight
                    ? mPositioner.isLargeScreen() ? getMaxExpandedHeight() : mOverflowHeight
                    : mBubble.getDesiredHeight(mContext);
                    : mBubble.getDesiredHeight(mContext);
            desiredHeight = Math.max(desiredHeight, mMinHeight);
            desiredHeight = Math.max(desiredHeight, mMinHeight);
            float height = Math.min(desiredHeight, getMaxExpandedHeight());
            float height = Math.min(desiredHeight, getMaxExpandedHeight());
@@ -657,10 +661,10 @@ public class BubbleExpandedView extends LinearLayout {
                    + getBubbleKey());
                    + getBubbleKey());
        }
        }
        mExpandedViewContainerLocation = containerLocationOnScreen;
        mExpandedViewContainerLocation = containerLocationOnScreen;
        updateHeight();
        if (mTaskView != null
        if (mTaskView != null
                && mTaskView.getVisibility() == VISIBLE
                && mTaskView.getVisibility() == VISIBLE
                && mTaskView.isAttachedToWindow()) {
                && mTaskView.isAttachedToWindow()) {
            updateHeight();
            mTaskView.onLocationChanged();
            mTaskView.onLocationChanged();
        }
        }
        if (mIsOverflow) {
        if (mIsOverflow) {
+14 −49
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
@@ -51,8 +50,6 @@ import java.util.function.Consumer;
 * Container view for showing aged out bubbles.
 * Container view for showing aged out bubbles.
 */
 */
public class BubbleOverflowContainerView extends LinearLayout {
public class BubbleOverflowContainerView extends LinearLayout {
    static final String EXTRA_BUBBLE_CONTROLLER = "bubble_controller";

    private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleOverflowActivity" : TAG_BUBBLES;
    private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleOverflowActivity" : TAG_BUBBLES;


    private LinearLayout mEmptyState;
    private LinearLayout mEmptyState;
@@ -64,18 +61,16 @@ public class BubbleOverflowContainerView extends LinearLayout {
    private RecyclerView mRecyclerView;
    private RecyclerView mRecyclerView;
    private List<Bubble> mOverflowBubbles = new ArrayList<>();
    private List<Bubble> mOverflowBubbles = new ArrayList<>();


    private class NoScrollGridLayoutManager extends GridLayoutManager {
    private class OverflowGridLayoutManager extends GridLayoutManager {
        NoScrollGridLayoutManager(Context context, int columns) {
        OverflowGridLayoutManager(Context context, int columns) {
            super(context, columns);
            super(context, columns);
        }
        }
        @Override

        public boolean canScrollVertically() {
//        @Override
            if (getResources().getConfiguration().orientation
//        public boolean canScrollVertically() {
                    == Configuration.ORIENTATION_LANDSCAPE) {
//            // TODO (b/162006693): this should be based on items in the list & available height
                return super.canScrollVertically();
//            return true;
            }
//        }
            return false;
        }


        @Override
        @Override
        public int getColumnCountForAccessibility(RecyclerView.Recycler recycler,
        public int getColumnCountForAccessibility(RecyclerView.Recycler recycler,
@@ -137,47 +132,24 @@ public class BubbleOverflowContainerView extends LinearLayout {
        Resources res = getResources();
        Resources res = getResources();
        final int columns = res.getInteger(R.integer.bubbles_overflow_columns);
        final int columns = res.getInteger(R.integer.bubbles_overflow_columns);
        mRecyclerView.setLayoutManager(
        mRecyclerView.setLayoutManager(
                new NoScrollGridLayoutManager(getContext(), columns));
                new OverflowGridLayoutManager(getContext(), columns));

        DisplayMetrics displayMetrics = new DisplayMetrics();
        getContext().getDisplay().getMetrics(displayMetrics);

        final int overflowPadding = res.getDimensionPixelSize(R.dimen.bubble_overflow_padding);
        final int recyclerViewWidth = displayMetrics.widthPixels - (overflowPadding * 2);
        final int viewWidth = recyclerViewWidth / columns;

        final int maxOverflowBubbles = res.getInteger(R.integer.bubbles_max_overflow);
        final int rows = (int) Math.ceil((double) maxOverflowBubbles / columns);
        final int recyclerViewHeight = res.getDimensionPixelSize(R.dimen.bubble_overflow_height)
                - res.getDimensionPixelSize(R.dimen.bubble_overflow_padding);
        final int viewHeight = recyclerViewHeight / rows;

        mAdapter = new BubbleOverflowAdapter(getContext(), mOverflowBubbles,
        mAdapter = new BubbleOverflowAdapter(getContext(), mOverflowBubbles,
                mController::promoteBubbleFromOverflow,
                mController::promoteBubbleFromOverflow,
                mController.getPositioner(),
                mController.getPositioner());
                viewWidth, viewHeight);
        mRecyclerView.setAdapter(mAdapter);
        mRecyclerView.setAdapter(mAdapter);


        mOverflowBubbles.clear();
        mOverflowBubbles.clear();
        mOverflowBubbles.addAll(mController.getOverflowBubbles());
        mOverflowBubbles.addAll(mController.getOverflowBubbles());
        mAdapter.notifyDataSetChanged();
        mAdapter.notifyDataSetChanged();


        // Currently BubbleExpandedView.mExpandedViewContainer is WRAP_CONTENT so use the same
        // width we would use for the recycler view
        LayoutParams lp = (LayoutParams) mEmptyState.getLayoutParams();
        lp.width = recyclerViewWidth;
        updateEmptyStateVisibility();

        mController.setOverflowListener(mDataListener);
        mController.setOverflowListener(mDataListener);
        updateEmptyStateVisibility();
        updateTheme();
        updateTheme();
    }
    }


    void updateEmptyStateVisibility() {
    void updateEmptyStateVisibility() {
        if (mOverflowBubbles.isEmpty()) {
        mEmptyState.setVisibility(mOverflowBubbles.isEmpty() ? View.VISIBLE : View.GONE);
            mEmptyState.setVisibility(View.VISIBLE);
        mRecyclerView.setVisibility(mOverflowBubbles.isEmpty() ? View.GONE : View.VISIBLE);
        } else {
            mEmptyState.setVisibility(View.GONE);
        }
    }
    }


    /**
    /**
@@ -258,20 +230,15 @@ class BubbleOverflowAdapter extends RecyclerView.Adapter<BubbleOverflowAdapter.V
    private Consumer<Bubble> mPromoteBubbleFromOverflow;
    private Consumer<Bubble> mPromoteBubbleFromOverflow;
    private BubblePositioner mPositioner;
    private BubblePositioner mPositioner;
    private List<Bubble> mBubbles;
    private List<Bubble> mBubbles;
    private int mWidth;
    private int mHeight;


    BubbleOverflowAdapter(Context context,
    BubbleOverflowAdapter(Context context,
            List<Bubble> list,
            List<Bubble> list,
            Consumer<Bubble> promoteBubble,
            Consumer<Bubble> promoteBubble,
            BubblePositioner positioner,
            BubblePositioner positioner) {
            int width, int height) {
        mContext = context;
        mContext = context;
        mBubbles = list;
        mBubbles = list;
        mPromoteBubbleFromOverflow = promoteBubble;
        mPromoteBubbleFromOverflow = promoteBubble;
        mPositioner = positioner;
        mPositioner = positioner;
        mWidth = width;
        mHeight = height;
    }
    }


    @Override
    @Override
@@ -284,8 +251,6 @@ class BubbleOverflowAdapter extends RecyclerView.Adapter<BubbleOverflowAdapter.V
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.width = mWidth;
        params.height = mHeight;
        overflowView.setLayoutParams(params);
        overflowView.setLayoutParams(params);


        // Ensure name has enough contrast.
        // Ensure name has enough contrast.
Loading