Merge "Don't hide text in pre-drag when opening popup above icon" into ub-launcher3-dorval-polish

am: 9ff727ef44

Change-Id: Id8cb80e35a1ec30e91427b4d75a783c130d6df90
This commit is contained in:
Tony Wickham 2017-05-24 18:05:30 +00:00 committed by android-build-merger
commit 2aea2f3bcb
2 changed files with 34 additions and 4 deletions

View File

@ -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) {

View File

@ -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);
}
}