From b3b467c27fa7215821ceda0470414528c5b30316 Mon Sep 17 00:00:00 2001 From: Kevin Lim Date: Fri, 21 Jul 2023 02:15:34 +0000 Subject: [PATCH] [NexusLauncher] Expose setLayoutHorizontal. mLayoutHorizontal is exposed so that classes that extend BubbleTextView can override this programmatically based on LayoutType. mLayoutHorizontal prevents the title in horizontal cases affecting the icon bounds measure, and shifting things such as the icon halo. Bug: b/288471727 Test: See ag/24199217 Test: New tests in SearchResultIconTest Test: No regression in SearchResultSmallIconRowTest Change-Id: I424c1597d29ed26d7dea9e666ff2d274847e3217 --- src/com/android/launcher3/BubbleTextView.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 360e06059f..c4fd311462 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -152,7 +152,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private final CheckLongPressHelper mLongPressHelper; - private final boolean mLayoutHorizontal; + private boolean mLayoutHorizontal; private final boolean mIsRtl; private final int mIconSize; @@ -665,6 +665,18 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } } + /** + * Sets whether the layout is horizontal. + */ + public void setLayoutHorizontal(boolean layoutHorizontal) { + if (mLayoutHorizontal == layoutHorizontal) { + return; + } + + mLayoutHorizontal = layoutHorizontal; + applyCompoundDrawables(getIconOrTransparentColor()); + } + /** * Sets whether to vertically center the content. */ @@ -991,10 +1003,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, if (!mIsIconVisible) { resetIconScale(); } - Drawable icon = visible ? mIcon : new ColorDrawable(Color.TRANSPARENT); + Drawable icon = getIconOrTransparentColor(); applyCompoundDrawables(icon); } + private Drawable getIconOrTransparentColor() { + return mIsIconVisible ? mIcon : new ColorDrawable(Color.TRANSPARENT); + } + /** Sets the icon visual state to disabled or not. */ public void setIconDisabled(boolean isDisabled) { if (mIcon != null) {