mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add SubtypeLocale class
Change-Id: Ic4c73c313f976ad6df1b4ddf48b914d05a08d283
This commit is contained in:
parent
96680f28e8
commit
e276d8ddaa
@ -138,4 +138,14 @@
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Subtype locale name exceptions -->
|
||||
<string-array name="subtype_locale_exception_keys">
|
||||
<item>en_US</item>
|
||||
<item>en_GB</item>
|
||||
</string-array>
|
||||
<string-array name="subtype_locale_exception_values">
|
||||
<item>English (US)</item>
|
||||
<item>English (UK)</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
46
java/src/com/android/inputmethod/latin/SubtypeLocale.java
Normal file
46
java/src/com/android/inputmethod/latin/SubtypeLocale.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class SubtypeLocale {
|
||||
private static String[] sExceptionKeys;
|
||||
private static String[] sExceptionValues;
|
||||
|
||||
private SubtypeLocale() {
|
||||
// Intentional empty constructor for utility class.
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
final Resources res = context.getResources();
|
||||
sExceptionKeys = res.getStringArray(R.array.subtype_locale_exception_keys);
|
||||
sExceptionValues = res.getStringArray(R.array.subtype_locale_exception_values);
|
||||
}
|
||||
|
||||
public static String getFullDisplayName(Locale locale) {
|
||||
String localeCode = locale.toString();
|
||||
for (int index = 0; index < sExceptionKeys.length; index++) {
|
||||
if (sExceptionKeys[index].equals(localeCode))
|
||||
return sExceptionValues[index];
|
||||
}
|
||||
return locale.getDisplayName(locale);
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import com.android.inputmethod.keyboard.Keyboard;
|
||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import com.android.inputmethod.voice.SettingsUtil;
|
||||
import com.android.inputmethod.voice.VoiceIMEConnector;
|
||||
@ -90,6 +89,8 @@ public class SubtypeSwitcher {
|
||||
}
|
||||
|
||||
sInstance.updateAllParameters();
|
||||
|
||||
SubtypeLocale.init(service);
|
||||
}
|
||||
|
||||
private SubtypeSwitcher() {
|
||||
@ -445,7 +446,7 @@ public class SubtypeSwitcher {
|
||||
|
||||
public static String getFullDisplayName(Locale locale, boolean returnsNameInThisLocale) {
|
||||
if (returnsNameInThisLocale) {
|
||||
return toTitleCase(locale.getDisplayName(locale));
|
||||
return toTitleCase(SubtypeLocale.getFullDisplayName(locale));
|
||||
} else {
|
||||
return toTitleCase(locale.getDisplayName());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user