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

Commit 70a3f677 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #5016544: IME keyboard hides folder rename text field.

Tweak some issues in TextView with the focus rect used to determing
where the scroll position needs to be.  The ultimate problem was that
in various situations it would use the right-most selection position
cursor as the scroll location and when it adds 1 to make this a valid
rect we end up with a rectangle that is outside of the view.

Change-Id: Ia200c58e4e014d2a0a1be4761f9a1e5eb702a8e5
parent 43321684
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -96,7 +96,7 @@ import java.util.List;
@SuppressWarnings({"EmptyCatchBlock", "PointlessBooleanExpression"})
@SuppressWarnings({"EmptyCatchBlock", "PointlessBooleanExpression"})
public final class ViewRootImpl extends Handler implements ViewParent,
public final class ViewRootImpl extends Handler implements ViewParent,
        View.AttachInfo.Callbacks, HardwareRenderer.HardwareDrawCallbacks {
        View.AttachInfo.Callbacks, HardwareRenderer.HardwareDrawCallbacks {
    private static final String TAG = "ViewAncestor";
    private static final String TAG = "ViewRootImpl";
    private static final boolean DBG = false;
    private static final boolean DBG = false;
    private static final boolean LOCAL_LOGV = false;
    private static final boolean LOCAL_LOGV = false;
    /** @noinspection PointlessBooleanExpression*/
    /** @noinspection PointlessBooleanExpression*/
+37 −9
Original line number Original line Diff line number Diff line
@@ -4969,18 +4969,42 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            return;
            return;
        }
        }


        int sel = getSelectionEnd();
        int selEnd = getSelectionEnd();
        if (sel < 0) {
        if (selEnd < 0) {
            super.getFocusedRect(r);
            super.getFocusedRect(r);
            return;
            return;
        }
        }


        int line = mLayout.getLineForOffset(sel);
        int selStart = getSelectionStart();
        if (selStart < 0 || selStart >= selEnd) {
            int line = mLayout.getLineForOffset(selEnd);
            r.top = mLayout.getLineTop(line);
            r.top = mLayout.getLineTop(line);
            r.bottom = mLayout.getLineBottom(line);
            r.bottom = mLayout.getLineBottom(line);

            r.left = (int) mLayout.getPrimaryHorizontal(selEnd) - 2;
        r.left = (int) mLayout.getPrimaryHorizontal(sel);
            r.right = r.left + 4;
        r.right = r.left + 1;
        } else {
            int lineStart = mLayout.getLineForOffset(selStart);
            int lineEnd = mLayout.getLineForOffset(selEnd);
            r.top = mLayout.getLineTop(lineStart);
            r.bottom = mLayout.getLineBottom(lineEnd);
            if (lineStart == lineEnd) {
                r.left = (int) mLayout.getPrimaryHorizontal(selStart);
                r.right = (int) mLayout.getPrimaryHorizontal(selEnd);
            } else {
                // Selection extends across multiple lines -- the focused
                // rect covers the entire width.
                if (mHighlightPathBogus) {
                    mHighlightPath.reset();
                    mLayout.getSelectionPath(selStart, selEnd, mHighlightPath);
                    mHighlightPathBogus = false;
                }
                synchronized (sTempRect) {
                    mHighlightPath.computeBounds(sTempRect, true);
                    r.left = (int)sTempRect.left-1;
                    r.right = (int)sTempRect.right+1;
                }
            }
        }


        // Adjust for padding and gravity.
        // Adjust for padding and gravity.
        int paddingLeft = getCompoundPaddingLeft();
        int paddingLeft = getCompoundPaddingLeft();
@@ -6812,7 +6836,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            // requestRectangleOnScreen() is in terms of content coordinates.
            // requestRectangleOnScreen() is in terms of content coordinates.


            if (mTempRect == null) mTempRect = new Rect();
            if (mTempRect == null) mTempRect = new Rect();
            mTempRect.set(x, top, x + 1, bottom);
            // The offsets here are to ensure the rectangle we are using is
            // within our view bounds, in case the cursor is on the far left
            // or right.  If it isn't withing the bounds, then this request
            // will be ignored.
            mTempRect.set(x - 2, top, x + 2, bottom);
            getInterestingRect(mTempRect, line);
            getInterestingRect(mTempRect, line);
            mTempRect.offset(mScrollX, mScrollY);
            mTempRect.offset(mScrollX, mScrollY);