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

Commit a47c0396 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make getLanguageFromLocaleString private"

parents 9a20068a e9eff660
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -578,7 +578,7 @@ public class InputMethodUtils {
     * Returns the language component of a given locale string.
     * TODO: Use {@link Locale#toLanguageTag()} and {@link Locale#forLanguageTag(String)}
     */
    public static String getLanguageFromLocaleString(String locale) {
    private static String getLanguageFromLocaleString(String locale) {
        final int idx = locale.indexOf('_');
        if (idx < 0) {
            return locale;
+5 −6
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class InputMethodSubtypePreference extends SwitchWithNoTextPreference {
        this(context,
                imi.getId() + subtype.hashCode(),
                InputMethodAndSubtypeUtil.getSubtypeLocaleNameAsSentence(subtype, context, imi),
                subtype.getLocale(),
                subtype.getLocaleObject(),
                context.getResources().getConfiguration().locale);
    }

@@ -51,20 +51,19 @@ public class InputMethodSubtypePreference extends SwitchWithNoTextPreference {
            final Context context,
            final String prefKey,
            final CharSequence title,
            final String subtypeLocaleString,
            final Locale subtypeLocale,
            final Locale systemLocale) {
        super(context);
        setPersistent(false);
        setKey(prefKey);
        setTitle(title);
        if (TextUtils.isEmpty(subtypeLocaleString)) {
        if (subtypeLocale == null) {
            mIsSystemLocale = false;
            mIsSystemLanguage = false;
        } else {
            mIsSystemLocale = subtypeLocaleString.equals(systemLocale.toString());
            mIsSystemLocale = subtypeLocale.equals(systemLocale);
            mIsSystemLanguage = mIsSystemLocale
                    || InputMethodUtils.getLanguageFromLocaleString(subtypeLocaleString)
                            .equals(systemLocale.getLanguage());
                    || TextUtils.equals(subtypeLocale.getLanguage(), systemLocale.getLanguage());
        }
    }

+5 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settingslib.inputmethod;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextUtils;

import org.junit.Test;
import org.junit.runner.RunWith;
@@ -98,11 +99,14 @@ public class InputMethodSubtypePreferenceTest {
            final String subtypeLocaleString,
            final Locale systemLocale) {
        final String key = subtypeName + "-" + subtypeLocaleString + "-" + systemLocale;
        final String subtypeLanguageTag = subtypeLocaleString.replace('_', '-');
        final Locale subtypeLocale = TextUtils.isEmpty(subtypeLanguageTag)
                ? null : Locale.forLanguageTag(subtypeLanguageTag);
        return new InputMethodSubtypePreference(
                InstrumentationRegistry.getTargetContext(),
                key,
                subtypeName,
                subtypeLocaleString,
                subtypeLocale,
                systemLocale);
    }
}