InputConnectionWrapper.java revision 612cce92ad96eda1146c3abd2afa7aaa4d4f2b3f
1/*
2 * Copyright (C) 2007-2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17package android.view.inputmethod;
18
19import android.os.Bundle;
20import android.os.Handler;
21import android.view.KeyEvent;
22
23/**
24 * <p>Wrapper class for proxying calls to another InputConnection.  Subclass
25 * and have fun!
26 */
27public class InputConnectionWrapper implements InputConnection {
28    private InputConnection mTarget;
29    final boolean mMutable;
30
31    public InputConnectionWrapper(InputConnection target, boolean mutable) {
32        mMutable = mutable;
33        mTarget = target;
34    }
35
36    /**
37     * Change the target of the input connection.
38     */
39    public void setTarget(InputConnection target) {
40        if (mTarget != null && !mMutable) {
41            throw new SecurityException("not mutable");
42        }
43        mTarget = target;
44    }
45
46    public CharSequence getTextBeforeCursor(int n, int flags) {
47        return mTarget.getTextBeforeCursor(n, flags);
48    }
49
50    public CharSequence getTextAfterCursor(int n, int flags) {
51        return mTarget.getTextAfterCursor(n, flags);
52    }
53
54    public CharSequence getSelectedText(int flags) {
55        return mTarget.getSelectedText(flags);
56    }
57
58    public int getCursorCapsMode(int reqModes) {
59        return mTarget.getCursorCapsMode(reqModes);
60    }
61
62    public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
63        return mTarget.getExtractedText(request, flags);
64    }
65
66    public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) {
67        return mTarget.deleteSurroundingTextInCodePoints(beforeLength, afterLength);
68    }
69
70    public boolean deleteSurroundingText(int beforeLength, int afterLength) {
71        return mTarget.deleteSurroundingText(beforeLength, afterLength);
72    }
73
74    public boolean setComposingText(CharSequence text, int newCursorPosition) {
75        return mTarget.setComposingText(text, newCursorPosition);
76    }
77
78    public boolean setComposingRegion(int start, int end) {
79        return mTarget.setComposingRegion(start, end);
80    }
81
82    public boolean finishComposingText() {
83        return mTarget.finishComposingText();
84    }
85
86    public boolean commitText(CharSequence text, int newCursorPosition) {
87        return mTarget.commitText(text, newCursorPosition);
88    }
89
90    public boolean commitCompletion(CompletionInfo text) {
91        return mTarget.commitCompletion(text);
92    }
93
94    public boolean commitCorrection(CorrectionInfo correctionInfo) {
95        return mTarget.commitCorrection(correctionInfo);
96    }
97
98    public boolean setSelection(int start, int end) {
99        return mTarget.setSelection(start, end);
100    }
101
102    public boolean performEditorAction(int editorAction) {
103        return mTarget.performEditorAction(editorAction);
104    }
105
106    public boolean performContextMenuAction(int id) {
107        return mTarget.performContextMenuAction(id);
108    }
109
110    public boolean beginBatchEdit() {
111        return mTarget.beginBatchEdit();
112    }
113
114    public boolean endBatchEdit() {
115        return mTarget.endBatchEdit();
116    }
117
118    public boolean sendKeyEvent(KeyEvent event) {
119        return mTarget.sendKeyEvent(event);
120    }
121
122    public boolean clearMetaKeyStates(int states) {
123        return mTarget.clearMetaKeyStates(states);
124    }
125
126    public boolean reportFullscreenMode(boolean enabled) {
127        return mTarget.reportFullscreenMode(enabled);
128    }
129
130    public boolean performPrivateCommand(String action, Bundle data) {
131        return mTarget.performPrivateCommand(action, data);
132    }
133
134    public boolean requestCursorUpdates(int cursorUpdateMode) {
135        return mTarget.requestCursorUpdates(cursorUpdateMode);
136    }
137
138    public Handler getHandler() {
139        return mTarget.getHandler();
140    }
141}
142