aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-03-23 16:15:07 -0700
committersatok <satok@google.com>2011-03-24 13:27:45 -0700
commit24119dfd414f948b2da214c021cc76e06b3dd41c (patch)
tree038708fb74300769e35d6d7c3a500f699637f8e4 /java
parentb916fab1960475505cb0d554255bf08364e5c71f (diff)
downloadlatinime-24119dfd414f948b2da214c021cc76e06b3dd41c.tar.gz
latinime-24119dfd414f948b2da214c021cc76e06b3dd41c.tar.xz
latinime-24119dfd414f948b2da214c021cc76e06b3dd41c.zip
Moved a functionality of setting touchableRegion to InputMethodServiceCompatWrapper.
Change-Id: I8b9fe507885ef5ae7cb09db93a977e23b1bbd0db
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/compat/CompatUtils.java35
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java6
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java3
3 files changed, 42 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/compat/CompatUtils.java b/java/src/com/android/inputmethod/compat/CompatUtils.java
index fea15fda5..8bf59091f 100644
--- a/java/src/com/android/inputmethod/compat/CompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/CompatUtils.java
@@ -20,6 +20,7 @@ import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -77,6 +78,18 @@ public class CompatUtils {
}
}
+ public static Field getField(Class<?> targetClass, String name) {
+ try {
+ return targetClass.getField(name);
+ } catch (SecurityException e) {
+ // ignore
+ return null;
+ } catch (NoSuchFieldException e) {
+ // ignore
+ return null;
+ }
+ }
+
public static Object invoke(
Object receiver, Object defaultValue, Method method, Object... args) {
if (receiver == null || method == null) return defaultValue;
@@ -94,6 +107,28 @@ public class CompatUtils {
}
}
+ public static Object getFieldValue(Object receiver, Object defaultValue, Field field) {
+ if (receiver == null || field == null) return defaultValue;
+ try {
+ return field.get(receiver);
+ } catch (IllegalArgumentException e) {
+ return defaultValue;
+ } catch (IllegalAccessException e) {
+ return defaultValue;
+ }
+ }
+
+ public static void setFieldValue(Object receiver, Field field, Object value) {
+ if (receiver == null || field == null) return;
+ try {
+ field.set(receiver, value);
+ } catch (IllegalArgumentException e) {
+ // ignore
+ } catch (IllegalAccessException e) {
+ // ignore
+ }
+ }
+
public static List<InputMethodSubtypeCompatWrapper> copyInputMethodSubtypeListToWrapper(
Object listObject) {
if (!(listObject instanceof List<?>)) return null;
diff --git a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java
index 72f3ca0d0..606322af7 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java
@@ -62,4 +62,10 @@ public class InputMethodServiceCompatWrapper extends InputMethodService {
SubtypeSwitcher.getInstance().updateSubtype(
new InputMethodSubtypeCompatWrapper(subtype));
}
+
+ protected static void setTouchableRegionCompat(InputMethodService.Insets outInsets,
+ int x, int y, int width, int height) {
+ outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
+ outInsets.touchableRegion.set(x, y, width, height);
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index b89fcbfcf..6ae6bd60f 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -914,8 +914,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (DEBUG) {
Log.d(TAG, "Touchable region " + x + ", " + y + ", " + width + ", " + height);
}
- outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
- outInsets.touchableRegion.set(x, y, width, height);
+ setTouchableRegionCompat(outInsets, x, y, width, height);
}
}