Loading core/java/android/inputmethodservice/ExtractEditText.java +27 −6 Original line number Diff line number Diff line Loading @@ -158,25 +158,46 @@ public class ExtractEditText extends EditText { } /** * Delete the range of text, supposedly valid * {@inheritDoc} * @hide */ @Override protected void deleteText_internal(int start, int end) { // Do not call the super method. This will change the source TextView instead, which // will update the ExtractTextView. // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedDeleteText(start, end); } /** * Replaces the range of text [start, end[ by replacement text * {@inheritDoc} * @hide */ @Override protected void replaceText_internal(int start, int end, CharSequence text) { // Do not call the super method. This will change the source TextView instead, which // will update the ExtractTextView. // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedReplaceText(start, end, text); } /** * {@inheritDoc} * @hide */ @Override protected void setSpan_internal(Object span, int start, int end, int flags) { // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedSetSpan(span, start, end, flags); } /** * {@inheritDoc} * @hide */ @Override protected void setCursorPosition_internal(int start, int end) { // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedSelectionChanged(start, end); } } core/java/android/inputmethodservice/InputMethodService.java +16 −0 Original line number Diff line number Diff line Loading @@ -2005,6 +2005,22 @@ public class InputMethodService extends AbstractInputMethodService { } } /** * @hide */ public void onExtractedSetSpan(Object span, int start, int end, int flags) { InputConnection conn = getCurrentInputConnection(); if (conn != null) { if (!conn.setSelection(start, end)) return; CharSequence text = conn.getSelectedText(InputConnection.GET_TEXT_WITH_STYLES); if (text instanceof Spannable) { ((Spannable) text).setSpan(span, 0, text.length(), flags); conn.setComposingRegion(start, end); conn.commitText(text, 1); } } } /** * This is called when the user has clicked on the extracted text view, * when running in fullscreen mode. The default implementation hides Loading core/java/android/widget/TextView.java +21 −5 Original line number Diff line number Diff line Loading @@ -9829,7 +9829,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener highlightTextDifferences(mSuggestionInfos[i], spanUnionStart, spanUnionEnd); } // Add to dictionary item is there a span with the misspelled flag // Add to dictionary item if there is a span with the misspelled flag if (misspelledSpan != null) { final int misspelledStart = spannable.getSpanStart(misspelledSpan); final int misspelledEnd = spannable.getSpanEnd(misspelledSpan); Loading Loading @@ -9915,7 +9915,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int spanStart = editable.getSpanStart(suggestionInfo.suggestionSpan); final int spanEnd = editable.getSpanEnd(suggestionInfo.suggestionSpan); if (spanStart < 0 || spanEnd < 0) { if (spanStart < 0 || spanEnd <= spanStart) { // Span has been removed hide(); return; Loading Loading @@ -9983,14 +9983,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // way to assign them a valid range after replacement if (suggestionSpansStarts[i] <= spanStart && suggestionSpansEnds[i] >= spanEnd) { // TODO The ExtractEditText should restore these spans in the original text editable.setSpan(suggestionSpans[i], suggestionSpansStarts[i], setSpan_internal(suggestionSpans[i], suggestionSpansStarts[i], suggestionSpansEnds[i] + lengthDifference, suggestionSpansFlags[i]); } } // Move cursor at the end of the replaced word Selection.setSelection(editable, spanEnd + lengthDifference); final int newCursorPosition = spanEnd + lengthDifference; setCursorPosition_internal(newCursorPosition, newCursorPosition); } hide(); Loading Loading @@ -11463,6 +11463,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener ((Editable) mText).replace(start, end, text); } /** * Sets a span on the specified range of text * @hide */ protected void setSpan_internal(Object span, int start, int end, int flags) { ((Editable) mText).setSpan(span, start, end, flags); } /** * Moves the cursor to the specified offset position in text * @hide */ protected void setCursorPosition_internal(int start, int end) { Selection.setSelection(((Editable) mText), start, end); } @ViewDebug.ExportedProperty(category = "text") private CharSequence mText; private CharSequence mTransformed; Loading Loading
core/java/android/inputmethodservice/ExtractEditText.java +27 −6 Original line number Diff line number Diff line Loading @@ -158,25 +158,46 @@ public class ExtractEditText extends EditText { } /** * Delete the range of text, supposedly valid * {@inheritDoc} * @hide */ @Override protected void deleteText_internal(int start, int end) { // Do not call the super method. This will change the source TextView instead, which // will update the ExtractTextView. // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedDeleteText(start, end); } /** * Replaces the range of text [start, end[ by replacement text * {@inheritDoc} * @hide */ @Override protected void replaceText_internal(int start, int end, CharSequence text) { // Do not call the super method. This will change the source TextView instead, which // will update the ExtractTextView. // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedReplaceText(start, end, text); } /** * {@inheritDoc} * @hide */ @Override protected void setSpan_internal(Object span, int start, int end, int flags) { // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedSetSpan(span, start, end, flags); } /** * {@inheritDoc} * @hide */ @Override protected void setCursorPosition_internal(int start, int end) { // Do not call the super method. // This will change the source TextView instead, which will update the ExtractTextView. mIME.onExtractedSelectionChanged(start, end); } }
core/java/android/inputmethodservice/InputMethodService.java +16 −0 Original line number Diff line number Diff line Loading @@ -2005,6 +2005,22 @@ public class InputMethodService extends AbstractInputMethodService { } } /** * @hide */ public void onExtractedSetSpan(Object span, int start, int end, int flags) { InputConnection conn = getCurrentInputConnection(); if (conn != null) { if (!conn.setSelection(start, end)) return; CharSequence text = conn.getSelectedText(InputConnection.GET_TEXT_WITH_STYLES); if (text instanceof Spannable) { ((Spannable) text).setSpan(span, 0, text.length(), flags); conn.setComposingRegion(start, end); conn.commitText(text, 1); } } } /** * This is called when the user has clicked on the extracted text view, * when running in fullscreen mode. The default implementation hides Loading
core/java/android/widget/TextView.java +21 −5 Original line number Diff line number Diff line Loading @@ -9829,7 +9829,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener highlightTextDifferences(mSuggestionInfos[i], spanUnionStart, spanUnionEnd); } // Add to dictionary item is there a span with the misspelled flag // Add to dictionary item if there is a span with the misspelled flag if (misspelledSpan != null) { final int misspelledStart = spannable.getSpanStart(misspelledSpan); final int misspelledEnd = spannable.getSpanEnd(misspelledSpan); Loading Loading @@ -9915,7 +9915,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int spanStart = editable.getSpanStart(suggestionInfo.suggestionSpan); final int spanEnd = editable.getSpanEnd(suggestionInfo.suggestionSpan); if (spanStart < 0 || spanEnd < 0) { if (spanStart < 0 || spanEnd <= spanStart) { // Span has been removed hide(); return; Loading Loading @@ -9983,14 +9983,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // way to assign them a valid range after replacement if (suggestionSpansStarts[i] <= spanStart && suggestionSpansEnds[i] >= spanEnd) { // TODO The ExtractEditText should restore these spans in the original text editable.setSpan(suggestionSpans[i], suggestionSpansStarts[i], setSpan_internal(suggestionSpans[i], suggestionSpansStarts[i], suggestionSpansEnds[i] + lengthDifference, suggestionSpansFlags[i]); } } // Move cursor at the end of the replaced word Selection.setSelection(editable, spanEnd + lengthDifference); final int newCursorPosition = spanEnd + lengthDifference; setCursorPosition_internal(newCursorPosition, newCursorPosition); } hide(); Loading Loading @@ -11463,6 +11463,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener ((Editable) mText).replace(start, end, text); } /** * Sets a span on the specified range of text * @hide */ protected void setSpan_internal(Object span, int start, int end, int flags) { ((Editable) mText).setSpan(span, start, end, flags); } /** * Moves the cursor to the specified offset position in text * @hide */ protected void setCursorPosition_internal(int start, int end) { Selection.setSelection(((Editable) mText), start, end); } @ViewDebug.ExportedProperty(category = "text") private CharSequence mText; private CharSequence mTransformed; Loading