Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a239ef91 authored by Raph Levien's avatar Raph Levien Committed by Android (Google) Code Review
Browse files

Merge "Track TextView locale changes if not explicitly set"

parents 75788208 2e3aa445
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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;
@@ -526,6 +527,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;
@@ -2740,9 +2742,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.
     */