aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/compat
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-04-13 12:58:46 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-04-13 12:58:46 +0000
commitf83d443d8d5e2c43024904125dc8bcd9e173782e (patch)
tree116ee96c6e5e93a6526a6319472415ecb08fa95c /java/src/com/android/inputmethod/compat
parent3b6025a190160d8e387f9691af64314e7bbda7a1 (diff)
parentda498229f41b828209765774a6f7f8f1ad5f30c3 (diff)
downloadlatinime-f83d443d8d5e2c43024904125dc8bcd9e173782e.tar.gz
latinime-f83d443d8d5e2c43024904125dc8bcd9e173782e.tar.xz
latinime-f83d443d8d5e2c43024904125dc8bcd9e173782e.zip
am da498229: Merge "Plumbing for ProductionFlag.USES_CURSOR_ANCHOR_MONITOR"
* commit 'da498229f41b828209765774a6f7f8f1ad5f30c3': Plumbing for ProductionFlag.USES_CURSOR_ANCHOR_MONITOR
Diffstat (limited to 'java/src/com/android/inputmethod/compat')
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodServiceCompatUtils.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatUtils.java b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatUtils.java
index 14ee654f3..81df17127 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatUtils.java
@@ -17,11 +17,12 @@
package com.android.inputmethod.compat;
import android.inputmethodservice.InputMethodService;
+import com.android.inputmethod.latin.define.ProductionFlag;
import java.lang.reflect.Method;
public final class InputMethodServiceCompatUtils {
- // Note that InputMethodService.enableHardwareAcceleration() has been introduced
+ // Note that {@link InputMethodService#enableHardwareAcceleration} has been introduced
// in API level 17 (Build.VERSION_CODES.JELLY_BEAN_MR1).
private static final Method METHOD_enableHardwareAcceleration =
CompatUtils.getMethod(InputMethodService.class, "enableHardwareAcceleration");
@@ -34,4 +35,30 @@ public final class InputMethodServiceCompatUtils {
return (Boolean)CompatUtils.invoke(ims, false /* defaultValue */,
METHOD_enableHardwareAcceleration);
}
+
+ public static void setCursorAnchorMonitorMode(final InputMethodService ims, final int mode) {
+ if (ProductionFlag.USES_CURSOR_ANCHOR_MONITOR) {
+ ExperimentalAPIUtils.setCursorAnchorMonitorMode(ims, mode);
+ }
+ }
+
+ /*
+ * For unreleased APIs. ProGuard will strip this class entirely, unless used explicitly.
+ */
+ private static final class ExperimentalAPIUtils {
+ // Note that {@link InputMethodManager#setCursorAnchorMonitorMode} is not yet available as
+ // an official API as of API level 19 (Build.VERSION_CODES.KITKAT).
+ private static final Method METHOD_setCursorAnchorMonitorMode = CompatUtils.getMethod(
+ InputMethodService.class, "setCursorAnchorMonitorMode", int.class);
+
+ private ExperimentalAPIUtils() {
+ // This utility class is not publicly instantiable.
+ }
+
+ public static void setCursorAnchorMonitorMode(final InputMethodService ims,
+ final int mode) {
+ CompatUtils.invoke(ims, null /* defaultValue */,
+ METHOD_setCursorAnchorMonitorMode, mode);
+ }
+ }
}