diff options
author | Hans Boehm <hboehm@google.com> | 2015-10-13 00:26:08 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-13 00:26:08 +0000 |
commit | 6b2bcfe495278239a955fbbbede30a26a0c0284a (patch) | |
tree | 8bc56329f24e4a793b487d3d11348bded76267bc | |
parent | 36b271808eb63d74bcf948eef24937e1a4504bf9 (diff) | |
parent | 9bc3f44b3118ab801f1ab6f48d0a2b9e818017cb (diff) | |
download | android_packages_apps_ExactCalculator-6b2bcfe495278239a955fbbbede30a26a0c0284a.tar.gz android_packages_apps_ExactCalculator-6b2bcfe495278239a955fbbbede30a26a0c0284a.tar.bz2 android_packages_apps_ExactCalculator-6b2bcfe495278239a955fbbbede30a26a0c0284a.zip |
am 9bc3f44b: Correctly set formula text size after rotation
* commit '9bc3f44b3118ab801f1ab6f48d0a2b9e818017cb':
Correctly set formula text size after rotation
-rw-r--r-- | src/com/android/calculator2/CalculatorText.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/com/android/calculator2/CalculatorText.java b/src/com/android/calculator2/CalculatorText.java index 109c2af..f944071 100644 --- a/src/com/android/calculator2/CalculatorText.java +++ b/src/com/android/calculator2/CalculatorText.java @@ -138,18 +138,22 @@ public class CalculatorText extends AlignedTextView implements View.OnLongClickL @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - // Prevent shrinking/resizing with our variable textSize. - if (!isLaidOut()) { - setTextSize(TypedValue.COMPLEX_UNIT_PX, mMaximumTextSize); - setMinHeight(getLineHeight() + getCompoundPaddingBottom() + getCompoundPaddingTop()); - } - // Re-calculate our textSize based on new width. final int width = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight(); if (mWidthConstraint != width) { mWidthConstraint = width; - setTextSize(TypedValue.COMPLEX_UNIT_PX, getVariableTextSize(getText())); + + if (!isLaidOut()) { + // Prevent shrinking/resizing with our variable textSize. + setTextSizeInternal(TypedValue.COMPLEX_UNIT_PX, mMaximumTextSize, + false /* notifyListener */); + setMinHeight(getLineHeight() + getCompoundPaddingBottom() + + getCompoundPaddingTop()); + } + + setTextSizeInternal(TypedValue.COMPLEX_UNIT_PX, getVariableTextSize(getText()), + false); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -164,16 +168,19 @@ public class CalculatorText extends AlignedTextView implements View.OnLongClickL setTextSize(TypedValue.COMPLEX_UNIT_PX, getVariableTextSize(text.toString())); } - @Override - public void setTextSize(int unit, float size) { + private void setTextSizeInternal(int unit, float size, boolean notifyListener) { final float oldTextSize = getTextSize(); super.setTextSize(unit, size); - - if (mOnTextSizeChangeListener != null && getTextSize() != oldTextSize) { + if (notifyListener && mOnTextSizeChangeListener != null && getTextSize() != oldTextSize) { mOnTextSizeChangeListener.onTextSizeChanged(this, oldTextSize); } } + @Override + public void setTextSize(int unit, float size) { + setTextSizeInternal(unit, size, true); + } + public float getMinimumTextSize() { return mMinimumTextSize; } |