Merge "Fix drop target icons being truncated." into sc-dev am: de268a51a1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14899271 Change-Id: I027d4605768273e0c5115f02682d87fea206f204
This commit is contained in:
commit
bd1581f030
|
@ -16,8 +16,8 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="20dp"
|
android:width="20dp"
|
||||||
android:height="20dp"
|
android:height="20dp"
|
||||||
android:viewportHeight="20.0"
|
android:viewportHeight="24.0"
|
||||||
android:viewportWidth="20.0"
|
android:viewportWidth="24.0"
|
||||||
android:tint="?android:attr/textColorPrimary">
|
android:tint="?android:attr/textColorPrimary">
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/white"
|
android:fillColor="@android:color/white"
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="20dp"
|
android:width="20dp"
|
||||||
android:height="20dp"
|
android:height="20dp"
|
||||||
android:viewportWidth="20.0"
|
android:viewportWidth="24.0"
|
||||||
android:viewportHeight="20.0"
|
android:viewportHeight="24.0"
|
||||||
android:tint="?android:attr/textColorPrimary" >
|
android:tint="?android:attr/textColorPrimary" >
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/white"
|
android:fillColor="@android:color/white"
|
||||||
|
|
|
@ -36,8 +36,6 @@ import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
|
||||||
|
|
||||||
import com.android.launcher3.anim.Interpolators;
|
import com.android.launcher3.anim.Interpolators;
|
||||||
import com.android.launcher3.dragndrop.DragController;
|
import com.android.launcher3.dragndrop.DragController;
|
||||||
import com.android.launcher3.dragndrop.DragLayer;
|
import com.android.launcher3.dragndrop.DragLayer;
|
||||||
|
@ -82,6 +80,8 @@ public abstract class ButtonDropTarget extends TextView
|
||||||
private boolean mAccessibleDrag;
|
private boolean mAccessibleDrag;
|
||||||
/** An item must be dragged at least this many pixels before this drop target is enabled. */
|
/** An item must be dragged at least this many pixels before this drop target is enabled. */
|
||||||
private final int mDragDistanceThreshold;
|
private final int mDragDistanceThreshold;
|
||||||
|
/** The size of the drawable shown in the drop target. */
|
||||||
|
private final int mDrawableSize;
|
||||||
|
|
||||||
protected CharSequence mText;
|
protected CharSequence mText;
|
||||||
protected ColorStateList mOriginalTextColor;
|
protected ColorStateList mOriginalTextColor;
|
||||||
|
@ -103,6 +103,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||||
|
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
|
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
|
||||||
|
mDrawableSize = resources.getDimensionPixelSize(R.dimen.drop_target_text_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,14 +121,18 @@ public abstract class ButtonDropTarget extends TextView
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDrawable(int resId) {
|
protected void setDrawable(int resId) {
|
||||||
|
mDrawable = getContext().getDrawable(resId).mutate();
|
||||||
|
mDrawable.setBounds(0, 0, mDrawableSize, mDrawableSize);
|
||||||
|
setDrawable(mDrawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDrawable(Drawable drawable) {
|
||||||
// We do not set the drawable in the xml as that inflates two drawables corresponding to
|
// We do not set the drawable in the xml as that inflates two drawables corresponding to
|
||||||
// drawableLeft and drawableStart.
|
// drawableLeft and drawableStart.
|
||||||
if (mTextVisible) {
|
if (mTextVisible) {
|
||||||
setCompoundDrawablesRelativeWithIntrinsicBounds(resId, 0, 0, 0);
|
setCompoundDrawablesRelative(drawable, null, null, null);
|
||||||
mDrawable = getCompoundDrawablesRelative()[0];
|
|
||||||
} else {
|
} else {
|
||||||
setCompoundDrawablesRelativeWithIntrinsicBounds(0, resId, 0, 0);
|
setCompoundDrawablesRelative(null, drawable, null, null);
|
||||||
mDrawable = getCompoundDrawablesRelative()[1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,11 +334,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||||
if (mTextVisible != isVisible || !TextUtils.equals(newText, getText())) {
|
if (mTextVisible != isVisible || !TextUtils.equals(newText, getText())) {
|
||||||
mTextVisible = isVisible;
|
mTextVisible = isVisible;
|
||||||
setText(newText);
|
setText(newText);
|
||||||
if (mTextVisible) {
|
setDrawable(mDrawable);
|
||||||
setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
|
|
||||||
} else {
|
|
||||||
setCompoundDrawablesRelativeWithIntrinsicBounds(null, mDrawable, null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue