InputMethodManagerWrapper.java revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
1// Copyright (c) 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
5package org.chromium.content.browser.input;
6
7import android.content.Context;
8import android.os.IBinder;
9import android.os.ResultReceiver;
10import android.view.View;
11import android.view.inputmethod.InputMethodManager;
12
13/**
14 * Wrapper around Android's InputMethodManager
15 */
16public class InputMethodManagerWrapper {
17    private final Context mContext;
18
19    public InputMethodManagerWrapper(Context context) {
20        mContext = context;
21    }
22
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     */
30    public void restartInput(View view) {
31        getInputMethodManager().restartInput(view);
32    }
33
34    /**
35     * @see android.view.inputmethod.InputMethodManager#showSoftInput(View, int, ResultReceiver)
36     */
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     */
44    public boolean isActive(View view) {
45        return getInputMethodManager().isActive(view);
46    }
47
48    /**
49     * @see InputMethodManager#hideSoftInputFromWindow(IBinder, int, ResultReceiver)
50     */
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     */
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