mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Hides text on ButtonDropTargets if any of them are ellipsized.
This can happen on small devices or on devices where Font/Display size
is enlarged and when Developer Options is turned on when all three
options {Uninstall, Delete, App Info} are shown at once.
Bug: 64391860
Change-Id: If355d28087d53148114eb586efb3c26f158b3713
This commit is contained in:
@@ -29,6 +29,7 @@ import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -69,6 +70,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
/** The paint applied to the drag view on hover */
|
||||
protected int mHoverColor = 0;
|
||||
|
||||
protected CharSequence mText;
|
||||
protected ColorStateList mOriginalTextColor;
|
||||
protected Drawable mDrawable;
|
||||
|
||||
@@ -96,6 +98,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mText = getText();
|
||||
mOriginalTextColor = getTextColors();
|
||||
}
|
||||
|
||||
@@ -297,4 +300,30 @@ public abstract class ButtonDropTarget extends TextView
|
||||
public int getTextColor() {
|
||||
return getTextColors().getDefaultColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns True if any update was made.
|
||||
*/
|
||||
public boolean updateText(boolean hide) {
|
||||
if ((hide && getText().toString().isEmpty()) || (!hide && mText.equals(getText()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setText(hide ? "" : mText);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isTextTruncated() {
|
||||
int availableWidth = getMeasuredWidth();
|
||||
if (mHideParentOnDisable) {
|
||||
ViewGroup parent = (ViewGroup) getParent();
|
||||
availableWidth = parent.getMeasuredWidth() - parent.getPaddingLeft()
|
||||
- parent.getPaddingRight();
|
||||
}
|
||||
availableWidth -= (getPaddingLeft() + getPaddingRight() + mDrawable.getIntrinsicWidth()
|
||||
+ getCompoundDrawablePadding());
|
||||
CharSequence displayedText = TextUtils.ellipsize(mText, getPaint(), availableWidth,
|
||||
TextUtils.TruncateAt.END);
|
||||
return !mText.equals(displayedText);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user