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..ef901bafd120093301aac23ae1a749e11eb39b0b 100644 |
--- a/ui/android/java/src/org/chromium/ui/UiUtils.java |
+++ b/ui/android/java/src/org/chromium/ui/UiUtils.java |
@@ -12,16 +12,21 @@ import android.net.Uri; |
import android.os.Build; |
import android.os.Environment; |
import android.os.Handler; |
+import android.text.TextUtils; |
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 +142,30 @@ 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>(); |
+ InputMethodManager imManager = |
+ (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); |
+ List<InputMethodInfo> enabledMethods = imManager.getEnabledInputMethodList(); |
+ for (int i = 0; i < enabledMethods.size(); i++) { |
+ List<InputMethodSubtype> subtypes = |
+ imManager.getEnabledInputMethodSubtypeList(enabledMethods.get(i), true); |
+ if (subtypes != null) { |
Ted C
2015/10/10 00:05:47
I would do:
if (subtypes == null) continue;
Then
Donn Denman
2015/10/12 18:43:52
Done.
|
+ for (int j = 0; j < subtypes.size(); j++) { |
+ String locale = subtypes.get(j).getLocale(); |
+ if (!TextUtils.isEmpty(locale)) result.add(locale); |
+ } |
+ } |
+ } |
+ System.out.println("ctxs getIMELocales returning " + result.toString()); |
Ted C
2015/10/10 00:05:47
debug print out left in
Donn Denman
2015/10/12 18:43:52
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. |