Index: ui/android/java/src/org/chromium/ui/UiUtils.java |
diff --git a/ui/android/java/src/org/chromium/ui/UiUtils.java b/ui/android/java/src/org/chromium/ui/UiUtils.java |
index c164641a1cf486d860bd9b52ee55f7704d7b1e38..68cccf851881f38c111a5203a43e6770d455a944 100644 |
--- a/ui/android/java/src/org/chromium/ui/UiUtils.java |
+++ b/ui/android/java/src/org/chromium/ui/UiUtils.java |
@@ -16,12 +16,16 @@ import android.util.Log; |
import android.view.SurfaceView; |
import android.view.View; |
import android.view.ViewGroup; |
+import android.view.inputmethod.InputMethodInfo; |
import android.view.inputmethod.InputMethodManager; |
+import android.view.inputmethod.InputMethodSubtype; |
import org.chromium.base.ContentUriUtils; |
import java.io.File; |
import java.io.IOException; |
+import java.util.ArrayList; |
+import java.util.List; |
import java.util.concurrent.atomic.AtomicInteger; |
/** |
@@ -137,6 +141,27 @@ public class UiUtils { |
} |
/** |
+ * Gets a list of locales supported by the current enabled Input Methods. |
+ * @param context A {@link Context} instance. |
+ * @return A possibly-empty {@link List} of locale strings. |
+ */ |
+ public static List<String> getIMELocales(Context context) { |
+ List<String> result = new ArrayList<String>(); |
Ted C
2015/10/09 22:50:30
I'd recommend returning a Set and using LinkedHash
Donn Denman
2015/10/09 23:51:38
Actually I did that, but then switched back to usi
Ted C
2015/10/10 00:05:47
Agreed, that's what I was suggesting LinkedHashMap
|
+ InputMethodManager imManager = |
+ (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); |
+ List<InputMethodInfo> enabledMethods = imManager.getEnabledInputMethodList(); |
+ for (InputMethodInfo inputMethodInfo : enabledMethods) { |
Ted C
2015/10/09 22:50:30
Use for (int i = 0; i < ...) for iterating to avoi
Donn Denman
2015/10/09 23:51:38
Done.
|
+ List<InputMethodSubtype> subtypes = |
+ imManager.getEnabledInputMethodSubtypeList(inputMethodInfo, true); |
Ted C
2015/10/09 22:50:30
this can't be null right? the docs don't say, but
Donn Denman
2015/10/09 23:51:38
I wondered about all of these requests returning n
|
+ for (InputMethodSubtype subtype : subtypes) { |
+ String locale = subtype.getLocale(); |
+ if (!locale.isEmpty()) result.add(locale); |
Ted C
2015/10/09 22:50:30
TextUtils.isEmpty
Donn Denman
2015/10/09 23:51:38
Done.
|
+ } |
+ } |
+ return result; |
+ } |
+ |
+ /** |
* Inserts a {@link View} into a {@link ViewGroup} after directly before a given {@View}. |
* @param container The {@link View} to add newView to. |
* @param newView The new {@link View} to add. |