FileDocCategorySizeDatePackage
ExtractEditText.javaAPI DocAndroid 5.1 API6629Thu Mar 12 22:22:10 GMT 2015android.inputmethodservice

ExtractEditText

public class ExtractEditText extends android.widget.EditText
Specialization of {@link EditText} for showing and interacting with the extracted text in a full-screen input method.

Fields Summary
private InputMethodService
mIME
private int
mSettingExtractedText
Constructors Summary
public ExtractEditText(android.content.Context context)

        super(context, null);
    
public ExtractEditText(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs, com.android.internal.R.attr.editTextStyle);
    
public ExtractEditText(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public ExtractEditText(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);
    
Methods Summary
protected voiddeleteText_internal(int start, int end)
{@inheritDoc}

hide

        // Do not call the super method.
        // This will change the source TextView instead, which will update the ExtractTextView.
        mIME.onExtractedDeleteText(start, end);
    
public voidfinishInternalChanges()
Finish making changes that will not be reported to the client. That is, {@link #onSelectionChanged(int, int)} will not result in sending the new selection to the client

        mSettingExtractedText -= 1;
    
public booleanhasFocus()
Pretend like this view always has focus, so its highlight and cursor will be displayed.

        return this.isEnabled();
    
public booleanhasVerticalScrollBar()
Return true if the edit text is currently showing a scroll bar.

        return computeVerticalScrollRange() > computeVerticalScrollExtent();
    
public booleanhasWindowFocus()
Pretend like the window this view is in always has focus, so its highlight and cursor will be displayed.

        return this.isEnabled();
    
public booleanisFocused()
Pretend like this view always has focus, so its highlight and cursor will be displayed.

        return this.isEnabled();
    
public booleanisInputMethodTarget()
We are always considered to be an input method target.

        return true;
    
protected voidonSelectionChanged(int selStart, int selEnd)
Report to the underlying text editor about selection changes.

        if (mSettingExtractedText == 0 && mIME != null && selStart >= 0 && selEnd >= 0) {
            mIME.onExtractedSelectionChanged(selStart, selEnd);
        }
    
public booleanonTextContextMenuItem(int id)

        if (mIME != null && mIME.onExtractTextContextMenuItem(id)) {
            // Mode was started on Extracted, needs to be stopped here.
            // Cut and paste will change the text, which stops selection mode.
            if (id == android.R.id.copy) stopSelectionActionMode();
            return true;
        }
        return super.onTextContextMenuItem(id);
    
public booleanperformClick()
Redirect clicks to the IME for handling there. First allows any on click handler to run, though.

        if (!super.performClick() && mIME != null) {
            mIME.onExtractedTextClicked();
            return true;
        }
        return false;
    
protected voidreplaceText_internal(int start, int end, java.lang.CharSequence text)
{@inheritDoc}

hide

        // Do not call the super method.
        // This will change the source TextView instead, which will update the ExtractTextView.
        mIME.onExtractedReplaceText(start, end, text);
    
protected voidsetCursorPosition_internal(int start, int end)
{@inheritDoc}

hide

        // Do not call the super method.
        // This will change the source TextView instead, which will update the ExtractTextView.
        mIME.onExtractedSelectionChanged(start, end);
    
public voidsetExtractedText(android.view.inputmethod.ExtractedText text)
Implement just to keep track of when we are setting text from the client (vs. seeing changes in ourself from the user).

        try {
            mSettingExtractedText++;
            super.setExtractedText(text);
        } finally {
            mSettingExtractedText--;
        }
    
voidsetIME(InputMethodService ime)

        mIME = ime;
    
protected voidsetSpan_internal(java.lang.Object span, int start, int end, int flags)
{@inheritDoc}

hide

        // Do not call the super method.
        // This will change the source TextView instead, which will update the ExtractTextView.
        mIME.onExtractedSetSpan(span, start, end, flags);
    
public voidstartInternalChanges()
Start making changes that will not be reported to the client. That is, {@link #onSelectionChanged(int, int)} will not result in sending the new selection to the client

        mSettingExtractedText += 1;
    
protected voidviewClicked(android.view.inputmethod.InputMethodManager imm)

hide

        // As an instance of this class is supposed to be owned by IMS,
        // and it has a reference to the IMS (the current IME),
        // we just need to call back its onViewClicked() here.
        // It should be good to avoid unnecessary IPCs by doing this as well.
        if (mIME != null) {
            mIME.onViewClicked(false);
        }