Draw contrast tile around the text
If the BubbletTextView should have an app contrast tile, account for some padding between the tile and the text when measuring the view, so that the text is guaranteed to be inside of the bubble. In a similar way, recalculate the bounds of the tile to only surround the app title as needed. Bug: 341217082 Flag: com.android.launcher3.enable_contrast_tiles Test: Manual, visual change Change-Id: I9e8b149ade3fa4522e62b89c2332195f648b190f
This commit is contained in:
@@ -127,6 +127,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
|
||||
private static final int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed};
|
||||
|
||||
private static final int APP_PILL_TITLE_PADDING = 8;
|
||||
|
||||
private float mScaleForReorderBounce = 1f;
|
||||
|
||||
private IntArray mBreakPointsIntArray;
|
||||
@@ -730,16 +732,21 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
Paint.FontMetrics fm = getPaint().getFontMetrics();
|
||||
Rect tmpRect = new Rect();
|
||||
getDrawingRect(tmpRect);
|
||||
CharSequence text = getText();
|
||||
|
||||
if (mIcon == null) {
|
||||
appTitleBounds = new RectF(0, 0, tmpRect.right,
|
||||
(int) Math.ceil(fm.bottom - fm.top));
|
||||
} else {
|
||||
float titleLength = (getPaint().measureText(text, 0, text.length())
|
||||
+ APP_PILL_TITLE_PADDING * 2);
|
||||
titleLength = Math.min(titleLength, tmpRect.width());
|
||||
appTitleBounds = new RectF((tmpRect.width() - titleLength) / 2.f - getCompoundPaddingLeft(),
|
||||
0, (tmpRect.width() + titleLength) / 2.f + getCompoundPaddingRight(),
|
||||
(int) Math.ceil(fm.bottom - fm.top));
|
||||
|
||||
|
||||
if (mIcon != null) {
|
||||
Rect iconBounds = new Rect();
|
||||
getIconBounds(iconBounds);
|
||||
int textStart = iconBounds.bottom + getCompoundDrawablePadding();
|
||||
appTitleBounds = new RectF(tmpRect.left, textStart, tmpRect.right,
|
||||
textStart + (int) Math.ceil(fm.bottom - fm.top));
|
||||
appTitleBounds.offset(0, textStart);
|
||||
}
|
||||
|
||||
canvas.drawRoundRect(appTitleBounds, appTitleBounds.height() / 2,
|
||||
@@ -851,6 +858,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
setPadding(getPaddingLeft(), (height - cellHeightPx) / 2, getPaddingRight(),
|
||||
getPaddingBottom());
|
||||
}
|
||||
if (shouldDrawAppContrastTile()) {
|
||||
setPadding(getPaddingLeft() + APP_PILL_TITLE_PADDING, getPaddingTop(),
|
||||
getPaddingRight() + APP_PILL_TITLE_PADDING,
|
||||
getPaddingBottom());
|
||||
}
|
||||
// Only apply two line for all_apps and device search only if necessary.
|
||||
if (shouldUseTwoLine() && (mLastOriginalText != null)) {
|
||||
int allowedVerticalSpace = height - getPaddingTop() - getPaddingBottom()
|
||||
|
||||
Reference in New Issue
Block a user