diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index e49ead0f75..1f7eba812e 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -23,10 +23,12 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Property; @@ -93,6 +95,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private final int mIconSize; @ViewDebug.ExportedProperty(category = "launcher") private int mTextColor; + private boolean mIsIconVisible = true; private BadgeInfo mBadgeInfo; private BadgeRenderer mBadgeRenderer; @@ -609,7 +612,21 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private void setIcon(Drawable icon) { mIcon = icon; mIcon.setBounds(0, 0, mIconSize, mIconSize); - applyCompoundDrawables(mIcon); + if (mIsIconVisible) { + applyCompoundDrawables(mIcon); + } + } + + public void setIconVisible(boolean visible) { + mIsIconVisible = visible; + mDisableRelayout = true; + Drawable icon = mIcon; + if (!visible) { + icon = new ColorDrawable(Color.TRANSPARENT); + icon.setBounds(0, 0, mIconSize, mIconSize); + } + applyCompoundDrawables(icon); + mDisableRelayout = false; } protected void applyCompoundDrawables(Drawable icon) { diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index ccead37dc8..b373a17669 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -530,6 +530,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra */ public DragOptions.PreDragCondition createPreDragCondition() { return new DragOptions.PreDragCondition() { + @Override public boolean shouldStartDrag(double distanceDragged) { return distanceDragged > mStartDragThreshold; @@ -537,15 +538,27 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra @Override public void onPreDragStart(DropTarget.DragObject dragObject) { - mOriginalIcon.setVisibility(INVISIBLE); + if (mIsAboveIcon) { + // Hide only the icon, keep the text visible. + mOriginalIcon.setIconVisible(false); + mOriginalIcon.setVisibility(VISIBLE); + } else { + // Hide both the icon and text. + mOriginalIcon.setVisibility(INVISIBLE); + } } @Override public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) { - if (!dragStarted) { - mOriginalIcon.setVisibility(VISIBLE); + mOriginalIcon.setIconVisible(true); + if (dragStarted) { + // Make sure we keep the original icon hidden while it is being dragged. + mOriginalIcon.setVisibility(INVISIBLE); + } else { mLauncher.getUserEventDispatcher().logDeepShortcutsOpen(mOriginalIcon); if (!mIsAboveIcon) { + // Show the icon but keep the text hidden. + mOriginalIcon.setVisibility(VISIBLE); mOriginalIcon.setTextVisibility(false); } }