diff options
| author | Sai Cheemalapati <saicheems@google.com> | 2014-06-23 11:30:45 -0700 |
|---|---|---|
| committer | Sai Cheemalapati <saicheems@google.com> | 2014-06-23 16:20:41 -0700 |
| commit | 9a17f0e3e1a3957c8c2b530171281943bec435f1 (patch) | |
| tree | 67f22f19d022bbefe9ac2b54bfa5ebd6ac9e03e7 /src/com/android/phone/common/dialpad/DigitsEditText.java | |
| parent | 13b8948c0cc543f62a68fa32c4692ba16a2e93c6 (diff) | |
| download | packages_apps_PhoneCommon-9a17f0e3e1a3957c8c2b530171281943bec435f1.tar.gz packages_apps_PhoneCommon-9a17f0e3e1a3957c8c2b530171281943bec435f1.tar.bz2 packages_apps_PhoneCommon-9a17f0e3e1a3957c8c2b530171281943bec435f1.zip | |
Add text resizing to InCallUI name field (2/2).
Set maximum size of primary name text to 45 pt.
Scales down to minimum size of 34 pt.
Bug: 15457502
Change-Id: I12dabf66cbefaa4ad458abdb910e8b0417f5b234
Diffstat (limited to 'src/com/android/phone/common/dialpad/DigitsEditText.java')
| -rw-r--r-- | src/com/android/phone/common/dialpad/DigitsEditText.java | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/src/com/android/phone/common/dialpad/DigitsEditText.java b/src/com/android/phone/common/dialpad/DigitsEditText.java index b2022aa..f6e87b7 100644 --- a/src/com/android/phone/common/dialpad/DigitsEditText.java +++ b/src/com/android/phone/common/dialpad/DigitsEditText.java @@ -28,18 +28,15 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import com.android.phone.common.R; +import com.android.phone.common.widget.ResizingTextEditText; /** * EditText which suppresses IME show up. */ -public class DigitsEditText extends EditText { - // Only scale the text down to 66% smaller at most. - private static final float MIN_TEXT_RESIZE_RATIO = 0.66f; - private final float mOriginalTextSize; +public class DigitsEditText extends ResizingTextEditText { public DigitsEditText(Context context, AttributeSet attrs) { super(context, attrs); - mOriginalTextSize = getTextSize(); setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); setShowSoftInputOnFocus(false); } @@ -65,30 +62,4 @@ public class DigitsEditText extends EditText { } return ret; } - - @Override - protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { - super.onTextChanged(text, start, lengthBefore, lengthAfter); - resizeText(getWidth()); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - resizeText(w); - } - - private void resizeText(int width) { - if (width == 0) { - return; - } - final Paint paint = getPaint(); - setTextSize(TypedValue.COMPLEX_UNIT_PX, mOriginalTextSize); - - float ratio = width / paint.measureText(getText().toString()); - if (ratio <= 1.0f) { - setTextSize(TypedValue.COMPLEX_UNIT_PX, - mOriginalTextSize * Math.max(MIN_TEXT_RESIZE_RATIO, ratio)); - } - } } |
