From 6fbbab3b8442ad010c53dc53a09535f7b0ef0323 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 9 Nov 2012 18:21:41 +0900 Subject: Enhance ImfUtils to InputMethodManagerWrapper class Change-Id: I6ff86ee819a446dd3ed5f9c3400d23564027b020 --- .../compat/InputMethodManagerCompatWrapper.java | 40 +++------------------- 1 file changed, 4 insertions(+), 36 deletions(-) (limited to 'java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java') diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index a01c301ee..8bd1e5208 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -19,53 +19,21 @@ package com.android.inputmethod.compat; import android.content.Context; import android.os.IBinder; import android.view.inputmethod.InputMethodManager; -import android.view.inputmethod.InputMethodSubtype; - -import com.android.inputmethod.latin.ImfUtils; import java.lang.reflect.Method; -// TODO: Override this class with the concrete implementation if we need to take care of the -// performance. public final class InputMethodManagerCompatWrapper { - private static final String TAG = InputMethodManagerCompatWrapper.class.getSimpleName(); private static final Method METHOD_switchToNextInputMethod = CompatUtils.getMethod( InputMethodManager.class, "switchToNextInputMethod", IBinder.class, Boolean.TYPE); - private static final InputMethodManagerCompatWrapper sInstance = - new InputMethodManagerCompatWrapper(); - - private InputMethodManager mImm; - - private InputMethodManagerCompatWrapper() { - // This wrapper class is not publicly instantiable. - } - - public static InputMethodManagerCompatWrapper getInstance() { - if (sInstance.mImm == null) { - throw new RuntimeException(TAG + ".getInstance() is called before initialization"); - } - return sInstance; - } - - public static void init(Context context) { - sInstance.mImm = ImfUtils.getInputMethodManager(context); - } - - public InputMethodSubtype getLastInputMethodSubtype() { - return mImm.getLastInputMethodSubtype(); - } + public final InputMethodManager mImm; - public boolean switchToLastInputMethod(IBinder token) { - return mImm.switchToLastInputMethod(token); + public InputMethodManagerCompatWrapper(final Context context) { + mImm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); } - public boolean switchToNextInputMethod(IBinder token, boolean onlyCurrentIme) { + public boolean switchToNextInputMethod(final IBinder token, final boolean onlyCurrentIme) { return (Boolean)CompatUtils.invoke(mImm, false, METHOD_switchToNextInputMethod, token, onlyCurrentIme); } - - public void showInputMethodPicker() { - mImm.showInputMethodPicker(); - } } -- cgit v1.2.3-83-g751a