aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/compat
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/compat')
-rw-r--r--java/src/com/android/inputmethod/compat/AbstractCompatWrapper.java39
-rw-r--r--java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java34
-rw-r--r--java/src/com/android/inputmethod/compat/CompatUtils.java38
-rw-r--r--java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java48
-rw-r--r--java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java63
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java77
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java167
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java109
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java188
-rw-r--r--java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java118
-rw-r--r--java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java23
-rw-r--r--java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java4
-rw-r--r--java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java1
-rw-r--r--java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java51
14 files changed, 43 insertions, 917 deletions
diff --git a/java/src/com/android/inputmethod/compat/AbstractCompatWrapper.java b/java/src/com/android/inputmethod/compat/AbstractCompatWrapper.java
deleted file mode 100644
index 2c31c55b0..000000000
--- a/java/src/com/android/inputmethod/compat/AbstractCompatWrapper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.util.Log;
-
-public abstract class AbstractCompatWrapper {
- private static final String TAG = AbstractCompatWrapper.class.getSimpleName();
- protected final Object mObj;
-
- public AbstractCompatWrapper(Object obj) {
- if (obj == null) {
- Log.e(TAG, "Invalid input to AbstractCompatWrapper");
- }
- mObj = obj;
- }
-
- public Object getOriginalObject() {
- return mObj;
- }
-
- public boolean hasOriginalObject() {
- return mObj != null;
- }
-}
diff --git a/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java b/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java
deleted file mode 100644
index 41b6a074d..000000000
--- a/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.view.accessibility.AccessibilityManager;
-
-import java.lang.reflect.Method;
-
-public class AccessibilityManagerCompatUtils {
- private static final Method METHOD_isTouchExplorationEnabled = CompatUtils.getMethod(
- AccessibilityManager.class, "isTouchExplorationEnabled");
-
- private AccessibilityManagerCompatUtils() {
- // This class is non-instantiable.
- }
-
- public static boolean isTouchExplorationEnabled(AccessibilityManager receiver) {
- return (Boolean) CompatUtils.invoke(receiver, false, METHOD_isTouchExplorationEnabled);
- }
-}
diff --git a/java/src/com/android/inputmethod/compat/CompatUtils.java b/java/src/com/android/inputmethod/compat/CompatUtils.java
index ba82a06ac..ce427e9c9 100644
--- a/java/src/com/android/inputmethod/compat/CompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/CompatUtils.java
@@ -23,8 +23,6 @@ import android.util.Log;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
public class CompatUtils {
private static final String TAG = CompatUtils.class.getSimpleName();
@@ -35,23 +33,16 @@ public class CompatUtils {
public static Intent getInputLanguageSelectionIntent(String inputMethodId,
int flagsForSubtypeSettings) {
- final String action;
- Intent intent;
- if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED
- /* android.os.Build.VERSION_CODES.HONEYCOMB */
- && android.os.Build.VERSION.SDK_INT >= 11) {
- // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS
- action = INPUT_METHOD_SUBTYPE_SETTINGS;
- intent = new Intent(action);
- if (!TextUtils.isEmpty(inputMethodId)) {
- intent.putExtra(EXTRA_INPUT_METHOD_ID, inputMethodId);
- }
- if (flagsForSubtypeSettings > 0) {
- intent.setFlags(flagsForSubtypeSettings);
- }
- return intent;
+ // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS
+ final String action = INPUT_METHOD_SUBTYPE_SETTINGS;
+ final Intent intent = new Intent(action);
+ if (!TextUtils.isEmpty(inputMethodId)) {
+ intent.putExtra(EXTRA_INPUT_METHOD_ID, inputMethodId);
}
- throw new RuntimeException("Language selection doesn't supported on this platform");
+ if (flagsForSubtypeSettings > 0) {
+ intent.setFlags(flagsForSubtypeSettings);
+ }
+ return intent;
}
public static Class<?> getClass(String className) {
@@ -138,15 +129,4 @@ public class CompatUtils {
Log.e(TAG, "Exception in setFieldValue: " + e.getClass().getSimpleName());
}
}
-
- public static List<InputMethodSubtypeCompatWrapper> copyInputMethodSubtypeListToWrapper(
- Object listObject) {
- if (!(listObject instanceof List<?>)) return null;
- final List<InputMethodSubtypeCompatWrapper> subtypes =
- new ArrayList<InputMethodSubtypeCompatWrapper>();
- for (Object o: (List<?>)listObject) {
- subtypes.add(new InputMethodSubtypeCompatWrapper(o));
- }
- return subtypes;
- }
}
diff --git a/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
index 938388d6c..08c246f8b 100644
--- a/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
@@ -17,56 +17,26 @@
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");
+ // EditorInfo.IME_FLAG_FORCE_ASCII has been introduced since API#16 (JellyBean).
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;
+ private EditorInfoCompatUtils() {
+ // This utility class is not publicly instantiable.
}
- // EditorInfo.IME_FLAG_FORCE_ASCII has been introduced since API#16 (JellyBean).
public static boolean hasFlagForceAscii(int imeOptions) {
if (OBJ_IME_FLAG_FORCE_ASCII == null)
return false;
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 +54,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 +67,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/compat/FrameLayoutCompatUtils.java b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
deleted file mode 100644
index 523bf7d0e..000000000
--- a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewGroup.MarginLayoutParams;
-import android.widget.FrameLayout;
-import android.widget.RelativeLayout;
-
-public class FrameLayoutCompatUtils {
- private static final boolean NEEDS_FRAME_LAYOUT_HACK = (
- android.os.Build.VERSION.SDK_INT < 11 /* Honeycomb */);
-
- public static ViewGroup getPlacer(ViewGroup container) {
- if (NEEDS_FRAME_LAYOUT_HACK) {
- // Insert RelativeLayout to be able to setMargin because pre-Honeycomb FrameLayout
- // could not handle setMargin properly.
- final ViewGroup placer = new RelativeLayout(container.getContext());
- container.addView(placer);
- return placer;
- } else {
- return container;
- }
- }
-
- public static MarginLayoutParams newLayoutParam(ViewGroup placer, int width, int height) {
- if (placer instanceof FrameLayout) {
- return new FrameLayout.LayoutParams(width, height);
- } else if (placer instanceof RelativeLayout) {
- return new RelativeLayout.LayoutParams(width, height);
- } else if (placer == null) {
- throw new NullPointerException("placer is null");
- } else {
- throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: "
- + placer.getClass().getName());
- }
- }
-
- public static void placeViewAt(View view, int x, int y, int w, int h) {
- final ViewGroup.LayoutParams lp = view.getLayoutParams();
- if (lp instanceof MarginLayoutParams) {
- final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp;
- marginLayoutParams.width = w;
- marginLayoutParams.height = h;
- marginLayoutParams.setMargins(x, y, 0, 0);
- }
- }
-}
diff --git a/java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java
deleted file mode 100644
index 831559809..000000000
--- a/java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
-import android.view.inputmethod.InputMethodInfo;
-
-import java.lang.reflect.Method;
-
-public class InputMethodInfoCompatWrapper {
- private final InputMethodInfo mImi;
- private static final Method METHOD_getSubtypeAt = CompatUtils.getMethod(
- InputMethodInfo.class, "getSubtypeAt", int.class);
- private static final Method METHOD_getSubtypeCount = CompatUtils.getMethod(
- InputMethodInfo.class, "getSubtypeCount");
-
- public InputMethodInfoCompatWrapper(InputMethodInfo imi) {
- mImi = imi;
- }
-
- public InputMethodInfo getInputMethodInfo() {
- return mImi;
- }
-
- public String getId() {
- return mImi.getId();
- }
-
- public String getPackageName() {
- return mImi.getPackageName();
- }
-
- public ServiceInfo getServiceInfo() {
- return mImi.getServiceInfo();
- }
-
- public int getSubtypeCount() {
- return (Integer) CompatUtils.invoke(mImi, 0, METHOD_getSubtypeCount);
- }
-
- public InputMethodSubtypeCompatWrapper getSubtypeAt(int index) {
- return new InputMethodSubtypeCompatWrapper(CompatUtils.invoke(mImi, null,
- METHOD_getSubtypeAt, index));
- }
-
- public CharSequence loadLabel(PackageManager pm) {
- return mImi.loadLabel(pm);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof InputMethodInfoCompatWrapper) {
- return mImi.equals(((InputMethodInfoCompatWrapper)o).mImi);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return mImi.hashCode();
- }
-}
diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
index 3df6bea4b..ffed8202d 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
@@ -16,69 +16,33 @@
package com.android.inputmethod.compat;
-import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
+import android.inputmethodservice.InputMethodService;
import android.os.IBinder;
-import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
-
-import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.SubtypeSwitcher;
-import com.android.inputmethod.latin.SubtypeUtils;
+import android.view.inputmethod.InputMethodSubtype;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
// TODO: Override this class with the concrete implementation if we need to take care of the
// performance.
public class InputMethodManagerCompatWrapper {
private static final String TAG = InputMethodManagerCompatWrapper.class.getSimpleName();
- private static final Method METHOD_getCurrentInputMethodSubtype =
- CompatUtils.getMethod(InputMethodManager.class, "getCurrentInputMethodSubtype");
- private static final Method METHOD_getLastInputMethodSubtype =
- CompatUtils.getMethod(InputMethodManager.class, "getLastInputMethodSubtype");
- private static final Method METHOD_getEnabledInputMethodSubtypeList =
- CompatUtils.getMethod(InputMethodManager.class, "getEnabledInputMethodSubtypeList",
- InputMethodInfo.class, boolean.class);
- private static final Method METHOD_getShortcutInputMethodsAndSubtypes =
- CompatUtils.getMethod(InputMethodManager.class, "getShortcutInputMethodsAndSubtypes");
- private static final Method METHOD_setInputMethodAndSubtype =
- CompatUtils.getMethod(
- InputMethodManager.class, "setInputMethodAndSubtype", IBinder.class,
- String.class, InputMethodSubtypeCompatWrapper.CLASS_InputMethodSubtype);
- private static final Method METHOD_switchToLastInputMethod = CompatUtils.getMethod(
- InputMethodManager.class, "switchToLastInputMethod", IBinder.class);
private static final Method METHOD_switchToNextInputMethod = CompatUtils.getMethod(
InputMethodManager.class, "switchToNextInputMethod", IBinder.class, Boolean.TYPE);
private static final InputMethodManagerCompatWrapper sInstance =
new InputMethodManagerCompatWrapper();
- // For the compatibility, IMM will create dummy subtypes if subtypes are not found.
- // This is required to be false if the current behavior is broken. For now, it's ok to be true.
- public static final boolean FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES =
- !InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED;
- private static final String VOICE_MODE = "voice";
- private static final String KEYBOARD_MODE = "keyboard";
-
- private InputMethodServiceCompatWrapper mService;
private InputMethodManager mImm;
- private PackageManager mPackageManager;
- private ApplicationInfo mApplicationInfo;
- private String mLatinImePackageName;
+
+ private InputMethodManagerCompatWrapper() {
+ // This wrapper class is not publicly instantiable.
+ }
public static InputMethodManagerCompatWrapper getInstance() {
if (sInstance.mImm == null)
@@ -86,120 +50,35 @@ public class InputMethodManagerCompatWrapper {
return sInstance;
}
- public static void init(InputMethodServiceCompatWrapper service) {
- sInstance.mService = service;
+ public static void init(InputMethodService service) {
sInstance.mImm = (InputMethodManager) service.getSystemService(
Context.INPUT_METHOD_SERVICE);
- sInstance.mLatinImePackageName = service.getPackageName();
- sInstance.mPackageManager = service.getPackageManager();
- sInstance.mApplicationInfo = service.getApplicationInfo();
- }
-
- public InputMethodSubtypeCompatWrapper getCurrentInputMethodSubtype() {
- Object o = CompatUtils.invoke(mImm, null, METHOD_getCurrentInputMethodSubtype);
- return new InputMethodSubtypeCompatWrapper(o);
- }
-
- public InputMethodSubtypeCompatWrapper getLastInputMethodSubtype() {
- Object o = CompatUtils.invoke(mImm, null, METHOD_getLastInputMethodSubtype);
- return new InputMethodSubtypeCompatWrapper(o);
}
- public List<InputMethodSubtypeCompatWrapper> getEnabledInputMethodSubtypeList(
- InputMethodInfoCompatWrapper imi, boolean allowsImplicitlySelectedSubtypes) {
- Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList,
- (imi != null ? imi.getInputMethodInfo() : null), allowsImplicitlySelectedSubtypes);
- if (retval == null || !(retval instanceof List<?>) || ((List<?>)retval).isEmpty()) {
- if (!FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES) {
- // Returns an empty list
- return Collections.emptyList();
- }
- // Creates dummy subtypes
- @SuppressWarnings("unused")
- List<InputMethodSubtypeCompatWrapper> subtypeList =
- new ArrayList<InputMethodSubtypeCompatWrapper>();
- InputMethodSubtypeCompatWrapper keyboardSubtype = getLastResortSubtype(KEYBOARD_MODE);
- InputMethodSubtypeCompatWrapper voiceSubtype = getLastResortSubtype(VOICE_MODE);
- if (keyboardSubtype != null) {
- subtypeList.add(keyboardSubtype);
- }
- if (voiceSubtype != null) {
- subtypeList.add(voiceSubtype);
- }
- return subtypeList;
- }
- return CompatUtils.copyInputMethodSubtypeListToWrapper(retval);
+ public InputMethodSubtype getCurrentInputMethodSubtype() {
+ return mImm.getCurrentInputMethodSubtype();
}
- private InputMethodInfoCompatWrapper getLatinImeInputMethodInfo() {
- if (TextUtils.isEmpty(mLatinImePackageName))
- return null;
- return SubtypeUtils.getInputMethodInfo(mLatinImePackageName);
+ public InputMethodSubtype getLastInputMethodSubtype() {
+ return mImm.getLastInputMethodSubtype();
}
- private static InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode) {
- if (VOICE_MODE.equals(mode) && !FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES)
- return null;
- Locale inputLocale = SubtypeSwitcher.getInstance().getInputLocale();
- if (inputLocale == null)
- return null;
- return new InputMethodSubtypeCompatWrapper(0, 0, inputLocale.toString(), mode, "");
+ public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(
+ InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) {
+ return mImm.getEnabledInputMethodSubtypeList(imi, allowsImplicitlySelectedSubtypes);
}
- public Map<InputMethodInfoCompatWrapper, List<InputMethodSubtypeCompatWrapper>>
- getShortcutInputMethodsAndSubtypes() {
- Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes);
- if (retval == null || !(retval instanceof Map<?, ?>) || ((Map<?, ?>)retval).isEmpty()) {
- if (!FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES) {
- // Returns an empty map
- return Collections.emptyMap();
- }
- // Creates dummy subtypes
- @SuppressWarnings("unused")
- InputMethodInfoCompatWrapper imi = getLatinImeInputMethodInfo();
- InputMethodSubtypeCompatWrapper voiceSubtype = getLastResortSubtype(VOICE_MODE);
- if (imi != null && voiceSubtype != null) {
- Map<InputMethodInfoCompatWrapper, List<InputMethodSubtypeCompatWrapper>>
- shortcutMap =
- new HashMap<InputMethodInfoCompatWrapper,
- List<InputMethodSubtypeCompatWrapper>>();
- List<InputMethodSubtypeCompatWrapper> subtypeList =
- new ArrayList<InputMethodSubtypeCompatWrapper>();
- subtypeList.add(voiceSubtype);
- shortcutMap.put(imi, subtypeList);
- return shortcutMap;
- } else {
- return Collections.emptyMap();
- }
- }
- Map<InputMethodInfoCompatWrapper, List<InputMethodSubtypeCompatWrapper>> shortcutMap =
- new HashMap<InputMethodInfoCompatWrapper, List<InputMethodSubtypeCompatWrapper>>();
- final Map<?, ?> retvalMap = (Map<?, ?>)retval;
- for (Object key : retvalMap.keySet()) {
- if (!(key instanceof InputMethodInfo)) {
- Log.e(TAG, "Class type error.");
- return null;
- }
- shortcutMap.put(new InputMethodInfoCompatWrapper((InputMethodInfo)key),
- CompatUtils.copyInputMethodSubtypeListToWrapper(retvalMap.get(key)));
- }
- return shortcutMap;
+ public Map<InputMethodInfo, List<InputMethodSubtype>> getShortcutInputMethodsAndSubtypes() {
+ return mImm.getShortcutInputMethodsAndSubtypes();
}
// We don't call this method when we switch between subtypes within this IME.
- public void setInputMethodAndSubtype(
- IBinder token, String id, InputMethodSubtypeCompatWrapper subtype) {
- // TODO: Support subtype change on non-subtype-supported platform.
- if (subtype != null && subtype.hasOriginalObject()) {
- CompatUtils.invoke(mImm, null, METHOD_setInputMethodAndSubtype,
- token, id, subtype.getOriginalObject());
- } else {
- mImm.setInputMethod(token, id);
- }
+ public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) {
+ mImm.setInputMethodAndSubtype(token, id, subtype);
}
public boolean switchToLastInputMethod(IBinder token) {
- return (Boolean)CompatUtils.invoke(mImm, false, METHOD_switchToLastInputMethod, token);
+ return mImm.switchToLastInputMethod(token);
}
public boolean switchToNextInputMethod(IBinder token, boolean onlyCurrentIme) {
@@ -207,13 +86,9 @@ public class InputMethodManagerCompatWrapper {
onlyCurrentIme);
}
- public List<InputMethodInfoCompatWrapper> getEnabledInputMethodList() {
+ public List<InputMethodInfo> getEnabledInputMethodList() {
if (mImm == null) return null;
- List<InputMethodInfoCompatWrapper> imis = new ArrayList<InputMethodInfoCompatWrapper>();
- for (InputMethodInfo imi : mImm.getEnabledInputMethodList()) {
- imis.add(new InputMethodInfoCompatWrapper(imi));
- }
- return imis;
+ return mImm.getEnabledInputMethodList();
}
public void showInputMethodPicker() {
diff --git a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java
deleted file mode 100644
index 7c15be300..000000000
--- a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.app.AlertDialog;
-import android.inputmethodservice.InputMethodService;
-import android.os.IBinder;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.inputmethod.InputMethodSubtype;
-
-import com.android.inputmethod.keyboard.KeyboardSwitcher;
-import com.android.inputmethod.latin.SubtypeSwitcher;
-
-public class InputMethodServiceCompatWrapper extends InputMethodService {
- // CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED needs to be false if the API level is 10
- // or previous. Note that InputMethodSubtype was added in the API level 11.
- // For the API level 11 or later, LatinIME should override onCurrentInputMethodSubtypeChanged().
- // For the API level 10 or previous, we handle the "subtype changed" events by ourselves
- // without having support from framework -- onCurrentInputMethodSubtypeChanged().
- public static final boolean CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED = true;
-
- private InputMethodManagerCompatWrapper mImm;
-
- // For compatibility of {@link InputMethodManager#showInputMethodPicker}.
- // TODO: Move this variable back to LatinIME when this compatibility wrapper is removed.
- protected AlertDialog mOptionsDialog;
-
- public void showOptionDialogInternal(AlertDialog dialog) {
- final IBinder windowToken = KeyboardSwitcher.getInstance().getKeyboardView()
- .getWindowToken();
- if (windowToken == null) return;
-
- dialog.setCancelable(true);
- dialog.setCanceledOnTouchOutside(true);
-
- final Window window = dialog.getWindow();
- final WindowManager.LayoutParams lp = window.getAttributes();
- lp.token = windowToken;
- lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
- window.setAttributes(lp);
- window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
-
- mOptionsDialog = dialog;
- dialog.show();
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- mImm = InputMethodManagerCompatWrapper.getInstance();
- }
-
- // When the API level is 10 or previous, notifyOnCurrentInputMethodSubtypeChanged should
- // handle the event the current subtype was changed. LatinIME calls
- // notifyOnCurrentInputMethodSubtypeChanged every time LatinIME
- // changes the current subtype.
- // This call is required to let LatinIME itself know a subtype changed
- // event when the API level is 10 or previous.
- @SuppressWarnings("unused")
- public void notifyOnCurrentInputMethodSubtypeChanged(
- InputMethodSubtypeCompatWrapper newSubtype) {
- // Do nothing when the API level is 11 or later
- // and FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES is not true
- if (CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED && !InputMethodManagerCompatWrapper.
- FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES) {
- return;
- }
- final InputMethodSubtypeCompatWrapper subtype = (newSubtype == null)
- ? mImm.getCurrentInputMethodSubtype()
- : newSubtype;
- if (subtype != null) {
- if (!InputMethodManagerCompatWrapper.FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES
- && !subtype.isDummy()) return;
- SubtypeSwitcher.getInstance().updateSubtype(subtype);
- }
- }
-
- //////////////////////////////////////
- // Functions using API v11 or later //
- //////////////////////////////////////
- @Override
- public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) {
- // Do nothing when the API level is 10 or previous
- if (!CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) return;
- 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/compat/InputMethodSubtypeCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java
deleted file mode 100644
index 574158825..000000000
--- a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.inputmethod.latin.LatinImeLogger;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Locale;
-
-// TODO: Override this class with the concrete implementation if we need to take care of the
-// performance.
-public class InputMethodSubtypeCompatWrapper extends AbstractCompatWrapper {
- private static final boolean DBG = LatinImeLogger.sDBG;
- private static final String TAG = InputMethodSubtypeCompatWrapper.class.getSimpleName();
- private static final String DEFAULT_LOCALE = "en_US";
- private static final String DEFAULT_MODE = "keyboard";
-
- public static final Class<?> CLASS_InputMethodSubtype =
- CompatUtils.getClass("android.view.inputmethod.InputMethodSubtype");
- private static final Method METHOD_getNameResId =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getNameResId");
- private static final Method METHOD_getIconResId =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getIconResId");
- private static final Method METHOD_getLocale =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getLocale");
- private static final Method METHOD_getMode =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getMode");
- private static final Method METHOD_getExtraValue =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getExtraValue");
- private static final Method METHOD_containsExtraValueKey =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "containsExtraValueKey", String.class);
- private static final Method METHOD_getExtraValueOf =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getExtraValueOf", String.class);
- private static final Method METHOD_isAuxiliary =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "isAuxiliary");
- private static final Method METHOD_getDisplayName =
- CompatUtils.getMethod(CLASS_InputMethodSubtype, "getDisplayName", Context.class,
- String.class, ApplicationInfo.class);
-
- private final int mDummyNameResId;
- private final int mDummyIconResId;
- private final String mDummyLocale;
- private final String mDummyMode;
- private final String mDummyExtraValues;
-
- public InputMethodSubtypeCompatWrapper(Object subtype) {
- super((CLASS_InputMethodSubtype != null && CLASS_InputMethodSubtype.isInstance(subtype))
- ? subtype : new Object());
- mDummyNameResId = 0;
- mDummyIconResId = 0;
- mDummyLocale = DEFAULT_LOCALE;
- mDummyMode = DEFAULT_MODE;
- mDummyExtraValues = "";
- }
-
- // Constructor for creating a dummy subtype.
- public InputMethodSubtypeCompatWrapper(int nameResId, int iconResId, String locale,
- String mode, String extraValues) {
- super(new Object());
- if (DBG) {
- Log.d(TAG, "CreateInputMethodSubtypeCompatWrapper");
- }
- mDummyNameResId = nameResId;
- mDummyIconResId = iconResId;
- mDummyLocale = locale != null ? locale : "";
- mDummyMode = mode != null ? mode : "";
- mDummyExtraValues = extraValues != null ? extraValues : "";
- }
-
- public int getNameResId() {
- if (mObj == null) return mDummyNameResId;
- return (Integer)CompatUtils.invoke(mObj, 0, METHOD_getNameResId);
- }
-
- public int getIconResId() {
- if (mObj == null) return mDummyIconResId;
- return (Integer)CompatUtils.invoke(mObj, 0, METHOD_getIconResId);
- }
-
- public String getLocale() {
- if (mObj == null) return mDummyLocale;
- final String s = (String)CompatUtils.invoke(mObj, null, METHOD_getLocale);
- return s != null ? s : DEFAULT_LOCALE;
- }
-
- public String getMode() {
- if (mObj == null) return mDummyMode;
- String s = (String)CompatUtils.invoke(mObj, null, METHOD_getMode);
- if (TextUtils.isEmpty(s)) return DEFAULT_MODE;
- return s;
- }
-
- public String getExtraValue() {
- if (mObj == null) return mDummyExtraValues;
- return (String)CompatUtils.invoke(mObj, null, METHOD_getExtraValue);
- }
-
- public boolean containsExtraValueKey(String key) {
- return (Boolean)CompatUtils.invoke(mObj, false, METHOD_containsExtraValueKey, key);
- }
-
- public String getExtraValueOf(String key) {
- return (String)CompatUtils.invoke(mObj, null, METHOD_getExtraValueOf, key);
- }
-
- public boolean isAuxiliary() {
- return (Boolean)CompatUtils.invoke(mObj, false, METHOD_isAuxiliary);
- }
-
- public CharSequence getDisplayName(Context context, String packageName,
- ApplicationInfo appInfo) {
- if (mObj != null) {
- return (CharSequence)CompatUtils.invoke(
- mObj, "", METHOD_getDisplayName, context, packageName, appInfo);
- }
-
- // The code below are based on {@link InputMethodSubtype#getDisplayName}.
-
- final Locale locale = new Locale(getLocale());
- final String localeStr = locale.getDisplayName();
- if (getNameResId() == 0) {
- return localeStr;
- }
- final CharSequence subtypeName = context.getText(getNameResId());
- if (!TextUtils.isEmpty(localeStr)) {
- return String.format(subtypeName.toString(), localeStr);
- } else {
- return localeStr;
- }
- }
-
- public boolean isDummy() {
- return !hasOriginalObject();
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof InputMethodSubtypeCompatWrapper) {
- InputMethodSubtypeCompatWrapper subtype = (InputMethodSubtypeCompatWrapper)o;
- if (mObj == null) {
- // easy check of dummy subtypes
- return (mDummyNameResId == subtype.mDummyNameResId
- && mDummyIconResId == subtype.mDummyIconResId
- && mDummyLocale.equals(subtype.mDummyLocale)
- && mDummyMode.equals(subtype.mDummyMode)
- && mDummyExtraValues.equals(subtype.mDummyExtraValues));
- }
- return mObj.equals(subtype.getOriginalObject());
- } else {
- return mObj.equals(o);
- }
- }
-
- @Override
- public int hashCode() {
- if (mObj == null) {
- return hashCodeInternal(mDummyNameResId, mDummyIconResId, mDummyLocale,
- mDummyMode, mDummyExtraValues);
- }
- return mObj.hashCode();
- }
-
- private static int hashCodeInternal(int nameResId, int iconResId, String locale,
- String mode, String extraValue) {
- return Arrays
- .hashCode(new Object[] { nameResId, iconResId, locale, mode, extraValue });
- }
-}
diff --git a/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java b/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java
deleted file mode 100644
index 6c2f0f799..000000000
--- a/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.text.InputType;
-
-import java.lang.reflect.Field;
-
-public class InputTypeCompatUtils {
- private static final Field FIELD_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS =
- CompatUtils.getField(InputType.class, "TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS");
- private static final Field FIELD_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD = CompatUtils
- .getField(InputType.class, "TYPE_TEXT_VARIATION_WEB_PASSWORD");
- private static final Field FIELD_InputType_TYPE_NUMBER_VARIATION_PASSWORD = CompatUtils
- .getField(InputType.class, "TYPE_NUMBER_VARIATION_PASSWORD");
- private static final Integer OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS =
- (Integer) CompatUtils.getFieldValue(null, null,
- FIELD_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
- private static final Integer OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD =
- (Integer) CompatUtils.getFieldValue(null, null,
- FIELD_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD);
- private static final Integer OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD =
- (Integer) CompatUtils.getFieldValue(null, null,
- FIELD_InputType_TYPE_NUMBER_VARIATION_PASSWORD);
- private static final int WEB_TEXT_PASSWORD_INPUT_TYPE;
- private static final int WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE;
- private static final int NUMBER_PASSWORD_INPUT_TYPE;
- private static final int TEXT_PASSWORD_INPUT_TYPE =
- InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
- private static final int TEXT_VISIBLE_PASSWORD_INPUT_TYPE =
- InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
-
- static {
- WEB_TEXT_PASSWORD_INPUT_TYPE =
- OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD != null
- ? InputType.TYPE_CLASS_TEXT | OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD
- : 0;
- WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE =
- OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != null
- ? InputType.TYPE_CLASS_TEXT
- | OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS
- : 0;
- NUMBER_PASSWORD_INPUT_TYPE =
- OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD != null
- ? InputType.TYPE_CLASS_NUMBER | OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD
- : 0;
- }
-
- private static boolean isWebEditTextInputType(int inputType) {
- return inputType == (InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
- }
-
- private static boolean isWebPasswordInputType(int inputType) {
- return WEB_TEXT_PASSWORD_INPUT_TYPE != 0
- && inputType == WEB_TEXT_PASSWORD_INPUT_TYPE;
- }
-
- private static boolean isWebEmailAddressInputType(int inputType) {
- return WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE != 0
- && inputType == WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE;
- }
-
- private static boolean isNumberPasswordInputType(int inputType) {
- return NUMBER_PASSWORD_INPUT_TYPE != 0
- && inputType == NUMBER_PASSWORD_INPUT_TYPE;
- }
-
- private static boolean isTextPasswordInputType(int inputType) {
- return inputType == TEXT_PASSWORD_INPUT_TYPE;
- }
-
- private static boolean isWebEmailAddressVariation(int variation) {
- return OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != null
- && variation == OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
- }
-
- public static boolean isEmailVariation(int variation) {
- return variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
- || isWebEmailAddressVariation(variation);
- }
-
- public static boolean isWebInputType(int inputType) {
- final int maskedInputType =
- inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_MASK_VARIATION);
- return isWebEditTextInputType(maskedInputType) || isWebPasswordInputType(maskedInputType)
- || isWebEmailAddressInputType(maskedInputType);
- }
-
- // Please refer to TextView.isPasswordInputType
- public static boolean isPasswordInputType(int inputType) {
- final int maskedInputType =
- inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_MASK_VARIATION);
- return isTextPasswordInputType(maskedInputType) || isWebPasswordInputType(maskedInputType)
- || isNumberPasswordInputType(maskedInputType);
- }
-
- // Please refer to TextView.isVisiblePasswordInputType
- public static boolean isVisiblePasswordInputType(int inputType) {
- final int maskedInputType =
- inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_MASK_VARIATION);
- return maskedInputType == TEXT_VISIBLE_PASSWORD_INPUT_TYPE;
- }
-}
diff --git a/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java b/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
deleted file mode 100644
index 9a523011a..000000000
--- a/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-public class MotionEventCompatUtils {
- // TODO: Remove after these are added to MotionEventCompat.
- public static final int ACTION_HOVER_ENTER = 0x9;
- public static final int ACTION_HOVER_EXIT = 0xA;
-}
diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
index df55aee94..5c351e41f 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
@@ -77,6 +77,10 @@ public class SuggestionSpanUtils {
}
}
+ private SuggestionSpanUtils() {
+ // This utility class is not publicly instantiable.
+ }
+
public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(
Context context, CharSequence text) {
if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null
diff --git a/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java
index 723ec2862..e5f9db27c 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java
@@ -30,6 +30,7 @@ public class SuggestionsInfoCompatUtils {
? OBJ_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS : 0;
private SuggestionsInfoCompatUtils() {
+ // This utility class is not publicly instantiable.
}
/**
diff --git a/java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java b/java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java
deleted file mode 100644
index d19bc3af1..000000000
--- a/java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.view.View;
-import android.view.ViewParent;
-import android.view.accessibility.AccessibilityEvent;
-
-import java.lang.reflect.Method;
-
-public class ViewParentCompatUtils {
- private static final Method METHOD_requestSendAccessibilityEvent = CompatUtils.getMethod(
- ViewParent.class, "requestSendAccessibilityEvent", View.class,
- AccessibilityEvent.class);
-
- /**
- * Called by a child to request from its parent to send an {@link AccessibilityEvent}.
- * The child has already populated a record for itself in the event and is delegating
- * to its parent to send the event. The parent can optionally add a record for itself.
- * <p>
- * Note: An accessibility event is fired by an individual view which populates the
- * event with a record for its state and requests from its parent to perform
- * the sending. The parent can optionally add a record for itself before
- * dispatching the request to its parent. A parent can also choose not to
- * respect the request for sending the event. The accessibility event is sent
- * by the topmost view in the view tree.</p>
- *
- * @param child The child which requests sending the event.
- * @param event The event to be sent.
- * @return True if the event was sent.
- */
- public static boolean requestSendAccessibilityEvent(
- ViewParent receiver, View child, AccessibilityEvent event) {
- return (Boolean) CompatUtils.invoke(
- receiver, false, METHOD_requestSendAccessibilityEvent, child, event);
- }
-}