Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
io.flutter.plugin.editing.InputConnectionAdaptor Class Reference
Inheritance diagram for io.flutter.plugin.editing.InputConnectionAdaptor:
io.flutter.plugin.editing.ListenableEditingState.EditingStateWatcher

Classes

interface  KeyboardDelegate
 

Public Member Functions

 InputConnectionAdaptor (View view, int client, TextInputChannel textInputChannel, KeyboardDelegate keyboardDelegate, ListenableEditingState editable, EditorInfo editorInfo, FlutterJNI flutterJNI)
 
 InputConnectionAdaptor (View view, int client, TextInputChannel textInputChannel, KeyboardDelegate keyboardDelegate, ListenableEditingState editable, EditorInfo editorInfo)
 
Editable getEditable ()
 
boolean beginBatchEdit ()
 
boolean endBatchEdit ()
 
boolean commitText (CharSequence text, int newCursorPosition)
 
boolean deleteSurroundingText (int beforeLength, int afterLength)
 
boolean deleteSurroundingTextInCodePoints (int beforeLength, int afterLength)
 
boolean setComposingRegion (int start, int end)
 
boolean setComposingText (CharSequence text, int newCursorPosition)
 
boolean finishComposingText ()
 
ExtractedText getExtractedText (ExtractedTextRequest request, int flags)
 
boolean requestCursorUpdates (int cursorUpdateMode)
 
boolean clearMetaKeyStates (int states)
 
void closeConnection ()
 
boolean setSelection (int start, int end)
 
boolean sendKeyEvent (KeyEvent event)
 
boolean handleKeyEvent (KeyEvent event)
 
boolean performContextMenuAction (int id)
 
boolean performPrivateCommand (String action, Bundle data)
 
boolean performEditorAction (int actionCode)
 
boolean commitContent (InputContentInfo inputContentInfo, int flags, Bundle opts)
 
void didChangeEditingState (boolean textChanged, boolean selectionChanged, boolean composingRegionChanged)
 

Detailed Description

Definition at line 44 of file InputConnectionAdaptor.java.

Constructor & Destructor Documentation

◆ InputConnectionAdaptor() [1/2]

io.flutter.plugin.editing.InputConnectionAdaptor.InputConnectionAdaptor ( View  view,
int  client,
TextInputChannel  textInputChannel,
KeyboardDelegate  keyboardDelegate,
ListenableEditingState  editable,
EditorInfo  editorInfo,
FlutterJNI  flutterJNI 
)
inline

Definition at line 68 of file InputConnectionAdaptor.java.

75 {
76 super(view, true);
77 mFlutterView = view;
78 mClient = client;
79 this.textInputChannel = textInputChannel;
80 mEditable = editable;
81 mEditable.addEditingStateListener(this);
82 mEditorInfo = editorInfo;
83 this.keyboardDelegate = keyboardDelegate;
84 this.flutterTextUtils = new FlutterTextUtils(flutterJNI);
85 // We create a dummy Layout with max width so that the selection
86 // shifting acts as if all text were in one line.
87 mLayout =
88 new DynamicLayout(
89 mEditable,
90 new TextPaint(),
91 Integer.MAX_VALUE,
92 Layout.Alignment.ALIGN_NORMAL,
93 1.0f,
94 0.0f,
95 false);
96 mImm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
97 }
void addEditingStateListener(EditingStateWatcher listener)

◆ InputConnectionAdaptor() [2/2]

io.flutter.plugin.editing.InputConnectionAdaptor.InputConnectionAdaptor ( View  view,
int  client,
TextInputChannel  textInputChannel,
KeyboardDelegate  keyboardDelegate,
ListenableEditingState  editable,
EditorInfo  editorInfo 
)
inline

Definition at line 99 of file InputConnectionAdaptor.java.

105 {
106 this(view, client, textInputChannel, keyboardDelegate, editable, editorInfo, new FlutterJNI());
107 }

Member Function Documentation

◆ beginBatchEdit()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.beginBatchEdit ( )
inline

Definition at line 148 of file InputConnectionAdaptor.java.

