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

Commit 0ae52c98 authored by Brandon Dayauon's avatar Brandon Dayauon
Browse files

Make DISPLAY_SEARCH_RESULT_SMALL not badged

bug: 299364813
Test:Manual -
before: https://drive.google.com/file/d/1Gb_bV5oIEPAvNYnqMJwscX-r1iz967eY/view?usp=sharing
after: https://drive.google.com/file/d/1GTH1A8biVAVnWXaArMkdzWK9kiwFhVCn/view?usp=sharing

Flag: n/a
Change-Id: I6e928079d53bfa7f87cde4d420ee05b1edf875f5
parent fb607d67
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -387,10 +387,12 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        setTag(itemInfo);
    }

    @VisibleForTesting
    @UiThread
    protected void applyIconAndLabel(ItemInfoWithIcon info) {
    public void applyIconAndLabel(ItemInfoWithIcon info) {
        int flags = shouldUseTheme() ? FLAG_THEMED : 0;
        if (mHideBadge) {
        // Remove badge on icons smaller than 48dp.
        if (mHideBadge || mDisplay == DISPLAY_SEARCH_RESULT_SMALL) {
            flags |= FLAG_NO_BADGE;
        }
        FastBitmapDrawable iconDrawable = info.newIcon(getContext(), flags);
+39 −0
Original line number Diff line number Diff line
@@ -20,21 +20,30 @@ import static androidx.test.core.app.ApplicationProvider.getApplicationContext;

import static com.android.launcher3.BubbleTextView.DISPLAY_ALL_APPS;
import static com.android.launcher3.BubbleTextView.DISPLAY_PREDICTION_ROW;
import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT;
import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT_SMALL;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.platform.test.flag.junit.SetFlagsRule;
import android.os.UserHandle;
import android.view.ViewGroup;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Flags;
import com.android.launcher3.Utilities;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.search.StringMatcherUtility;
import com.android.launcher3.util.ActivityContextWrapper;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.views.BaseDragLayer;

@@ -55,6 +64,8 @@ public class BubbleTextViewTest {
    @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
    private static final StringMatcherUtility.StringMatcher
            MATCHER = StringMatcherUtility.StringMatcher.getInstance();
    private static final UserHandle WORK_HANDLE = new UserHandle(13);
    private static final int WORK_FLAG = 1;
    private static final int ONE_LINE = 1;
    private static final int TWO_LINE = 2;
    private static final String TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT = "Battery Stats";
@@ -81,6 +92,7 @@ public class BubbleTextViewTest {
    private ItemInfoWithIcon mItemInfoWithIcon;
    private Context mContext;
    private int mLimitedWidth;
    private AppInfo mGmailAppInfo;

    @Before
    public void setUp() throws Exception {
@@ -109,6 +121,9 @@ public class BubbleTextViewTest {
                return null;
            }
        };
        ComponentName componentName = new ComponentName(mContext,
                "com.android.launcher3.tests.Activity" + "Gmail");
        mGmailAppInfo = new AppInfo(componentName, "Gmail", WORK_HANDLE, new Intent());
    }

    @Test
@@ -358,4 +373,28 @@ public class BubbleTextViewTest {

        assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
    }

    @Test
    public void applyIconAndLabel_whenDisplay_DISPLAY_SEARCH_RESULT_SMALL_noBadge() {
        FlagOp op = FlagOp.NO_OP;
        // apply the WORK bitmap flag to show work badge
        mGmailAppInfo.bitmap.flags = op.apply(WORK_FLAG);
        mBubbleTextView.setDisplay(DISPLAY_SEARCH_RESULT_SMALL);

        mBubbleTextView.applyIconAndLabel(mGmailAppInfo);

        assertThat(mBubbleTextView.getIcon().hasBadge()).isEqualTo(false);
    }

    @Test
    public void applyIconAndLabel_whenDisplay_DISPLAY_SEARCH_RESULT_hasBadge() {
        FlagOp op = FlagOp.NO_OP;
        // apply the WORK bitmap flag to show work badge
        mGmailAppInfo.bitmap.flags = op.apply(WORK_FLAG);
        mBubbleTextView.setDisplay(DISPLAY_SEARCH_RESULT);

        mBubbleTextView.applyIconAndLabel(mGmailAppInfo);

        assertThat(mBubbleTextView.getIcon().hasBadge()).isEqualTo(true);
    }
}