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

Commit ca346975 authored by Mady Mellor's avatar Mady Mellor
Browse files

Use the bubble type to determine if the app badge is shown

This is really determined by type, not this launch intent
check.

Added tests for each type case.

Flag: EXEMPT minor bugfix
Test: atest BubbleTest
Bug: 393646910
Change-Id: I4c3371954391853241d508a2c7825d446f8b3ad9
parent c54de25c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -357,9 +357,9 @@ public class BadgedImageView extends ConstraintLayout {

    void showBadge() {
        Bitmap appBadgeBitmap = mBubble.getAppBadge();
        final boolean isAppLaunchIntent = (mBubble instanceof Bubble)
                && ((Bubble) mBubble).isAppLaunchIntent();
        if (appBadgeBitmap == null || isAppLaunchIntent) {
        final boolean showAppBadge = (mBubble instanceof Bubble)
                && ((Bubble) mBubble).showAppBadge();
        if (appBadgeBitmap == null || !showAppBadge) {
            mAppIcon.setVisibility(GONE);
            return;
        }
+4 −9
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView;
import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.bubbles.BubbleAnythingFlagHelper;
import com.android.wm.shell.shared.bubbles.BubbleInfo;
import com.android.wm.shell.shared.bubbles.ParcelableFlyoutMessage;
import com.android.wm.shell.taskview.TaskView;
@@ -439,7 +438,7 @@ public class Bubble implements BubbleViewProvider {
                getTitle(),
                getAppName(),
                isImportantConversation(),
                !isAppLaunchIntent(),
                showAppBadge(),
                getParcelableFlyoutMessage());
    }

@@ -1124,14 +1123,10 @@ public class Bubble implements BubbleViewProvider {
    }

    /**
     * Whether this bubble represents the full app, i.e. the intent used is the launch
     * intent for an app. In this case we don't show a badge on the icon.
     * Whether an app badge should be shown for this bubble.
     */
    public boolean isAppLaunchIntent() {
        if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mIntent != null) {
            return mIntent.hasCategory("android.intent.category.LAUNCHER");
        }
        return false;
    public boolean showAppBadge() {
        return isChat() || isShortcut() || isNote();
    }

    /**
+36 −0
Original line number Diff line number Diff line
@@ -233,6 +233,42 @@ public class BubbleTest extends ShellTestCase {
        assertThat(bubble.isApp()).isTrue();
    }

    @Test
    public void testShowAppBadge_chat() {
        Bubble bubble = createChatBubble(true /* useShortcut */);
        assertThat(bubble.isChat()).isTrue();
        assertThat(bubble.showAppBadge()).isTrue();
    }

    @Test
    public void testShowAppBadge_note() {
        Bubble bubble = Bubble.createNotesBubble(createIntent(), UserHandle.of(0),
                mock(Icon.class),
                mMainExecutor, mBgExecutor);
        assertThat(bubble.isNote()).isTrue();
        assertThat(bubble.showAppBadge()).isTrue();
    }

    @Test
    public void testShowAppBadge_app() {
        Bubble bubble = Bubble.createAppBubble(createIntent(), UserHandle.of(0),
                mock(Icon.class),
                mMainExecutor, mBgExecutor);
        assertThat(bubble.isApp()).isTrue();
        assertThat(bubble.showAppBadge()).isFalse();
    }

    @Test
    public void testShowAppBadge_shortcut() {
        ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(mContext)
                .setId("mockShortcutId")
                .build();
        Bubble bubble = Bubble.createShortcutBubble(shortcutInfo,
                mMainExecutor, mBgExecutor);
        assertThat(bubble.isShortcut()).isTrue();
        assertThat(bubble.showAppBadge()).isTrue();
    }

    @Test
    public void testBubbleAsBubbleBarBubble_withShortcut() {
        Bubble bubble = createChatBubble(true /* useShortcut */);