148 {
149 mEditable.beginBatchEdit();
150 batchEditNestDepth += 1;
151 return super.beginBatchEdit();
152 }

◆ clearMetaKeyStates()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.clearMetaKeyStates ( int  states)
inline

Definition at line 243 of file InputConnectionAdaptor.java.

243 {
244 boolean result = super.clearMetaKeyStates(states);
245 return result;
246 }
GAsyncResult * result

◆ closeConnection()

void io.flutter.plugin.editing.InputConnectionAdaptor.closeConnection ( )
inline

Definition at line 249 of file InputConnectionAdaptor.java.

249 {
250 super.closeConnection();
251 mEditable.removeEditingStateListener(this);
252 for (; batchEditNestDepth > 0; batchEditNestDepth--) {
253 endBatchEdit();
254 }
255 }
void removeEditingStateListener(EditingStateWatcher listener)

◆ commitContent()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.commitContent ( InputContentInfo  inputContentInfo,
int  flags,
Bundle  opts 
)
inline

Definition at line 483 of file InputConnectionAdaptor.java.

483 {
484 // Ensure permission is granted.
485 if (Build.VERSION.SDK_INT >= API_LEVELS.API_25
486 && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
487 try {
488 inputContentInfo.requestPermission();
489 } catch (Exception e) {
490 return false;
491 }
492 } else {
493 return false;
494 }
495
496 if (inputContentInfo.getDescription().getMimeTypeCount() > 0) {
497 inputContentInfo.requestPermission();
498
499 final Uri uri = inputContentInfo.getContentUri();
500 final String mimeType = inputContentInfo.getDescription().getMimeType(0);
501 Context context = mFlutterView.getContext();
502
503 if (uri != null) {
504 InputStream is;
505 try {
506 // Extract byte data from the given URI.
507 is = context.getContentResolver().openInputStream(uri);
508 } catch (FileNotFoundException ex) {
509 inputContentInfo.releasePermission();
510 return false;
511 }
512
513 if (is != null) {
514 final byte[] data = this.readStreamFully(is, 64 * 1024);
515
516 final Map<String, Object> obj = new HashMap<>();
517 obj.put("mimeType", mimeType);
518 obj.put("data", data);
519 obj.put("uri", uri.toString());
520
521 // Commit the content to the text input channel and release the permission.
522 textInputChannel.commitContent(mClient, obj);
523 inputContentInfo.releasePermission();
524 return true;
525 }
526 }
527
528 inputContentInfo.releasePermission();
529 }
530 return false;
531 }
FlutterSemanticsFlag flags
Build(configs, env, options)
Definition build.py:232
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ commitText()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.commitText ( CharSequence  text,
int  newCursorPosition 
)
inline

Definition at line 163 of file InputConnectionAdaptor.java.

163 {
164 final boolean result = super.commitText(text, newCursorPosition);
165 return result;
166 }

◆ deleteSurroundingText()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.deleteSurroundingText ( int  beforeLength,
int  afterLength 
)
inline

Definition at line 169 of file InputConnectionAdaptor.java.

169 {
170 if (mEditable.getSelectionStart() == -1) {
171 return true;
172 }
173
174 final boolean result = super.deleteSurroundingText(beforeLength, afterLength);
175 return result;
176 }

◆ deleteSurroundingTextInCodePoints()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.deleteSurroundingTextInCodePoints ( int  beforeLength,
int  afterLength 
)
inline

Definition at line 179 of file InputConnectionAdaptor.java.

179 {
180 boolean result = super.deleteSurroundingTextInCodePoints(beforeLength, afterLength);
181 return result;
182 }

◆ didChangeEditingState()

void io.flutter.plugin.editing.InputConnectionAdaptor.didChangeEditingState ( boolean  textChanged,
boolean  selectionChanged,
boolean  composingRegionChanged 
)
inline

Implements io.flutter.plugin.editing.ListenableEditingState.EditingStateWatcher.

Definition at line 551 of file InputConnectionAdaptor.java.

