| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.inputmethod; |
| 18 |
|
| 19 |
import android.annotation.IntRange; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.os.Bundle; |
| 23 |
import android.os.Handler; |
| 24 |
import android.view.KeyEvent; |
| 25 |
|
| 26 |
import com.android.internal.util.Preconditions; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class InputConnectionWrapper implements InputConnection { |
| 32 |
private InputConnection mTarget; |
| 33 |
final boolean mMutable; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public InputConnectionWrapper(InputConnection target, boolean mutable) { |
| 46 |
mMutable = mutable; |
| 47 |
mTarget = target; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public void setTarget(InputConnection target) { |
| 60 |
if (mTarget != null && !mMutable) { |
| 61 |
throw new SecurityException("not mutable"); |
| 62 |
} |
| 63 |
mTarget = target; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
@Nullable |
| 72 |
@Override |
| 73 |
public CharSequence getTextBeforeCursor(@IntRange(from = 0) int n, int flags) { |
| 74 |
Preconditions.checkArgumentNonnegative(n); |
| 75 |
return mTarget.getTextBeforeCursor(n, flags); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
@Nullable |
| 84 |
@Override |
| 85 |
public CharSequence getTextAfterCursor(@IntRange(from = 0) int n, int flags) { |
| 86 |
Preconditions.checkArgumentNonnegative(n); |
| 87 |
return mTarget.getTextAfterCursor(n, flags); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
@Override |
| 95 |
public CharSequence getSelectedText(int flags) { |
| 96 |
return mTarget.getSelectedText(flags); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
@Nullable |
| 105 |
@Override |
| 106 |
public SurroundingText getSurroundingText(int beforeLength, int afterLength, int flags) { |
| 107 |
Preconditions.checkArgumentNonnegative(beforeLength); |
| 108 |
Preconditions.checkArgumentNonnegative(afterLength); |
| 109 |
return mTarget.getSurroundingText(beforeLength, afterLength, flags); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
@Override |
| 117 |
public int getCursorCapsMode(int reqModes) { |
| 118 |
return mTarget.getCursorCapsMode(reqModes); |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
@Override |
| 126 |
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) { |
| 127 |
return mTarget.getExtractedText(request, flags); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
@Override |
| 135 |
public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { |
| 136 |
return mTarget.deleteSurroundingTextInCodePoints(beforeLength, afterLength); |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
@Override |
| 144 |
public boolean deleteSurroundingText(int beforeLength, int afterLength) { |
| 145 |
return mTarget.deleteSurroundingText(beforeLength, afterLength); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
@Override |
| 153 |
public boolean setComposingText(CharSequence text, int newCursorPosition) { |
| 154 |
return mTarget.setComposingText(text, newCursorPosition); |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
@Override |
| 162 |
public boolean setComposingText(@NonNull CharSequence text, |
| 163 |
int newCursorPosition, @Nullable TextAttribute textAttribute) { |
| 164 |
return mTarget.setComposingText(text, newCursorPosition, textAttribute); |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
@Override |
| 172 |
public boolean setComposingRegion(int start, int end) { |
| 173 |
return mTarget.setComposingRegion(start, end); |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
@Override |
| 181 |
public boolean setComposingRegion(int start, int end, @Nullable TextAttribute textAttribute) { |
| 182 |
return mTarget.setComposingRegion(start, end, textAttribute); |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
@Override |
| 190 |
public boolean finishComposingText() { |
| 191 |
return mTarget.finishComposingText(); |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
@Override |
| 199 |
public boolean commitText(CharSequence text, int newCursorPosition) { |
| 200 |
return mTarget.commitText(text, newCursorPosition); |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
@Override |
| 208 |
public boolean commitText(@NonNull CharSequence text, int newCursorPosition, |
| 209 |
@Nullable TextAttribute textAttribute) { |
| 210 |
return mTarget.commitText(text, newCursorPosition, textAttribute); |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
@Override |
| 218 |
public boolean commitCompletion(CompletionInfo text) { |
| 219 |
return mTarget.commitCompletion(text); |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
@Override |
| 227 |
public boolean commitCorrection(CorrectionInfo correctionInfo) { |
| 228 |
return mTarget.commitCorrection(correctionInfo); |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
@Override |
| 236 |
public boolean setSelection(int start, int end) { |
| 237 |
return mTarget.setSelection(start, end); |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
@Override |
| 245 |
public boolean performEditorAction(int editorAction) { |
| 246 |
return mTarget.performEditorAction(editorAction); |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
@Override |
| 254 |
public boolean performContextMenuAction(int id) { |
| 255 |
return mTarget.performContextMenuAction(id); |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
@Override |
| 263 |
public boolean beginBatchEdit() { |
| 264 |
return mTarget.beginBatchEdit(); |
| 265 |
} |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
@Override |
| 272 |
public boolean endBatchEdit() { |
| 273 |
return mTarget.endBatchEdit(); |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
@Override |
| 281 |
public boolean sendKeyEvent(KeyEvent event) { |
| 282 |
return mTarget.sendKeyEvent(event); |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
@Override |
| 290 |
public boolean clearMetaKeyStates(int states) { |
| 291 |
return mTarget.clearMetaKeyStates(states); |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
@Override |
| 299 |
public boolean reportFullscreenMode(boolean enabled) { |
| 300 |
return mTarget.reportFullscreenMode(enabled); |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
@Override |
| 308 |
public boolean performSpellCheck() { |
| 309 |
return mTarget.performSpellCheck(); |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
@Override |
| 317 |
public boolean performPrivateCommand(String action, Bundle data) { |
| 318 |
return mTarget.performPrivateCommand(action, data); |
| 319 |
} |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
@Override |
| 326 |
public boolean requestCursorUpdates(int cursorUpdateMode) { |
| 327 |
return mTarget.requestCursorUpdates(cursorUpdateMode); |
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
@Override |
| 335 |
public Handler getHandler() { |
| 336 |
return mTarget.getHandler(); |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
@Override |
| 344 |
public void closeConnection() { |
| 345 |
mTarget.closeConnection(); |
| 346 |
} |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
@Override |
| 353 |
public boolean commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts) { |
| 354 |
return mTarget.commitContent(inputContentInfo, flags, opts); |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
@Override |
| 362 |
public boolean setImeConsumesInput(boolean imeConsumesInput) { |
| 363 |
return mTarget.setImeConsumesInput(imeConsumesInput); |
| 364 |
} |
| 365 |
} |