• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 package org.chromium.content.browser.input;
6 
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;
12 
13 /**
14  * Wrapper around Android's InputMethodManager
15  */
16 public class InputMethodManagerWrapper {
17     private final Context mContext;
18 
InputMethodManagerWrapper(Context context)19     public InputMethodManagerWrapper(Context context) {
20         mContext = context;
21     }
22 
getInputMethodManager()23     private InputMethodManager getInputMethodManager() {
24         return (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
25     }
26 
27     /**
28      * @see android.view.inputmethod.InputMethodManager#restartInput(View)
29      */
restartInput(View view)30     public void restartInput(View view) {
31         getInputMethodManager().restartInput(view);
32     }
33 
34     /**
35      * @see android.view.inputmethod.InputMethodManager#showSoftInput(View, int, ResultReceiver)
36      */
showSoftInput(View view, int flags, ResultReceiver resultReceiver)37     public void showSoftInput(View view, int flags, ResultReceiver resultReceiver) {
38         getInputMethodManager().showSoftInput(view, flags, resultReceiver);
39     }
40 
41     /**
42      * @see android.view.inputmethod.InputMethodManager#isActive(View)
43      */
isActive(View view)44     public boolean isActive(View view) {
45         return getInputMethodManager().isActive(view);
46     }
47 
48     /**
49      * @see InputMethodManager#hideSoftInputFromWindow(IBinder, int, ResultReceiver)
50      */
hideSoftInputFromWindow(IBinder windowToken, int flags, ResultReceiver resultReceiver)51     public boolean hideSoftInputFromWindow(IBinder windowToken, int flags,
52             ResultReceiver resultReceiver) {
53         return getInputMethodManager().hideSoftInputFromWindow(windowToken, flags, resultReceiver);
54     }
55 
56     /**
57      * @see android.view.inputmethod.InputMethodManager#updateSelection(View, int, int, int, int)
58      */
updateSelection(View view, int selStart, int selEnd, int candidatesStart, int candidatesEnd)59     public void updateSelection(View view, int selStart, int selEnd,
60             int candidatesStart, int candidatesEnd) {
61         getInputMethodManager().updateSelection(view, selStart, selEnd, candidatesStart,
62                 candidatesEnd);
63     }
64 
65     /**
66      * @see android.view.inputmethod.InputMethodManager#isWatchingCursor(View)
67      */
isWatchingCursor(View view)68     public boolean isWatchingCursor(View view) {
69         return getInputMethodManager().isWatchingCursor(view);
70     }
71 
72     /**
73      * @see android.view.inputmethod.InputMethodManager#updateCursor(View, int, int, int, int)
74      */
updateCursor(View view, int left, int top, int right, int bottom)75     public void updateCursor(View view, int left, int top, int right, int bottom) {
76         getInputMethodManager().updateCursor(view, left, top, right, bottom);
77     }
78 }
79