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

Commit 4186cf1b authored by Ats Jenk's avatar Ats Jenk
Browse files

Fix bubble bar arrow visibility during animation

Bubble bar pointer arrow was being drawn outside of BubbleBarView
bounds.
This caused issues when alpha was applied to the BubbleBarView. With
alpha, BubbleBarView draw was clipped to its bounds and arrow was no
longer visible. This led to the arrow flickering during move animations.
Move animation updates alpha.
Move the pointer arrow inside the bounds of the bar view. Update the bar
height to include the arrow.
Update callers who rely on bubble bar content height to take into
account extra height for the arrow.

Bug: 313661121
Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT
Test: move bubble bar left and right, observe arrow is visible
Change-Id: I05866b5c944361b2f10437c3641527ed3c594047
parent 77b6225d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -41,9 +41,10 @@
    <com.android.launcher3.taskbar.bubbles.BubbleBarView
        android:id="@+id/taskbar_bubbles"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/bubblebar_size"
        android:layout_height="@dimen/bubblebar_size_with_pointer"
        android:layout_gravity="bottom|end"
        android:layout_marginHorizontal="@dimen/transient_taskbar_bottom_margin"
        android:paddingTop="@dimen/bubblebar_pointer_size"
        android:paddingEnd="@dimen/taskbar_icon_spacing"
        android:paddingStart="@dimen/taskbar_icon_spacing"
        android:visibility="gone"
+2 −0
Original line number Diff line number Diff line
@@ -413,6 +413,8 @@
    <dimen name="bubblebar_stashed_size">@dimen/transient_taskbar_stashed_height</dimen>
    <dimen name="bubblebar_stashed_handle_height">@dimen/taskbar_stashed_handle_height</dimen>
    <dimen name="bubblebar_pointer_size">8dp</dimen>
    <!-- Container size with pointer included: bubblebar_size + bubblebar_pointer_size -->
    <dimen name="bubblebar_size_with_pointer">80dp</dimen>
    <dimen name="bubblebar_elevation">1dp</dimen>
    <dimen name="bubblebar_hotseat_adjustment_threshold">90dp</dimen>

+23 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.graphics.Canvas
import android.graphics.Color
import android.graphics.ColorFilter
import android.graphics.Paint
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
import android.graphics.drawable.ShapeDrawable
import com.android.app.animation.Interpolators
@@ -122,14 +123,22 @@ class BubbleBarBackground(context: TaskbarActivityContext, private val backgroun

        // Draw background.
        val radius = backgroundHeight / 2f
        val left = if (anchorLeft) 0f else canvas.width.toFloat() - width
        val right = if (anchorLeft) width else canvas.width.toFloat()
        canvas.drawRoundRect(left, 0f, right, canvas.height.toFloat(), radius, radius, paint)
        val left = if (anchorLeft) 0f else bounds.width().toFloat() - width
        val right = if (anchorLeft) width else bounds.width().toFloat()
        canvas.drawRoundRect(
            left,
            pointerSize,
            right,
            bounds.height().toFloat(),
            radius,
            radius,
            paint
        )

        if (showingArrow) {
            // Draw arrow.
            val transX = arrowPositionX - pointerSize / 2f
            canvas.translate(transX, -pointerSize)
            canvas.translate(transX, 0f)
            arrowDrawable.draw(canvas)
        }

@@ -137,11 +146,20 @@ class BubbleBarBackground(context: TaskbarActivityContext, private val backgroun
    }

    override fun getOpacity(): Int {
        return paint.alpha
        return when (paint.alpha) {
            255 -> PixelFormat.OPAQUE
            0 -> PixelFormat.TRANSPARENT
            else -> PixelFormat.TRANSLUCENT
        }
    }

    override fun setAlpha(alpha: Int) {
        paint.alpha = alpha
        arrowDrawable.paint.alpha = alpha
    }

    override fun getAlpha(): Int {
        return paint.alpha
    }

    override fun setColorFilter(colorFilter: ColorFilter?) {
+1 −1
Original line number Diff line number Diff line
@@ -614,7 +614,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
            location.right = currentBarBounds.right;
        }
        final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY());
        location.top = displaySize.y - mBarView.getHeight() - translation;
        location.top = displaySize.y - currentBarBounds.height() - translation;
        location.bottom = displaySize.y - translation;
        return location;
    }
+6 −2
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ public class BubbleBarView extends FrameLayout {
    private final float mIconSize;
    // The elevation of the bubbles within the bar
    private final float mBubbleElevation;
    private final int mPointerSize;

    // Whether the bar is expanded (i.e. the bubble activity is being displayed).
    private boolean mIsBarExpanded = false;
@@ -166,6 +167,8 @@ public class BubbleBarView extends FrameLayout {
        mIconSpacing = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_spacing);
        mIconSize = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_size);
        mBubbleElevation = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_elevation);
        mPointerSize = getResources().getDimensionPixelSize(R.dimen.bubblebar_pointer_size);

        setClipToPadding(false);

        mBubbleBarBackground = new BubbleBarBackground(activityContext,
@@ -214,7 +217,7 @@ public class BubbleBarView extends FrameLayout {
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        mBubbleBarBounds.left = left;
        mBubbleBarBounds.top = top;
        mBubbleBarBounds.top = top + mPointerSize;
        mBubbleBarBounds.right = right;
        mBubbleBarBounds.bottom = bottom;

@@ -272,6 +275,7 @@ public class BubbleBarView extends FrameLayout {
        if (bubbleBarLocation != mBubbleBarLocation) {
            mBubbleBarLocation = bubbleBarLocation;
            onBubbleBarLocationChanged();
            invalidate();
        }
    }

@@ -344,7 +348,7 @@ public class BubbleBarView extends FrameLayout {
     * Updates the bounds with translation that may have been applied and returns the result.
     */
    public Rect getBubbleBarBounds() {
        mBubbleBarBounds.top = getTop() + (int) getTranslationY();
        mBubbleBarBounds.top = getTop() + (int) getTranslationY() + mPointerSize;
        mBubbleBarBounds.bottom = getBottom() + (int) getTranslationY();
        return mBubbleBarBounds;
    }
Loading