Loading core/java/com/android/internal/inputmethod/InputMethodUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodSubtypePreference.java +5 −6 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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()); } } Loading packages/SettingsLib/tests/integ/src/com/android/settingslib/inputmethod/InputMethodSubtypePreferenceTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } } Loading
core/java/com/android/internal/inputmethod/InputMethodUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodSubtypePreference.java +5 −6 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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()); } } Loading
packages/SettingsLib/tests/integ/src/com/android/settingslib/inputmethod/InputMethodSubtypePreferenceTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } }