aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-04-02 22:31:17 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-04-03 16:45:36 +0900
commit0d1a5d5b9710dd8fbdae18b0e69bccb53c7b9207 (patch)
tree514d976aea30db64b26a188d033f466fb6782877
parent13d6ecc4c275b9e9c38c7713bb2c69d37f3467f3 (diff)
downloadlatinime-0d1a5d5b9710dd8fbdae18b0e69bccb53c7b9207.tar.gz
latinime-0d1a5d5b9710dd8fbdae18b0e69bccb53c7b9207.tar.xz
latinime-0d1a5d5b9710dd8fbdae18b0e69bccb53c7b9207.zip
Cleanup EditorInfoCompatUtils
Bug: 6129704 Change-Id: I5b9964f2ad52e7cd60c63acca93d0241a1e729ef
-rw-r--r--java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java46
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java4
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java3
3 files changed, 8 insertions, 45 deletions
diff --git a/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
index 938388d6c..d1af7a527 100644
--- a/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
@@ -17,41 +17,14 @@
package com.android.inputmethod.compat;
import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputConnection;
import java.lang.reflect.Field;
public class EditorInfoCompatUtils {
- private static final Field FIELD_IME_FLAG_NAVIGATE_NEXT = CompatUtils.getField(
- EditorInfo.class, "IME_FLAG_NAVIGATE_NEXT");
- private static final Field FIELD_IME_FLAG_NAVIGATE_PREVIOUS = CompatUtils.getField(
- EditorInfo.class, "IME_FLAG_NAVIGATE_PREVIOUS");
private static final Field FIELD_IME_FLAG_FORCE_ASCII = CompatUtils.getField(
EditorInfo.class, "IME_FLAG_FORCE_ASCII");
- private static final Field FIELD_IME_ACTION_PREVIOUS = CompatUtils.getField(
- EditorInfo.class, "IME_ACTION_PREVIOUS");
- private static final Integer OBJ_IME_FLAG_NAVIGATE_NEXT = (Integer) CompatUtils
- .getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_NEXT);
- private static final Integer OBJ_IME_FLAG_NAVIGATE_PREVIOUS = (Integer) CompatUtils
- .getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_PREVIOUS);
private static final Integer OBJ_IME_FLAG_FORCE_ASCII = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_FLAG_FORCE_ASCII);
- private static final Integer OBJ_IME_ACTION_PREVIOUS = (Integer) CompatUtils
- .getFieldValue(null, null, FIELD_IME_ACTION_PREVIOUS);
-
- // EditorInfo.IME_FLAG_NAVIGATE_NEXT has been introduced since API#11 (Honeycomb).
- public static boolean hasFlagNavigateNext(int imeOptions) {
- if (OBJ_IME_FLAG_NAVIGATE_NEXT == null)
- return false;
- return (imeOptions & OBJ_IME_FLAG_NAVIGATE_NEXT) != 0;
- }
-
- // EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS has been introduced since API#11 (Honeycomb).
- public static boolean hasFlagNavigatePrevious(int imeOptions) {
- if (OBJ_IME_FLAG_NAVIGATE_PREVIOUS == null)
- return false;
- return (imeOptions & OBJ_IME_FLAG_NAVIGATE_PREVIOUS) != 0;
- }
// EditorInfo.IME_FLAG_FORCE_ASCII has been introduced since API#16 (JellyBean).
public static boolean hasFlagForceAscii(int imeOptions) {
@@ -60,13 +33,6 @@ public class EditorInfoCompatUtils {
return (imeOptions & OBJ_IME_FLAG_FORCE_ASCII) != 0;
}
- // EditorInfo.IME_ACTION_PREVIOUS has been introduced since API#11 (Honeycomb).
- public static void performEditorActionPrevious(InputConnection ic) {
- if (OBJ_IME_ACTION_PREVIOUS == null || ic == null)
- return;
- ic.performEditorAction(OBJ_IME_ACTION_PREVIOUS);
- }
-
public static String imeActionName(int imeOptions) {
final int actionId = imeOptions & EditorInfo.IME_MASK_ACTION;
switch (actionId) {
@@ -84,12 +50,10 @@ public class EditorInfoCompatUtils {
return "actionNext";
case EditorInfo.IME_ACTION_DONE:
return "actionDone";
+ case EditorInfo.IME_ACTION_PREVIOUS:
+ return "actionPrevious";
default:
- if (OBJ_IME_ACTION_PREVIOUS != null && actionId == OBJ_IME_ACTION_PREVIOUS) {
- return "actionPrevious";
- } else {
- return "actionUnknown(" + actionId + ")";
- }
+ return "actionUnknown(" + actionId + ")";
}
}
@@ -99,10 +63,10 @@ public class EditorInfoCompatUtils {
if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
flags.append("flagNoEnterAction|");
}
- if (hasFlagNavigateNext(imeOptions)) {
+ if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0) {
flags.append("flagNavigateNext|");
}
- if (hasFlagNavigatePrevious(imeOptions)) {
+ if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS) != 0) {
flags.append("flagNavigatePrevious|");
}
if (hasFlagForceAscii(imeOptions)) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index 3b2b11e4e..eef065f52 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -131,11 +131,11 @@ public class KeyboardId {
}
public boolean navigateNext() {
- return EditorInfoCompatUtils.hasFlagNavigateNext(mEditorInfo.imeOptions);
+ return (mEditorInfo.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0;
}
public boolean navigatePrevious() {
- return EditorInfoCompatUtils.hasFlagNavigatePrevious(mEditorInfo.imeOptions);
+ return (mEditorInfo.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS) != 0;
}
public boolean passwordInput() {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3b41e3b0c..177f5e629 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -56,7 +56,6 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.CompatUtils;
-import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.SuggestionSpanUtils;
import com.android.inputmethod.keyboard.Keyboard;
@@ -1273,7 +1272,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
performeEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
case Keyboard.CODE_ACTION_PREVIOUS:
- EditorInfoCompatUtils.performEditorActionPrevious(getCurrentInputConnection());
+ performeEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
break;
case Keyboard.CODE_LANGUAGE_SWITCH:
handleLanguageSwitchKey();