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

Commit 70e798e4 authored by Mady Mellor's avatar Mady Mellor
Browse files

Make the pointer for bubbles expanded view rounded

Test: manual - open a bubble and note that the pointer is rounded
Bug: 183658029
Change-Id: I65f460289dc7128aa95e9ad7575a3bb39be629bf
parent 7376a67a
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -139,10 +139,15 @@
    <dimen name="bubble_empty_overflow_image_height">200dp</dimen>
    <!-- Padding of bubble overflow empty state subtitle -->
    <dimen name="bubble_empty_overflow_subtitle_padding">50dp</dimen>
    <!-- Height of the triangle that points to the expanded bubble -->
    <dimen name="bubble_pointer_height">8dp</dimen>
    <!-- Width of the triangle that points to the expanded bubble -->
    <!-- Height of the triangle that points to the expanded bubble. -->
    <dimen name="bubble_pointer_height">10dp</dimen>
    <!-- Width of the triangle that points to the expanded bubble. -->
    <dimen name="bubble_pointer_width">12dp</dimen>
    <!-- Radius of the pointer -->
    <dimen name="bubble_pointer_radius">2dp</dimen>
    <!-- The amount the pointer overlaps with the expanded view to be flush on an edge with
         a radius. -->
    <dimen name="bubble_pointer_overlap">1dp</dimen>
    <!-- Extra padding around the dismiss target for bubbles -->
    <dimen name="bubble_dismiss_slop">16dp</dimen>
    <!-- Height of button allowing users to adjust settings for bubbles. -->
+25 −8
Original line number Diff line number Diff line
@@ -39,7 +39,9 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.CornerPathEffect;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.Rect;
import android.graphics.drawable.ShapeDrawable;
@@ -105,6 +107,9 @@ public class BubbleExpandedView extends LinearLayout {
    private int mSettingsIconHeight;
    private int mPointerWidth;
    private int mPointerHeight;
    private float mPointerRadius;
    private float mPointerOverlap;
    private CornerPathEffect mPointerEffect;
    private ShapeDrawable mCurrentPointer;
    private ShapeDrawable mTopPointer;
    private ShapeDrawable mLeftPointer;
@@ -348,7 +353,9 @@ public class BubbleExpandedView extends LinearLayout {
        mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin);
        mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
        mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);

        mPointerRadius = getResources().getDimensionPixelSize(R.dimen.bubble_pointer_radius);
        mPointerEffect = new CornerPathEffect(mPointerRadius);
        mPointerOverlap = getResources().getDimensionPixelSize(R.dimen.bubble_pointer_overlap);
        mTopPointer = new ShapeDrawable(TriangleShape.create(
                mPointerWidth, mPointerHeight, true /* pointUp */));
        mLeftPointer = new ShapeDrawable(TriangleShape.createHorizontal(
@@ -408,8 +415,12 @@ public class BubbleExpandedView extends LinearLayout {
            lp.width = mPointerWidth;
            lp.height = mPointerHeight;
        }
        mPointerView.setLayoutParams(lp);
        mCurrentPointer.setTint(mBackgroundColorFloating);

        Paint arrowPaint = mCurrentPointer.getPaint();
        arrowPaint.setColor(mBackgroundColorFloating);
        arrowPaint.setPathEffect(mPointerEffect);
        mPointerView.setLayoutParams(lp);
        mPointerView.setBackground(mCurrentPointer);
    }

@@ -701,10 +712,14 @@ public class BubbleExpandedView extends LinearLayout {
    public void setPointerPosition(float bubblePosition, boolean onLeft) {
        // Pointer gets drawn in the padding
        final boolean showVertically = mPositioner.showBubblesVertically();
        final int paddingLeft = (showVertically && onLeft) ? mPointerHeight : 0;
        final int paddingRight = (showVertically && !onLeft) ? mPointerHeight : 0;
        final int paddingTop = showVertically ? 0 : mExpandedViewPadding;
        setPadding(paddingLeft, paddingTop, paddingRight, 0);
        final float paddingLeft = (showVertically && onLeft)
                ? mPointerHeight - mPointerOverlap
                : 0;
        final float paddingRight = (showVertically && !onLeft)
                ? mPointerHeight - mPointerOverlap : 0;
        final int paddingTop = showVertically ? 0
                : mExpandedViewPadding;
        setPadding((int) paddingLeft, paddingTop, (int) paddingRight, 0);

        final float expandedViewY = mPositioner.getExpandedViewY();
        final float bubbleSize = mPositioner.getBubbleBitmapSize();
@@ -717,9 +732,11 @@ public class BubbleExpandedView extends LinearLayout {
            float pointerX;
            if (showVertically) {
                pointerY = bubbleCenter - (mPointerWidth / 2f);
                pointerX = onLeft ? -mPointerHeight : getWidth() - mPaddingRight;
                pointerX = onLeft
                        ? -mPointerHeight + mPointerOverlap
                        : getWidth() - mPaddingRight - mPointerOverlap;
            } else {
                pointerY = 0;
                pointerY = mPointerOverlap;
                pointerX = bubbleCenter - mPaddingLeft - (mPointerWidth / 2f);
            }
            mPointerView.setTranslationY(pointerY);