private void notifyTextChange() { final InputMethodManager imm = getInputMethodManager(); final View v = getView(); final Editable editable = getEditable(); if (imm == null || v == null || editable == null) { return; } mUpdateExtract.flags = 0; // Update the entire Editable range mUpdateExtract.partialStartOffset = -1; mUpdateExtract.partialEndOffset = -1; mUpdateExtract.selectionStart = Selection.getSelectionStart(editable); mUpdateExtract.selectionEnd = Selection.getSelectionEnd(editable); mUpdateExtract.startOffset = 0; if ((mUpdateRequest.flags & GET_TEXT_WITH_STYLES) != 0) { mUpdateExtract.text = new SpannableString(editable); } else { mUpdateExtract.text = editable.toString(); } imm.updateExtractedText(v, mUpdateRequest.token, mUpdateExtract); }
public void notifyTextChange( InputMethodManager imm, String text, int start, int oldEnd, int newEnd) { if (!mBatchMode) { if (!text.contentEquals(mEditable)) { if (DEBUG) Log.d( LOGTAG, String.format( ". . . notifyTextChange: current mEditable=\"%s\"", mEditable.toString())); setEditable(text); } } if (mUpdateRequest == null) return; View v = GeckoApp.mAppContext.getLayerController().getView(); if (imm == null) { imm = getInputMethodManager(); if (imm == null) return; } mUpdateExtract.flags = 0; // We update from (0, oldEnd) to (0, newEnd) because some Android IMEs // assume that updates start at zero, according to jchen. mUpdateExtract.partialStartOffset = 0; mUpdateExtract.partialEndOffset = oldEnd; // Faster to not query for selection mUpdateExtract.selectionStart = newEnd; mUpdateExtract.selectionEnd = newEnd; mUpdateExtract.text = text.substring(0, newEnd); mUpdateExtract.startOffset = 0; imm.updateExtractedText(v, mUpdateRequest.token, mUpdateExtract); }