Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: ui/android/java/src/org/chromium/ui/UiUtils.java

Issue 1354763003: [Contextual Search] Trigger the translation one-box. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comment about test infrastructure needing to be updated when shifting to new API. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/android/contextualsearch/tap_test.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..094a354f83b6fade6ebd3f4e10b9a2f5ca95faec 100644
--- a/ui/android/java/src/org/chromium/ui/UiUtils.java
+++ b/ui/android/java/src/org/chromium/ui/UiUtils.java
@@ -12,16 +12,22 @@ 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.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -137,6 +143,28 @@ public class UiUtils {
}
/**
+ * Gets the set of locales supported by the current enabled Input Methods.
+ * @param context A {@link Context} instance.
+ * @return A possibly-empty {@link Set} of locale strings.
+ */
+ public static Set<String> getIMELocales(Context context) {
+ LinkedHashSet<String> locales = new LinkedHashSet<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) continue;
+ for (int j = 0; j < subtypes.size(); j++) {
+ String locale = subtypes.get(j).getLocale();
+ if (!TextUtils.isEmpty(locale)) locales.add(locale);
+ }
+ }
+ return locales;
+ }
+
+ /**
* 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.
« no previous file with comments | « chrome/test/data/android/contextualsearch/tap_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698