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

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

Merge changes I4794ed89,I0c273f4d,Ibd8609a8 into sc-dev

* changes:
  Flexible maximum number of bubbles to show
  Add shadows back to bubble avatar
  Update sizes for the bubble avatar
parents 519fcc51 238f122f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/bubble_view"
        android:layout_gravity="center"
        android:layout_width="@dimen/individual_bubble_size"
        android:layout_height="@dimen/individual_bubble_size"/>
        android:layout_width="@dimen/bubble_size"
        android:layout_height="@dimen/bubble_size"/>

    <TextView
        android:id="@+id/bubble_view_name"
+9 −7
Original line number Diff line number Diff line
@@ -101,12 +101,12 @@
    <dimen name="bubble_flyout_avatar_message_space">6dp</dimen>
    <!-- Padding between status bar and bubbles when displayed in expanded state -->
    <dimen name="bubble_padding_top">16dp</dimen>
    <!-- Max amount of space between bubbles when expanded. -->
    <dimen name="bubble_max_spacing">8dp</dimen>
    <!-- Size of individual bubbles. -->
    <dimen name="individual_bubble_size">60dp</dimen>
    <!-- Size of bubble bitmap. -->
    <dimen name="bubble_bitmap_size">52dp</dimen>
    <!-- Space between bubbles when expanded. -->
    <dimen name="bubble_spacing">3dp</dimen>
    <!-- Size of the bubble. -->
    <dimen name="bubble_size">60dp</dimen>
    <!-- Size of the badge shown on the bubble. -->
    <dimen name="bubble_badge_size">24dp</dimen>
    <!-- Extra padding added to the touchable rect for bubbles so they are easier to grab. -->
    <dimen name="bubble_touch_padding">12dp</dimen>
    <!-- Size of the circle around the bubbles when they're in the dismiss target. -->
@@ -120,6 +120,8 @@
    <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_tablet_width">412dp</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  -->
@@ -154,7 +156,7 @@
    <!-- Interior padding of the message bubble -->
    <dimen name="bubble_message_padding">4dp</dimen>
    <!-- Offset between bubbles in their stacked position. -->
    <dimen name="bubble_stack_offset">10dp</dimen>
    <dimen name="bubble_stack_offset">12dp</dimen>
    <!-- Offset between stack y and animation y for bubble swap. -->
    <dimen name="bubble_swap_animation_offset">15dp</dimen>
    <!-- How far offscreen the bubble stack rests. There's some padding around the bubble so
+19 −2
Original line number Diff line number Diff line
@@ -23,15 +23,19 @@ import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.PathParser;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;

import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.IconNormalizer;
import com.android.wm.shell.animation.Interpolators;

import java.util.EnumSet;
@@ -104,6 +108,19 @@ public class BadgedImageView extends ImageView {

        setFocusable(true);
        setClickable(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                BadgedImageView.this.getOutline(outline);
            }
        });
    }

    private void getOutline(Outline outline) {
        final int bubbleSize = mPositioner.getBubbleSize();
        final int normalizedSize = IconNormalizer.getNormalizedCircleSize(bubbleSize);
        final int inset = (bubbleSize - normalizedSize) / 2;
        outline.setOval(inset, inset, inset + normalizedSize, inset + normalizedSize);
    }

    public void initialize(BubblePositioner positioner) {
@@ -111,7 +128,7 @@ public class BadgedImageView extends ImageView {

        Path iconPath = PathParser.createPathFromPathData(
                getResources().getString(com.android.internal.R.string.config_icon_mask));
        mDotRenderer = new DotRenderer(mPositioner.getBubbleBitmapSize(),
        mDotRenderer = new DotRenderer(mPositioner.getBubbleSize(),
                iconPath, DEFAULT_PATH_SIZE);
    }

@@ -192,7 +209,7 @@ public class BadgedImageView extends ImageView {
     * @param iconPath The new icon path to use when calculating dot position.
     */
    void drawDot(Path iconPath) {
        mDotRenderer = new DotRenderer(mPositioner.getBubbleBitmapSize(),
        mDotRenderer = new DotRenderer(mPositioner.getBubbleSize(),
                iconPath, DEFAULT_PATH_SIZE);
        invalidate();
    }
+1 −0
Original line number Diff line number Diff line
@@ -722,6 +722,7 @@ public class BubbleController {
                    || !newConfig.windowConfiguration.getBounds().equals(mScreenBounds)) {
                mDensityDpi = newConfig.densityDpi;
                mScreenBounds.set(newConfig.windowConfiguration.getBounds());
                mBubbleData.onMaxBubblesChanged();
                mBubbleIconFactory = new BubbleIconFactory(mContext);
                mStackView.onDisplaySizeChanged();
            }
+26 −4
Original line number Diff line number Diff line
@@ -141,9 +141,11 @@ public class BubbleData {
    private final BubbleOverflow mOverflow;
    private boolean mShowingOverflow;
    private boolean mExpanded;
    private final int mMaxBubbles;
    private int mMaxBubbles;
    private int mMaxOverflowBubbles;

    private boolean mNeedsTrimming;

    // State tracked during an operation -- keeps track of what listener events to dispatch.
    private Update mStateChange;

@@ -180,7 +182,7 @@ public class BubbleData {
        mOverflowBubbles = new ArrayList<>();
        mPendingBubbles = new HashMap<>();
        mStateChange = new Update(mBubbles, mOverflowBubbles);
        mMaxBubbles = mContext.getResources().getInteger(R.integer.bubbles_max_rendered);
        mMaxBubbles = mPositioner.getMaxBubbles();
        mMaxOverflowBubbles = mContext.getResources().getInteger(R.integer.bubbles_max_overflow);
    }

@@ -194,6 +196,16 @@ public class BubbleData {
        mCancelledListener = listener;
    }

    public void onMaxBubblesChanged() {
        mMaxBubbles = mPositioner.getMaxBubbles();
        if (!mExpanded) {
            trim();
            dispatchPendingChanges();
        } else {
            mNeedsTrimming = true;
        }
    }

    public boolean hasBubbles() {
        return !mBubbles.isEmpty();
    }
@@ -455,13 +467,19 @@ public class BubbleData {

    private void trim() {
        if (mBubbles.size() > mMaxBubbles) {
            int numtoRemove = mBubbles.size() - mMaxBubbles;
            ArrayList<Bubble> toRemove = new ArrayList<>();
            mBubbles.stream()
                    // sort oldest first (ascending lastActivity)
                    .sorted(Comparator.comparingLong(Bubble::getLastActivity))
                    // skip the selected bubble
                    .filter((b) -> !b.equals(mSelectedBubble))
                    .findFirst()
                    .ifPresent((b) -> doRemove(b.getKey(), Bubbles.DISMISS_AGED));
                    .forEachOrdered((b) -> {
                        if (toRemove.size() < numtoRemove) {
                            toRemove.add(b);
                        }
                    });
            toRemove.forEach((b) -> doRemove(b.getKey(), Bubbles.DISMISS_AGED));
        }
    }

@@ -770,6 +788,10 @@ public class BubbleData {
                }
            }
        }
        if (mNeedsTrimming) {
            mNeedsTrimming = false;
            trim();
        }
        mExpanded = shouldExpand;
        mStateChange.expanded = shouldExpand;
        mStateChange.expandedChanged = true;
Loading