summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2015-01-14 16:12:53 -0800
committerRaph Levien <raph@google.com>2015-01-14 16:12:53 -0800
commit2e3aa445b418e63f8c1bf7272fa2d75e021d7164 (patch)
tree7757873b88a8a73c0d90882c9aa1aa32d1b6b7db /core/java/android
parentee7712c0a95033394c73f7d6c511204d81a20d1e (diff)
downloadframeworks_base-2e3aa445b418e63f8c1bf7272fa2d75e021d7164.zip
frameworks_base-2e3aa445b418e63f8c1bf7272fa2d75e021d7164.tar.gz
frameworks_base-2e3aa445b418e63f8c1bf7272fa2d75e021d7164.tar.bz2
Track TextView locale changes if not explicitly set
The locale in the Paint used by TextView is set at the time the view is created. If the locale changes and the locale hasn't been explicitly set, better behavior is "whatever the current locale is." This patch updates the locale in that particular case. Bug: 16274782 Change-Id: I3b1b8e77c9508c757543ea50de3590d254404c1e
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/widget/TextView.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index edba9f5..b0b4fed 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.UndoManager;
import android.content.res.ColorStateList;
import android.content.res.CompatibilityInfo;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
@@ -520,6 +521,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private final TextPaint mTextPaint;
private boolean mUserSetTextScaleX;
private Layout mLayout;
+ private boolean mLocaleChanged = false;
private int mGravity = Gravity.TOP | Gravity.START;
private boolean mHorizontallyScrolling;
@@ -2587,9 +2589,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @see Paint#setTextLocale
*/
public void setTextLocale(Locale locale) {
+ mLocaleChanged = true;
mTextPaint.setTextLocale(locale);
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (!mLocaleChanged) {
+ mTextPaint.setTextLocale(Locale.getDefault());
+ }
+ }
+
/**
* @return the size (in pixels) of the default text size in this TextView.
*/