1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.content.browser.input;
7 import android.content.Context;
8 import android.os.IBinder;
9 import android.os.ResultReceiver;
10 import android.view.View;
11 import android.view.inputmethod.InputMethodManager;
14 * Wrapper around Android's InputMethodManager
16 public class InputMethodManagerWrapper {
17 private final Context mContext;
19 public InputMethodManagerWrapper(Context context) {
23 private InputMethodManager getInputMethodManager() {
24 return (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
28 * @see android.view.inputmethod.InputMethodManager#restartInput(View)
30 public void restartInput(View view) {
31 getInputMethodManager().restartInput(view);
35 * @see android.view.inputmethod.InputMethodManager#showSoftInput(View, int, ResultReceiver)
37 public void showSoftInput(View view, int flags, ResultReceiver resultReceiver) {
38 getInputMethodManager().showSoftInput(view, flags, resultReceiver);
42 * @see android.view.inputmethod.InputMethodManager#isActive(View)
44 public boolean isActive(View view) {
45 return getInputMethodManager().isActive(view);
49 * @see InputMethodManager#hideSoftInputFromWindow(IBinder, int, ResultReceiver)
51 public boolean hideSoftInputFromWindow(IBinder windowToken, int flags,
52 ResultReceiver resultReceiver) {
53 return getInputMethodManager().hideSoftInputFromWindow(windowToken, flags, resultReceiver);
57 * @see android.view.inputmethod.InputMethodManager#updateSelection(View, int, int, int, int)
59 public void updateSelection(View view, int selStart, int selEnd,
60 int candidatesStart, int candidatesEnd) {
61 getInputMethodManager().updateSelection(view, selStart, selEnd, candidatesStart,
66 * @see android.view.inputmethod.InputMethodManager#isWatchingCursor(View)
68 @SuppressWarnings("deprecation")
69 public boolean isWatchingCursor(View view) {
70 // TODO(aurimas): InputMethodManager.isWatchingCursor() was deprecated in L. Fix
71 // this once the final Android L SDK is released.
72 return getInputMethodManager().isWatchingCursor(view);
76 * @see android.view.inputmethod.InputMethodManager#updateCursor(View, int, int, int, int)
78 @SuppressWarnings("deprecation")
79 public void updateCursor(View view, int left, int top, int right, int bottom) {
80 // TODO(aurimas): InputMethodManager.updateCursor() was deprecated in L. Fix
81 // this once the final Android L SDK is released.
82 getInputMethodManager().updateCursor(view, left, top, right, bottom);