• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package android.view.inputmethod;
18 
19 import android.os.Bundle;
20 import android.view.KeyEvent;
21 
22 /**
23  * <p>Wrapper class for proxying calls to another InputConnection.  Subclass
24  * and have fun!
25  */
26 public class InputConnectionWrapper implements InputConnection {
27     private InputConnection mTarget;
28     final boolean mMutable;
29 
InputConnectionWrapper(InputConnection target, boolean mutable)30     public InputConnectionWrapper(InputConnection target, boolean mutable) {
31         mMutable = mutable;
32         mTarget = target;
33     }
34 
35     /**
36      * Change the target of the input connection.
37      */
setTarget(InputConnection target)38     public void setTarget(InputConnection target) {
39         if (mTarget != null && !mMutable) {
40             throw new SecurityException("not mutable");
41         }
42         mTarget = target;
43     }
44 
getTextBeforeCursor(int n, int flags)45     public CharSequence getTextBeforeCursor(int n, int flags) {
46         return mTarget.getTextBeforeCursor(n, flags);
47     }
48 
getTextAfterCursor(int n, int flags)49     public CharSequence getTextAfterCursor(int n, int flags) {
50         return mTarget.getTextAfterCursor(n, flags);
51     }
52 
getCursorCapsMode(int reqModes)53     public int getCursorCapsMode(int reqModes) {
54         return mTarget.getCursorCapsMode(reqModes);
55     }
56 
getExtractedText(ExtractedTextRequest request, int flags)57     public ExtractedText getExtractedText(ExtractedTextRequest request,
58             int flags) {
59         return mTarget.getExtractedText(request, flags);
60     }
61 
deleteSurroundingText(int leftLength, int rightLength)62     public boolean deleteSurroundingText(int leftLength, int rightLength) {
63         return mTarget.deleteSurroundingText(leftLength, rightLength);
64     }
65 
setComposingText(CharSequence text, int newCursorPosition)66     public boolean setComposingText(CharSequence text, int newCursorPosition) {
67         return mTarget.setComposingText(text, newCursorPosition);
68     }
69 
finishComposingText()70     public boolean finishComposingText() {
71         return mTarget.finishComposingText();
72     }
73 
commitText(CharSequence text, int newCursorPosition)74     public boolean commitText(CharSequence text, int newCursorPosition) {
75         return mTarget.commitText(text, newCursorPosition);
76     }
77 
commitCompletion(CompletionInfo text)78     public boolean commitCompletion(CompletionInfo text) {
79         return mTarget.commitCompletion(text);
80     }
81 
setSelection(int start, int end)82     public boolean setSelection(int start, int end) {
83         return mTarget.setSelection(start, end);
84     }
85 
performEditorAction(int editorAction)86     public boolean performEditorAction(int editorAction) {
87         return mTarget.performEditorAction(editorAction);
88     }
89 
performContextMenuAction(int id)90     public boolean performContextMenuAction(int id) {
91         return mTarget.performContextMenuAction(id);
92     }
93 
beginBatchEdit()94     public boolean beginBatchEdit() {
95         return mTarget.beginBatchEdit();
96     }
97 
endBatchEdit()98     public boolean endBatchEdit() {
99         return mTarget.endBatchEdit();
100     }
101 
sendKeyEvent(KeyEvent event)102     public boolean sendKeyEvent(KeyEvent event) {
103         return mTarget.sendKeyEvent(event);
104     }
105 
clearMetaKeyStates(int states)106     public boolean clearMetaKeyStates(int states) {
107         return mTarget.clearMetaKeyStates(states);
108     }
109 
reportFullscreenMode(boolean enabled)110     public boolean reportFullscreenMode(boolean enabled) {
111         return mTarget.reportFullscreenMode(enabled);
112     }
113 
performPrivateCommand(String action, Bundle data)114     public boolean performPrivateCommand(String action, Bundle data) {
115         return mTarget.performPrivateCommand(action, data);
116     }
117 }
118