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

Commit eaddec8c authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Use TextView's text locale for capitalization.

BUG: 19284889
Change-Id: Icd3c1dd3b31c23025bc974bcbb5a3618196434e7
parent 7a11a0e8
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import java.util.Locale;

@@ -39,13 +40,25 @@ public class AllCapsTransformationMethod implements TransformationMethod2 {

    @Override
    public CharSequence getTransformation(CharSequence source, View view) {
        if (mEnabled) {
            return source != null ? source.toString().toUpperCase(mLocale) : null;
        }
        if (!mEnabled) {
            Log.w(TAG, "Caller did not enable length changes; not transforming text");
            return source;
        }

        if (source == null) {
            return null;
        }

        Locale locale = null;
        if (view instanceof TextView) {
            locale = ((TextView)view).getTextLocale();
        }
        if (locale == null) {
            locale = mLocale;
        }
        return source.toString().toUpperCase(locale);
    }

    @Override
    public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction,
            Rect previouslyFocusedRect) {