Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d73e1e35 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by android-build-merger
Browse files

Merge "Invalidate HandleView when handle position may have to be changed." into nyc-dev

am: 03f1e026

* commit '03f1e026':
  Invalidate HandleView when handle position may have to be changed.

Change-Id: Ida7d9b65486177b28071c6ab7ca09d8085c4ed59
parents 444c9865 03f1e026
Loading
Loading
Loading
Loading
+44 −8
Original line number Diff line number Diff line
@@ -1778,6 +1778,18 @@ public class Editor {
        if (translate) canvas.translate(0, -cursorOffsetVertical);
    }

    void invalidateHandlesAndActionMode() {
        if (mSelectionModifierCursorController != null) {
            mSelectionModifierCursorController.invalidateHandles();
        }
        if (mInsertionPointCursorController != null) {
            mInsertionPointCursorController.invalidateHandle();
        }
        if (mTextActionMode != null) {
            mTextActionMode.invalidate();
        }
    }

    /**
     * Invalidates all the sub-display lists that overlap the specified character range
     */
@@ -4104,6 +4116,14 @@ public class Editor {
            setMeasuredDimension(getPreferredWidth(), getPreferredHeight());
        }

        @Override
        public void invalidate() {
            super.invalidate();
            if (isShowing()) {
                positionAtCursorOffset(getCurrentCursorOffset(), true);
            }
        };

        private int getPreferredWidth() {
            return Math.max(mDrawable.getIntrinsicWidth(), mMinSize);
        }
@@ -4170,7 +4190,12 @@ public class Editor {
            return mTextView.getOffsetAtCoordinate(line, x);
        }

        protected void positionAtCursorOffset(int offset, boolean parentScrolled) {
        /**
         * @param offset Cursor offset. Must be in [-1, length].
         * @param forceUpdatePosition whether to force update the position.  This should be true
         * when If the parent has been scrolled, for example.
         */
        protected void positionAtCursorOffset(int offset, boolean forceUpdatePosition) {
            // A HandleView relies on the layout, which may be nulled by external methods
            Layout layout = mTextView.getLayout();
            if (layout == null) {
@@ -4181,7 +4206,7 @@ public class Editor {
            layout = mTextView.getLayout();

            boolean offsetChanged = offset != mPreviousOffset;
            if (offsetChanged || parentScrolled) {
            if (offsetChanged || forceUpdatePosition) {
                if (offsetChanged) {
                    updateSelection(offset);
                    addPositionToTouchUpFilter(offset);
@@ -4782,13 +4807,9 @@ public class Editor {
            mPrevX = x;
        }

        /**
         * @param offset Cursor offset. Must be in [-1, length].
         * @param parentScrolled If the parent has been scrolled or not.
         */
        @Override
        protected void positionAtCursorOffset(int offset, boolean parentScrolled) {
            super.positionAtCursorOffset(offset, parentScrolled);
        protected void positionAtCursorOffset(int offset, boolean forceUpdatePosition) {
            super.positionAtCursorOffset(offset, forceUpdatePosition);
            mInWord = (offset != -1) && !getWordIteratorWithText().isBoundary(offset);
        }

@@ -5014,6 +5035,12 @@ public class Editor {
        public boolean isActive() {
            return mHandle != null && mHandle.isShowing();
        }

        public void invalidateHandle() {
            if (mHandle != null) {
                mHandle.invalidate();
            }
        }
    }

    class SelectionModifierCursorController implements CursorController {
@@ -5418,6 +5445,15 @@ public class Editor {
        public boolean isActive() {
            return mStartHandle != null && mStartHandle.isShowing();
        }

        public void invalidateHandles() {
            if (mStartHandle != null) {
                mStartHandle.invalidate();
            }
            if (mEndHandle != null) {
                mEndHandle.invalidate();
            }
        }
    }

    private class CorrectionHighlighter {
+5 −1
Original line number Diff line number Diff line
@@ -3350,7 +3350,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        mShadowColor = color;

        // Will change text clip region
        if (mEditor != null) mEditor.invalidateTextDisplayList();
        if (mEditor != null) {
            mEditor.invalidateTextDisplayList();
            mEditor.invalidateHandlesAndActionMode();
        }
        invalidate();
    }

@@ -8306,6 +8309,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            if (mEditor != null) {
                if (oldStart >= 0) mEditor.invalidateTextDisplayList(mLayout, oldStart, oldEnd);
                if (newStart >= 0) mEditor.invalidateTextDisplayList(mLayout, newStart, newEnd);
                mEditor.invalidateHandlesAndActionMode();
            }
        }