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

Commit 0ed59fae authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #6567507 [Bidi] - Cursor is sometimes not visible on EditText

- take the hint layout primary horizontal offset if needed

Change-Id: Ib5c4dd990278e1fd8bb9ba4f4b6940a62dba91e3
parent 73bde11e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1416,6 +1416,7 @@ public class Editor {
        }

        Layout layout = mTextView.getLayout();
        Layout hintLayout = mTextView.getHintLayout();
        final int offset = mTextView.getSelectionStart();
        final int line = layout.getLineForOffset(offset);
        final int top = layout.getLineTop(line);
@@ -1429,13 +1430,23 @@ public class Editor {
            middle = (top + bottom) >> 1;
        }

        updateCursorPosition(0, top, middle, layout.getPrimaryHorizontal(offset));
        updateCursorPosition(0, top, middle, getPrimaryHorizontal(layout, hintLayout, offset));

        if (mCursorCount == 2) {
            updateCursorPosition(1, middle, bottom, layout.getSecondaryHorizontal(offset));
        }
    }

    private float getPrimaryHorizontal(Layout layout, Layout hintLayout, int offset) {
        if (TextUtils.isEmpty(layout.getText()) &&
                hintLayout != null &&
                !TextUtils.isEmpty(hintLayout.getText())) {
            return hintLayout.getPrimaryHorizontal(offset);
        } else {
            return layout.getPrimaryHorizontal(offset);
        }
    }

    /**
     * @return true if the selection mode was actually started.
     */
+8 −0
Original line number Diff line number Diff line
@@ -1311,6 +1311,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return mLayout;
    }

    /**
     * @return the Layout that is currently being used to display the hint text.
     * This can be null.
     */
    final Layout getHintLayout() {
        return mHintLayout;
    }

    /**
     * @return the current key listener for this TextView.
     * This will frequently be null for non-EditText TextViews.