3

I struggle with android EditText for days, try to get rid of the "paste" popup when select text. (my extend EditText is readonly and selectable).

from the anwser to the question : EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event

override the package-private method canPaste() is ok for dalvik runtime, but will not work with the android 5.0 above using ART.

So I find other way to solve the problem, not overide the method, but try replace Editor's field variable

I look the EditText's helper class Editor got a lot specific logic, looks if I can replace InsertionPointCursorController in a proper time by a dummy subclass, it will not show the popup. (InsertionPointCursorController is a private class, it implement a private interface, so to replace it with a dummy subclass, I need to extend the class or implement the interface)

public boolean performLongClick(boolean handled) {
    // Long press in empty space moves cursor and shows the Paste affordance if available.
    if (!handled && !isPositionOnText(mLastDownPositionX, mLastDownPositionY) &&
            mInsertionControllerEnabled) {
        final int offset = mTextView.getOffsetForPosition(mLastDownPositionX,
                mLastDownPositionY);
        stopSelectionActionMode();
        Selection.setSelection((Spannable) mTextView.getText(), offset);
        getInsertionController().showWithActionPopup();
        handled = true;
    }

looks the getInsertionController().showWithActionPopup(); show the popup :(

Now I'll go to try replace remove callback for an anternative

Community
  • 1
  • 1
Gohan
  • 2,422
  • 2
  • 26
  • 45

1 Answers1

0

You can't extend outer private class (default in the same package and protected in other package can) and interface.

Extend your parent class you need to alter and the override the methods you need to use, but again you can't override private methods. You can recode them (pretty "overloading").

Yuri Blanc
  • 636
  • 10
  • 24