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

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

Merge "Fix layout crash & bubble anything with valid bubble metadata intent"

parents 065aac1a edd4ee1e
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -267,8 +267,9 @@ public class BubbleController {
            BubbleView bubble = (BubbleView) mInflater.inflate(
                    R.layout.bubble_view, mStackView, false /* attachToRoot */);
            bubble.setNotif(notif);
            if (shouldUseActivityView(mContext)) {
                bubble.setAppOverlayIntent(getAppOverlayIntent(notif));
            PendingIntent bubbleIntent = getValidBubbleIntent(notif);
            if (shouldUseActivityView(mContext) || bubbleIntent != null) {
                bubble.setBubbleIntent(getValidBubbleIntent(notif));
            }
            mBubbles.put(bubble.getKey(), bubble);
            mStackView.addBubble(bubble);
@@ -282,7 +283,7 @@ public class BubbleController {
    }

    @Nullable
    private PendingIntent getAppOverlayIntent(NotificationEntry notif) {
    private PendingIntent getValidBubbleIntent(NotificationEntry notif) {
        Notification notification = notif.notification.getNotification();
        if (canLaunchInActivityView(notification.getBubbleMetadata() != null
                ? notification.getBubbleMetadata().getIntent() : null)) {
+17 −1
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@ import android.view.WindowManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.ViewClippingUtil;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -225,6 +227,19 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
        notifyExpansionChanged(mExpandedBubble, true /* expanded */);
    }

    /**
     * Sets the entry that should be expanded and expands if needed.
     */
    @VisibleForTesting
    public void setExpandedBubble(NotificationEntry entry) {
        for (int i = 0; i < mBubbleContainer.getChildCount(); i++) {
            BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i);
            if (entry.equals(bv.getEntry())) {
                setExpandedBubble(bv);
            }
        }
    }

    /**
     * Adds a bubble to the top of the stack.
     *
@@ -456,7 +471,8 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
        if (mExpandedBubble.hasAppOverlayIntent()) {
            // Bubble with activity view expanded state
            ActivityView expandedView = mExpandedBubble.getActivityView();
            expandedView.setLayoutParams(new ViewGroup.LayoutParams(
            // XXX: gets added to linear layout
            expandedView.setLayoutParams(new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, mExpandedBubbleHeight));

            final PendingIntent intent = mExpandedBubble.getAppOverlayIntent();
+1 −1
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ public class BubbleView extends FrameLayout implements BubbleTouchHandler.Floati

    }

    public void setAppOverlayIntent(PendingIntent intent) {
    public void setBubbleIntent(PendingIntent intent) {
        mAppOverlayIntent = intent;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.bubbles;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.atLeastOnce;
@@ -160,6 +161,12 @@ public class BubbleControllerTest extends SysuiTestCase {
        stackView.expandStack();
        assertTrue(mBubbleController.isStackExpanded());

        stackView.setExpandedBubble(mRow.getEntry());
        assertEquals(stackView.getExpandedBubble().getEntry(), mRow.getEntry());

        stackView.setExpandedBubble(mRow2.getEntry());
        assertEquals(stackView.getExpandedBubble().getEntry(), mRow2.getEntry());

        mBubbleController.collapseStack();
        assertFalse(mBubbleController.isStackExpanded());
    }