552 {
553 // This method notifies the input method that the editing state has changed.
554 // updateSelection is mandatory. updateExtractedText and updateCursorAnchorInfo
555 // are on demand (if the input method set the correspoinding monitoring
556 // flags). See getExtractedText and requestCursorUpdates.
557
558 // Always send selection update. InputMethodManager#updateSelection skips
559 // sending the message if none of the parameters have changed since the last
560 // time we called it.
561 mImm.updateSelection(
562 mFlutterView,
563 mEditable.getSelectionStart(),
564 mEditable.getSelectionEnd(),
565 mEditable.getComposingStart(),
566 mEditable.getComposingEnd());
567
568 if (mExtractRequest != null) {
569 mImm.updateExtractedText(
570 mFlutterView, mExtractRequest.token, getExtractedText(mExtractRequest));
571 }
572 if (mMonitorCursorUpdate) {
573 final CursorAnchorInfo info = getCursorAnchorInfo();
574 mImm.updateCursorAnchorInfo(mFlutterView, info);
575 }
576 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213

◆ endBatchEdit()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.endBatchEdit ( )
inline

Definition at line 155 of file InputConnectionAdaptor.java.

155 {
156 boolean result = super.endBatchEdit();
157 batchEditNestDepth -= 1;
158 mEditable.endBatchEdit();
159 return result;
160 }

◆ finishComposingText()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.finishComposingText ( )
inline

Definition at line 204 of file InputConnectionAdaptor.java.

204 {
205 final boolean result = super.finishComposingText();
206 return result;
207 }

◆ getEditable()

Editable io.flutter.plugin.editing.InputConnectionAdaptor.getEditable ( )
inline

Definition at line 143 of file InputConnectionAdaptor.java.

143 {
144 return mEditable;
145 }

◆ getExtractedText()

ExtractedText io.flutter.plugin.editing.InputConnectionAdaptor.getExtractedText ( ExtractedTextRequest  request,
int  flags 
)
inline

Definition at line 215 of file InputConnectionAdaptor.java.

215 {
216 final boolean textMonitor = (flags & GET_EXTRACTED_TEXT_MONITOR) != 0;
217 if (textMonitor == (mExtractRequest == null)) {
218 Log.d(TAG, "The input method toggled text monitoring " + (textMonitor ? "on" : "off"));
219 }
220 // Enables text monitoring if the relevant flag is set. See
221 // InputConnectionAdaptor#didChangeEditingState.
222 mExtractRequest = textMonitor ? request : null;
223 return getExtractedText(request);
224 }
void Log(const char *format,...) SK_PRINTF_LIKE(1

◆ handleKeyEvent()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.handleKeyEvent ( KeyEvent  event)
inline

Definition at line 289 of file InputConnectionAdaptor.java.

289 {
290 if (event.getAction() == KeyEvent.ACTION_DOWN) {
291 if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
292 return handleHorizontalMovement(true, event.isShiftPressed());
293 } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) {
294 return handleHorizontalMovement(false, event.isShiftPressed());
295 } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP) {
296 return handleVerticalMovement(true, event.isShiftPressed());
297 } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN) {
298 return handleVerticalMovement(false, event.isShiftPressed());
299 // When the enter key is pressed on a non-multiline field, consider it a
300 // submit instead of a newline.
301 } else if ((event.getKeyCode() == KeyEvent.KEYCODE_ENTER
302 || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER)
303 && (InputType.TYPE_TEXT_FLAG_MULTI_LINE & mEditorInfo.inputType) == 0) {
304 performEditorAction(mEditorInfo.imeOptions & EditorInfo.IME_MASK_ACTION);
305 return true;
306 } else {
307 // Enter a character.
308 final int selStart = Selection.getSelectionStart(mEditable);
309 final int selEnd = Selection.getSelectionEnd(mEditable);
310 final int character = event.getUnicodeChar();
311 if (selStart < 0 || selEnd < 0 || character == 0) {
312 return false;
313 }
314
315 final int selMin = Math.min(selStart, selEnd);
316 final int selMax = Math.max(selStart, selEnd);
318 if (selMin != selMax) mEditable.delete(selMin, selMax);
319 mEditable.insert(selMin, String.valueOf((char) character));
320 setSelection(selMin + 1, selMin + 1);
321 endBatchEdit();
322 return true;
323 }
324 }
325 return false;
326 }
FlKeyEvent * event

