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

Commit 97fcd7a0 authored by Mady Mellor's avatar Mady Mellor
Browse files

Flexible bubble sizing & fixed position

This will enable some stuff for taskbar & hopefully make customizations by
ARC++ easier??

- BubblePositioner now tracks the size of the bubble & bitmap within it.
  Have to use a multiplier to derive the size of a couple of things now
  (e.g. bitmap size)
- BubblePositioner now tracks the position of the bubble stack & allows
  a way to override / set a fixed position. If something is in fixed
  location, it is not draggable (however when expanded you can still
  drag individual bubbles to dismiss)
- BubblePositioner tracks some taskbar related info
- Rather than checking for "isLandscape" we want "showBubblesVertically"
  (e.g. device might not be landscape but should be vertical if taskbar)
- Fixes an animation issue where bubbles super-overshoot the y position
  when expanding vertically.

Bug: 167413172
Test: a lot of manual testing
Test: atest WMShellTest SystemUITests
Change-Id: I79948a4bd6b58fb3aa2f52e2553f3dfc31630cf1
parent cef78df6
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -16,14 +16,16 @@
  -->
<com.android.wm.shell.bubbles.BubbleMenuView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="#66000000"
    android:visibility="gone"
    android:id="@+id/bubble_menu_container">
    android:id="@+id/bubble_menu_container"
    tools:ignore="MissingClass">

    <FrameLayout
        android:layout_height="@dimen/individual_bubble_size"
        android:layout_height="@dimen/bubble_menu_item_height"
        android:layout_width="wrap_content"
        android:background="#FFFFFF"
        android:id="@+id/bubble_menu_view">
+2 −2
Original line number Diff line number Diff line
@@ -17,6 +17,6 @@
<com.android.wm.shell.bubbles.BadgedImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bubble_overflow_button"
    android:layout_width="@dimen/individual_bubble_size"
    android:layout_height="@dimen/individual_bubble_size"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/bubble_ic_overflow_button"/>
+2 −2
Original line number Diff line number Diff line
@@ -17,5 +17,5 @@
<com.android.wm.shell.bubbles.BadgedImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bubble_view"
    android:layout_width="@dimen/individual_bubble_size"
    android:layout_height="@dimen/individual_bubble_size"/>
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
+4 −2
Original line number Diff line number Diff line
@@ -99,12 +99,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">16dp</dimen>
    <!-- Size of individual bubbles. -->
    <dimen name="individual_bubble_size">60dp</dimen>
    <!-- Size of bubble bitmap. -->
    <dimen name="bubble_bitmap_size">52dp</dimen>
    <!-- Size of bubble icon bitmap. -->
    <dimen name="bubble_overflow_icon_bitmap_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. -->
@@ -136,6 +136,8 @@
    <dimen name="bubble_dismiss_slop">16dp</dimen>
    <!-- Height of button allowing users to adjust settings for bubbles. -->
    <dimen name="bubble_manage_button_height">48dp</dimen>
    <!-- Height of an item in the bubble manage menu. -->
    <dimen name="bubble_menu_item_height">60dp</dimen>
    <!-- Max width of the message bubble-->
    <dimen name="bubble_message_max_width">144dp</dimen>
    <!-- Min width of the message bubble -->
+17 −15
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.util.PathParser;
import android.widget.ImageView;

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

import java.util.EnumSet;
@@ -75,9 +74,8 @@ public class BadgedImageView extends ImageView {
    private boolean mDotIsAnimating = false;

    private BubbleViewProvider mBubble;
    private BubblePositioner mPositioner;

    private int mBubbleBitmapSize;
    private int mBubbleSize;
    private DotRenderer mDotRenderer;
    private DotRenderer.DrawParams mDrawParams;
    private boolean mOnLeft;
@@ -101,18 +99,21 @@ public class BadgedImageView extends ImageView {
    public BadgedImageView(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mBubbleBitmapSize = getResources().getDimensionPixelSize(R.dimen.bubble_bitmap_size);
        mBubbleSize = getResources().getDimensionPixelSize(R.dimen.individual_bubble_size);
        mDrawParams = new DotRenderer.DrawParams();

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

        setFocusable(true);
        setClickable(true);
    }

    public void initialize(BubblePositioner positioner) {
        mPositioner = positioner;

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

    public void showDotAndBadge(boolean onLeft) {
        removeDotSuppressionFlag(BadgedImageView.SuppressionFlag.BEHIND_STACK);
        animateDotBadgePositions(onLeft);
@@ -186,7 +187,8 @@ public class BadgedImageView extends ImageView {
     * @param iconPath The new icon path to use when calculating dot position.
     */
    void drawDot(Path iconPath) {
        mDotRenderer = new DotRenderer(mBubbleBitmapSize, iconPath, DEFAULT_PATH_SIZE);
        mDotRenderer = new DotRenderer(mPositioner.getBubbleBitmapSize(),
                iconPath, DEFAULT_PATH_SIZE);
        invalidate();
    }

@@ -310,13 +312,13 @@ public class BadgedImageView extends ImageView {

        bubbleCanvas.setDrawFilter(new PaintFlagsDrawFilter(DITHER_FLAG, FILTER_BITMAP_FLAG));
        bubbleCanvas.setBitmap(bubble);

        final int badgeSize = (int) (ICON_BADGE_SCALE * mBubbleSize);
        final int bubbleSize = bubble.getWidth();
        final int badgeSize = (int) (ICON_BADGE_SCALE * bubbleSize);
        if (mOnLeft) {
            badge.setBounds(0, mBubbleSize - badgeSize, badgeSize, mBubbleSize);
            badge.setBounds(0, bubbleSize - badgeSize, badgeSize, bubbleSize);
        } else {
            badge.setBounds(mBubbleSize - badgeSize, mBubbleSize - badgeSize,
                    mBubbleSize, mBubbleSize);
            badge.setBounds(bubbleSize - badgeSize, bubbleSize - badgeSize,
                    bubbleSize, bubbleSize);
        }
        badge.draw(bubbleCanvas);
        bubbleCanvas.setBitmap(null);
Loading