From 00fb1adab40581d46c7cebac973f6a71fa55eebb Mon Sep 17 00:00:00 2001 From: Charlie Anderson Date: Wed, 31 Jul 2024 14:08:16 +0000 Subject: [PATCH] Revert "Handles Bold Text setting for inline icon by providing bolded cloud icon" This reverts commit 114e84908fb399b65328b4261fd67ad6b23f6714. Reason for revert: b/356166053 Change-Id: I30dfbc5da1caecd89b4b23aafe4de8e9efede6a0 --- res/drawable/cloud_download_semibold_24px.xml | 11 --- src/com/android/launcher3/BubbleTextView.java | 29 ++------ .../launcher3/ui/BubbleTextViewTest.java | 68 ------------------- 3 files changed, 5 insertions(+), 103 deletions(-) delete mode 100644 res/drawable/cloud_download_semibold_24px.xml diff --git a/res/drawable/cloud_download_semibold_24px.xml b/res/drawable/cloud_download_semibold_24px.xml deleted file mode 100644 index ef15f9f735..0000000000 --- a/res/drawable/cloud_download_semibold_24px.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 5134dbe232..0cb213759a 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -16,8 +16,6 @@ package com.android.launcher3; -import static android.graphics.fonts.FontStyle.FONT_WEIGHT_BOLD; -import static android.graphics.fonts.FontStyle.FONT_WEIGHT_NORMAL; import static android.text.Layout.Alignment.ALIGN_NORMAL; import static com.android.launcher3.Flags.enableCursorHoverStates; @@ -120,7 +118,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private static final String EMPTY = ""; private static final StringMatcherUtility.StringMatcher MATCHER = StringMatcherUtility.StringMatcher.getInstance(); - private static final int BOLD_TEXT_ADJUSTMENT = FONT_WEIGHT_BOLD - FONT_WEIGHT_NORMAL; private static final int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed}; @@ -507,7 +504,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, if (Flags.enableNewArchivingIcon() && info instanceof ItemInfoWithIcon infoWithIcon && infoWithIcon.isInactiveArchive()) { - setTextWithArchivingIcon(label); + setTextWithStartIcon(label, R.drawable.cloud_download_24px); } else { setText(label); } @@ -823,7 +820,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, if (Flags.enableNewArchivingIcon() && getTag() instanceof ItemInfoWithIcon infoWithIcon && infoWithIcon.isInactiveArchive()) { - setTextWithArchivingIcon(modifiedString); + setTextWithStartIcon(modifiedString, R.drawable.cloud_download_24px); } else { setText(modifiedString); } @@ -847,29 +844,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, super.setTextColor(getModifiedColor()); } - /** - * Sets text with a start icon for App Archiving. - * Uses a bolded drawable if text is bolded. - * @param text - */ - private void setTextWithArchivingIcon(CharSequence text) { - var drawableId = R.drawable.cloud_download_24px; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S - && getResources().getConfiguration().fontWeightAdjustment >= BOLD_TEXT_ADJUSTMENT) { - // If System bold text setting is on, then use a bolded icon - drawableId = R.drawable.cloud_download_semibold_24px; - } - setTextWithStartIcon(text, drawableId); - } - /** * Uses a SpannableString to set text with a Drawable at the start of the TextView * @param text text to use for TextView - * @param drawableId Drawable Resource to use for drawing image at start of text + * @param drawableRes Drawable Resource to use for drawing image at start of text */ - @VisibleForTesting - public void setTextWithStartIcon(CharSequence text, @DrawableRes int drawableId) { - Drawable drawable = getContext().getDrawable(drawableId); + private void setTextWithStartIcon(CharSequence text, @DrawableRes int drawableRes) { + Drawable drawable = getContext().getDrawable(drawableRes); if (drawable == null) { setText(text); Log.w(TAG, "setTextWithStartIcon: start icon Drawable not found from resources" diff --git a/tests/multivalentTests/src/com/android/launcher3/ui/BubbleTextViewTest.java b/tests/multivalentTests/src/com/android/launcher3/ui/BubbleTextViewTest.java index a1f2d50f3c..b83349e715 100644 --- a/tests/multivalentTests/src/com/android/launcher3/ui/BubbleTextViewTest.java +++ b/tests/multivalentTests/src/com/android/launcher3/ui/BubbleTextViewTest.java @@ -16,41 +16,28 @@ package com.android.launcher3.ui; -import static android.graphics.fonts.FontStyle.FONT_WEIGHT_BOLD; -import static android.graphics.fonts.FontStyle.FONT_WEIGHT_NORMAL; -import static android.text.style.DynamicDrawableSpan.ALIGN_CENTER; - 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.android.launcher3.Flags.FLAG_ENABLE_NEW_ARCHIVING_ICON; import static com.android.launcher3.LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE; -import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_ARCHIVED; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; -import android.os.Build; import android.os.UserHandle; -import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; -import android.text.SpannedString; -import android.text.style.ImageSpan; import android.view.ViewGroup; import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.SdkSuppress; import androidx.test.filters.SmallTest; import com.android.launcher3.BubbleTextView; @@ -416,61 +403,6 @@ public class BubbleTextViewTest { assertThat(mBubbleTextView.getIcon().hasBadge()).isEqualTo(false); } - @EnableFlags(FLAG_ENABLE_NEW_ARCHIVING_ICON) - @Test - public void applyIconAndLabel_setsImageSpan_whenInactiveArchivedApp() { - // Given - BubbleTextView spyTextView = spy(mBubbleTextView); - mGmailAppInfo.runtimeStatusFlags |= FLAG_ARCHIVED; - BubbleTextView expectedTextView = new BubbleTextView(mContext); - int expectedDrawableId = mContext.getResources().getIdentifier( - "cloud_download_24px", /* name */ - "drawable", /* defType */ - mContext.getPackageName() - ); - expectedTextView.setTextWithStartIcon(mGmailAppInfo.title, expectedDrawableId); - // When - spyTextView.applyIconAndLabel(mGmailAppInfo); - // Then - SpannedString expectedText = (SpannedString) expectedTextView.getText(); - SpannedString actualText = (SpannedString) spyTextView.getText(); - ImageSpan actualSpan = actualText.getSpans( - 0, /* queryStart */ - 1, /* queryEnd */ - ImageSpan.class - )[0]; - ImageSpan expectedSpan = expectedText.getSpans( - 0, /* queryStart */ - 1, /* queryEnd */ - ImageSpan.class - )[0]; - verify(spyTextView).setTextWithStartIcon(mGmailAppInfo.title, expectedDrawableId); - assertThat(actualText.toString()).isEqualTo(expectedText.toString()); - assertThat(actualSpan.getDrawable().getBounds()) - .isEqualTo(expectedSpan.getDrawable().getBounds()); - assertThat(actualSpan.getVerticalAlignment()).isEqualTo(ALIGN_CENTER); - } - - @EnableFlags(FLAG_ENABLE_NEW_ARCHIVING_ICON) - @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S) - @Test - public void applyIconAndLabel_setsBoldDrawable_whenBoldedTextForArchivedApp() { - // Given - int expectedDrawableId = mContext.getResources().getIdentifier( - "cloud_download_semibold_24px", /* name */ - "drawable", /* defType */ - mContext.getPackageName() - ); - mContext.getResources().getConfiguration().fontWeightAdjustment = - FONT_WEIGHT_BOLD - FONT_WEIGHT_NORMAL; - BubbleTextView spyTextView = spy(mBubbleTextView); - mGmailAppInfo.runtimeStatusFlags |= FLAG_ARCHIVED; - // When - spyTextView.applyIconAndLabel(mGmailAppInfo); - // Then - verify(spyTextView).setTextWithStartIcon(mGmailAppInfo.title, expectedDrawableId); - } - @Test public void applyIconAndLabel_whenDisplay_DISPLAY_SEARCH_RESULT_hasBadge() { FlagOp op = FlagOp.NO_OP;