aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2016-03-04 13:07:17 -0800
committerYohei Yukawa <yukawa@google.com>2016-03-04 13:07:17 -0800
commit31a3f07c2117180df524d6b2e78089897c8ea807 (patch)
tree35bc91e958303a737e642c7659391eb2f0b138b8 /java/src/com/android/inputmethod
parent4b46e711632f6e5d868e6d84a6211384d37e1911 (diff)
downloadlatinime-31a3f07c2117180df524d6b2e78089897c8ea807.tar.gz
latinime-31a3f07c2117180df524d6b2e78089897c8ea807.tar.xz
latinime-31a3f07c2117180df524d6b2e78089897c8ea807.zip
Map "sr-Latn" to "sr_ZZ" for internal use.
We want to expose Serbian (Latin) layout as "sr-Latn" to the system, while our internal logic may not be ready to deal with "sr-Latn" yet. As a temporary workaround, we remap "sr-Latn" into "sr_ZZ" for our internal use. Bug: 27348943 Change-Id: I93ff0c75b3687bb1b913f451b9eb5f2820beefbc
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java b/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java
index 71aaf5e01..cc589229e 100644
--- a/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java
+++ b/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java
@@ -18,14 +18,17 @@ package com.android.inputmethod.latin;
import static com.android.inputmethod.latin.common.Constants.Subtype.KEYBOARD_MODE;
+import android.os.Build;
import android.util.Log;
import android.view.inputmethod.InputMethodSubtype;
+import com.android.inputmethod.compat.BuildCompatUtils;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.LocaleUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+import java.util.HashMap;
import java.util.Locale;
import javax.annotation.Nonnull;
@@ -40,14 +43,29 @@ import javax.annotation.Nullable;
public class RichInputMethodSubtype {
private static final String TAG = RichInputMethodSubtype.class.getSimpleName();
+ private static final HashMap<Locale, Locale> sLocaleMap = initializeLocaleMap();
+ private static final HashMap<Locale, Locale> initializeLocaleMap() {
+ final HashMap<Locale, Locale> map = new HashMap<>();
+ if (BuildCompatUtils.EFFECTIVE_SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ // Locale#forLanguageTag is available on API Level 21+.
+ // TODO: Remove this workaround once when we become able to deal with "sr-Latn".
+ map.put(Locale.forLanguageTag("sr-Latn"), new Locale("sr_ZZ"));
+ }
+ return map;
+ }
+
@Nonnull
private final InputMethodSubtype mSubtype;
@Nonnull
private final Locale mLocale;
+ @Nonnull
+ private final Locale mOriginalLocale;
public RichInputMethodSubtype(@Nonnull final InputMethodSubtype subtype) {
mSubtype = subtype;
- mLocale = InputMethodSubtypeCompatUtils.getLocaleObject(mSubtype);
+ mOriginalLocale = InputMethodSubtypeCompatUtils.getLocaleObject(mSubtype);
+ final Locale mappedLocale = sLocaleMap.get(mOriginalLocale);
+ mLocale = mappedLocale != null ? mappedLocale : mOriginalLocale;
}
// Extra values are determined by the primary subtype. This is probably right, but
@@ -128,6 +146,11 @@ public class RichInputMethodSubtype {
return mLocale;
}
+ @Nonnull
+ public Locale getOriginalLocale() {
+ return mOriginalLocale;
+ }
+
public boolean isRtlSubtype() {
// The subtype is considered RTL if the language of the main subtype is RTL.
return LocaleUtils.isRtlLanguage(mLocale);