mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
Automated g4 rollback of changelist 170486018
PiperOrigin-RevId: 170512542
This commit is contained in:
parent
b93ba27820
commit
585a074ae5
@ -99,7 +99,6 @@ final class CollapsingTextHelper {
|
||||
private boolean mBoundsChanged;
|
||||
|
||||
private final TextPaint mTextPaint;
|
||||
private final TextPaint mTmpPaint;
|
||||
|
||||
private TimeInterpolator mPositionInterpolator;
|
||||
private TimeInterpolator mTextSizeInterpolator;
|
||||
@ -118,7 +117,6 @@ final class CollapsingTextHelper {
|
||||
mView = view;
|
||||
|
||||
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
|
||||
mTmpPaint = new TextPaint(mTextPaint);
|
||||
|
||||
mCollapsedBounds = new Rect();
|
||||
mExpandedBounds = new Rect();
|
||||
@ -179,31 +177,6 @@ final class CollapsingTextHelper {
|
||||
}
|
||||
}
|
||||
|
||||
float calculateCollapsedTextWidth() {
|
||||
if (mTextToDraw == null) {
|
||||
return 0;
|
||||
}
|
||||
getTextPaintCollapsed(mTmpPaint);
|
||||
return mTmpPaint.measureText(mTextToDraw, 0, mTextToDraw.length());
|
||||
}
|
||||
|
||||
float getCollapsedTextHeight() {
|
||||
getTextPaintCollapsed(mTmpPaint);
|
||||
return mTmpPaint.descent() - mTmpPaint.ascent();
|
||||
}
|
||||
|
||||
void getCollapsedTextActualBounds(RectF bounds) {
|
||||
bounds.left = mCollapsedBounds.left;
|
||||
bounds.top = mCollapsedBounds.top;
|
||||
bounds.right = bounds.left + calculateCollapsedTextWidth();
|
||||
bounds.bottom = mCollapsedBounds.top + getCollapsedTextHeight();
|
||||
}
|
||||
|
||||
private void getTextPaintCollapsed(TextPaint textPaint) {
|
||||
textPaint.setTextSize(mCollapsedTextSize);
|
||||
textPaint.setTypeface(mCollapsedTypeface);
|
||||
}
|
||||
|
||||
void onBoundsChanged() {
|
||||
mDrawTitle =
|
||||
mCollapsedBounds.width() > 0
|
||||
|
||||
@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
@ -165,6 +166,7 @@ public class TextInputLayout extends LinearLayout {
|
||||
public static final int BOX_BACKGROUND_FILLED = 1;
|
||||
public static final int BOX_BACKGROUND_OUTLINE = 2;
|
||||
|
||||
private Paint mTmpPaint;
|
||||
private final Rect mTmpRect = new Rect();
|
||||
private Typeface mTypeface;
|
||||
|
||||
@ -348,23 +350,17 @@ public class TextInputLayout extends LinearLayout {
|
||||
private void onApplyBoxBackgroundMode() {
|
||||
if (mBoxBackgroundMode == BOX_BACKGROUND_NONE) {
|
||||
mBoxBackground = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBoxBackground == null) {
|
||||
mBoxBackground = new GradientDrawable();
|
||||
}
|
||||
|
||||
if (mBoxBackgroundMode != BOX_BACKGROUND_NONE) {
|
||||
updateInputLayoutMargins();
|
||||
}
|
||||
updateTextInputBoxBounds();
|
||||
setEditTextBoxPadding();
|
||||
}
|
||||
|
||||
private void setEditTextBoxPadding() {
|
||||
if (mBoxBackgroundMode == BOX_BACKGROUND_NONE) {
|
||||
return;
|
||||
}
|
||||
// Set box padding on the edit text.
|
||||
if (mEditText != null) {
|
||||
mEditText.setPadding(
|
||||
@ -568,7 +564,12 @@ public class TextInputLayout extends LinearLayout {
|
||||
final int newTopMargin;
|
||||
|
||||
if (mHintEnabled) {
|
||||
newTopMargin = (int) mCollapsingTextHelper.getCollapsedTextHeight();
|
||||
if (mTmpPaint == null) {
|
||||
mTmpPaint = new Paint();
|
||||
}
|
||||
mTmpPaint.setTypeface(mCollapsingTextHelper.getCollapsedTypeface());
|
||||
mTmpPaint.setTextSize(mCollapsingTextHelper.getCollapsedTextSize());
|
||||
newTopMargin = (int) -mTmpPaint.ascent();
|
||||
} else {
|
||||
newTopMargin = 0;
|
||||
}
|
||||
@ -965,10 +966,7 @@ public class TextInputLayout extends LinearLayout {
|
||||
}
|
||||
|
||||
private void updateTextInputBoxBounds() {
|
||||
if (mBoxBackgroundMode == BOX_BACKGROUND_NONE
|
||||
|| mBoxBackground == null
|
||||
|| mEditText == null
|
||||
|| getRight() == 0) {
|
||||
if (mBoxBackground == null || mEditText == null || getRight() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user