◆ performContextMenuAction()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.performContextMenuAction ( int  id)
inline

Definition at line 383 of file InputConnectionAdaptor.java.

383 {
385 final boolean result = doPerformContextMenuAction(id);
386 endBatchEdit();
387 return result;
388 }

◆ performEditorAction()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.performEditorAction ( int  actionCode)
inline

Definition at line 449 of file InputConnectionAdaptor.java.

449 {
450 switch (actionCode) {
451 case EditorInfo.IME_ACTION_NONE:
452 textInputChannel.newline(mClient);
453 break;
454 case EditorInfo.IME_ACTION_UNSPECIFIED:
455 textInputChannel.unspecifiedAction(mClient);
456 break;
457 case EditorInfo.IME_ACTION_GO:
458 textInputChannel.go(mClient);
459 break;
460 case EditorInfo.IME_ACTION_SEARCH:
461 textInputChannel.search(mClient);
462 break;
463 case EditorInfo.IME_ACTION_SEND:
464 textInputChannel.send(mClient);
465 break;
466 case EditorInfo.IME_ACTION_NEXT:
467 textInputChannel.next(mClient);
468 break;
469 case EditorInfo.IME_ACTION_PREVIOUS:
470 textInputChannel.previous(mClient);
471 break;
472 default:
473 case EditorInfo.IME_ACTION_DONE:
474 textInputChannel.done(mClient);
475 break;
476 }
477 return true;
478 }

◆ performPrivateCommand()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.performPrivateCommand ( String  action,
Bundle  data 
)
inline

Definition at line 443 of file InputConnectionAdaptor.java.

443 {
444 textInputChannel.performPrivateCommand(mClient, action, data);
445 return true;
446 }

◆ requestCursorUpdates()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.requestCursorUpdates ( int  cursorUpdateMode)
inline

Definition at line 227 of file InputConnectionAdaptor.java.

227 {
228 if ((cursorUpdateMode & CURSOR_UPDATE_IMMEDIATE) != 0) {
229 mImm.updateCursorAnchorInfo(mFlutterView, getCursorAnchorInfo());
230 }
231
232 final boolean updated = (cursorUpdateMode & CURSOR_UPDATE_MONITOR) != 0;
233 if (updated != mMonitorCursorUpdate) {
234 Log.d(TAG, "The input method toggled cursor monitoring " + (updated ? "on" : "off"));
235 }
236
237 // Enables cursor monitoring. See InputConnectionAdaptor#didChangeEditingState.
238 mMonitorCursorUpdate = updated;
239 return true;
240 }

◆ sendKeyEvent()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.sendKeyEvent ( KeyEvent  event)
inline

Definition at line 285 of file InputConnectionAdaptor.java.

285 {
286 return keyboardDelegate.handleEvent(event);
287 }

◆ setComposingRegion()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.setComposingRegion ( int  start,
int  end 
)
inline

Definition at line 185 of file InputConnectionAdaptor.java.

185 {
186 final boolean result = super.setComposingRegion(start, end);
187 return result;
188 }
glong glong end

◆ setComposingText()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.setComposingText ( CharSequence  text,
int  newCursorPosition 
)
inline

Definition at line 191 of file InputConnectionAdaptor.java.

191 {
192 boolean result;
194 if (text.length() == 0) {
195 result = super.commitText(text, newCursorPosition);
196 } else {
197 result = super.setComposingText(text, newCursorPosition);
198 }
199 endBatchEdit();
200 return result;
201 }
std::u16string text

◆ setSelection()

boolean io.flutter.plugin.editing.InputConnectionAdaptor.setSelection ( int  start,
int  end 
)
inline

Definition at line 258 of file InputConnectionAdaptor.java.

258 {
260 boolean result = super.setSelection(start, end);
261 endBatchEdit();
262 return result;
263 }

The documentation for this class was generated from the following file: