InputConnectionWrapper.java revision cf9cf2f40efc4ccf3f73e6fdb07725d9c00c4f91
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.view.KeyEvent; 21 22/** 23 * <p>Wrapper class for proxying calls to another InputConnection. Subclass 24 * and have fun! 25 */ 26public class InputConnectionWrapper implements InputConnection { 27 private InputConnection mTarget; 28 final boolean mMutable; 29 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 */ 38 public void setTarget(InputConnection target) { 39 if (mTarget != null && !mMutable) { 40 throw new SecurityException("not mutable"); 41 } 42 mTarget = target; 43 } 44 45 public CharSequence getTextBeforeCursor(int n, int flags) { 46 return mTarget.getTextBeforeCursor(n, flags); 47 } 48 49 public CharSequence getTextAfterCursor(int n, int flags) { 50 return mTarget.getTextAfterCursor(n, flags); 51 } 52 53 public CharSequence getSelectedText(int flags) { 54 return mTarget.getSelectedText(flags); 55 } 56 57 public int getCursorCapsMode(int reqModes) { 58 return mTarget.getCursorCapsMode(reqModes); 59 } 60 61 public ExtractedText getExtractedText(ExtractedTextRequest request, 62 int flags) { 63 return mTarget.getExtractedText(request, flags); 64 } 65 66 public boolean deleteSurroundingText(int leftLength, int rightLength) { 67 return mTarget.deleteSurroundingText(leftLength, rightLength); 68 } 69 70 public boolean setComposingText(CharSequence text, int newCursorPosition) { 71 return mTarget.setComposingText(text, newCursorPosition); 72 } 73 74 public boolean setComposingRegion(int start, int end) { 75 return mTarget.setComposingRegion(start, end); 76 } 77 78 public boolean finishComposingText() { 79 return mTarget.finishComposingText(); 80 } 81 82 public boolean commitText(CharSequence text, int newCursorPosition) { 83 return mTarget.commitText(text, newCursorPosition); 84 } 85 86 public boolean commitCompletion(CompletionInfo text) { 87 return mTarget.commitCompletion(text); 88 } 89 90 public boolean commitCorrection(CorrectionInfo correctionInfo) { 91 return mTarget.commitCorrection(correctionInfo); 92 } 93 94 public boolean setSelection(int start, int end) { 95 return mTarget.setSelection(start, end); 96 } 97 98 public boolean performEditorAction(int editorAction) { 99 return mTarget.performEditorAction(editorAction); 100 } 101 102 public boolean performContextMenuAction(int id) { 103 return mTarget.performContextMenuAction(id); 104 } 105 106 public boolean beginBatchEdit() { 107 return mTarget.beginBatchEdit(); 108 } 109 110 public boolean endBatchEdit() { 111 return mTarget.endBatchEdit(); 112 } 113 114 public boolean sendKeyEvent(KeyEvent event) { 115 return mTarget.sendKeyEvent(event); 116 } 117 118 public boolean clearMetaKeyStates(int states) { 119 return mTarget.clearMetaKeyStates(states); 120 } 121 122 public boolean reportFullscreenMode(boolean enabled) { 123 return mTarget.reportFullscreenMode(enabled); 124 } 125 126 public boolean performPrivateCommand(String action, Bundle data) { 127 return mTarget.performPrivateCommand(action, data); 128 } 129} 130