Loading core/java/android/widget/Editor.java +21 −19 Original line number Diff line number Diff line Loading @@ -1683,8 +1683,7 @@ public class Editor { return; } Layout layout = mTextView.getLayout(); Layout hintLayout = mTextView.getHintLayout(); Layout layout = getActiveLayout(); final int offset = mTextView.getSelectionStart(); final int line = layout.getLineForOffset(offset); final int top = layout.getLineTop(line); Loading @@ -1699,8 +1698,7 @@ public class Editor { } boolean clamped = layout.shouldClampCursor(line); updateCursorPosition(0, top, middle, getPrimaryHorizontal(layout, hintLayout, offset, clamped)); updateCursorPosition(0, top, middle, layout.getPrimaryHorizontal(offset, clamped)); if (mCursorCount == 2) { updateCursorPosition(1, middle, bottom, Loading @@ -1708,17 +1706,6 @@ public class Editor { } } private float getPrimaryHorizontal(Layout layout, Layout hintLayout, int offset, boolean clamped) { if (TextUtils.isEmpty(layout.getText()) && hintLayout != null && !TextUtils.isEmpty(hintLayout.getText())) { return hintLayout.getPrimaryHorizontal(offset, clamped); } else { return layout.getPrimaryHorizontal(offset, clamped); } } /** * Start an Insertion action mode. */ Loading Loading @@ -3311,14 +3298,15 @@ public class Editor { + mHandleHeight); } else { // We have a single cursor. int line = mTextView.getLayout().getLineForOffset(mTextView.getSelectionStart()); Layout layout = getActiveLayout(); int line = layout.getLineForOffset(mTextView.getSelectionStart()); float primaryHorizontal = mTextView.getLayout().getPrimaryHorizontal(mTextView.getSelectionStart()); layout.getPrimaryHorizontal(mTextView.getSelectionStart()); mSelectionBounds.set( primaryHorizontal, mTextView.getLayout().getLineTop(line), layout.getLineTop(line), primaryHorizontal + 1, mTextView.getLayout().getLineTop(line + 1) + mHandleHeight); layout.getLineTop(line + 1) + mHandleHeight); } // Take TextView's padding and scroll into account. int textHorizontalOffset = mTextView.viewportToContentHorizontalOffset(); Loading Loading @@ -3684,6 +3672,7 @@ public class Editor { prepareCursorControllers(); return; } layout = getActiveLayout(); boolean offsetChanged = offset != mPreviousOffset; if (offsetChanged || parentScrolled) { Loading Loading @@ -3863,6 +3852,19 @@ public class Editor { public void onDetached() {} } /** * Returns the active layout (hint or text layout). Note that the text layout can be null. */ private Layout getActiveLayout() { Layout layout = mTextView.getLayout(); Layout hintLayout = mTextView.getHintLayout(); if (TextUtils.isEmpty(layout.getText()) && hintLayout != null && !TextUtils.isEmpty(hintLayout.getText())) { layout = hintLayout; } return layout; } private class InsertionHandleView extends HandleView { private static final int DELAY_BEFORE_HANDLE_FADES_OUT = 4000; private static final int RECENT_CUT_COPY_DURATION = 15 * 1000; // seconds Loading Loading
core/java/android/widget/Editor.java +21 −19 Original line number Diff line number Diff line Loading @@ -1683,8 +1683,7 @@ public class Editor { return; } Layout layout = mTextView.getLayout(); Layout hintLayout = mTextView.getHintLayout(); Layout layout = getActiveLayout(); final int offset = mTextView.getSelectionStart(); final int line = layout.getLineForOffset(offset); final int top = layout.getLineTop(line); Loading @@ -1699,8 +1698,7 @@ public class Editor { } boolean clamped = layout.shouldClampCursor(line); updateCursorPosition(0, top, middle, getPrimaryHorizontal(layout, hintLayout, offset, clamped)); updateCursorPosition(0, top, middle, layout.getPrimaryHorizontal(offset, clamped)); if (mCursorCount == 2) { updateCursorPosition(1, middle, bottom, Loading @@ -1708,17 +1706,6 @@ public class Editor { } } private float getPrimaryHorizontal(Layout layout, Layout hintLayout, int offset, boolean clamped) { if (TextUtils.isEmpty(layout.getText()) && hintLayout != null && !TextUtils.isEmpty(hintLayout.getText())) { return hintLayout.getPrimaryHorizontal(offset, clamped); } else { return layout.getPrimaryHorizontal(offset, clamped); } } /** * Start an Insertion action mode. */ Loading Loading @@ -3311,14 +3298,15 @@ public class Editor { + mHandleHeight); } else { // We have a single cursor. int line = mTextView.getLayout().getLineForOffset(mTextView.getSelectionStart()); Layout layout = getActiveLayout(); int line = layout.getLineForOffset(mTextView.getSelectionStart()); float primaryHorizontal = mTextView.getLayout().getPrimaryHorizontal(mTextView.getSelectionStart()); layout.getPrimaryHorizontal(mTextView.getSelectionStart()); mSelectionBounds.set( primaryHorizontal, mTextView.getLayout().getLineTop(line), layout.getLineTop(line), primaryHorizontal + 1, mTextView.getLayout().getLineTop(line + 1) + mHandleHeight); layout.getLineTop(line + 1) + mHandleHeight); } // Take TextView's padding and scroll into account. int textHorizontalOffset = mTextView.viewportToContentHorizontalOffset(); Loading Loading @@ -3684,6 +3672,7 @@ public class Editor { prepareCursorControllers(); return; } layout = getActiveLayout(); boolean offsetChanged = offset != mPreviousOffset; if (offsetChanged || parentScrolled) { Loading Loading @@ -3863,6 +3852,19 @@ public class Editor { public void onDetached() {} } /** * Returns the active layout (hint or text layout). Note that the text layout can be null. */ private Layout getActiveLayout() { Layout layout = mTextView.getLayout(); Layout hintLayout = mTextView.getHintLayout(); if (TextUtils.isEmpty(layout.getText()) && hintLayout != null && !TextUtils.isEmpty(hintLayout.getText())) { layout = hintLayout; } return layout; } private class InsertionHandleView extends HandleView { private static final int DELAY_BEFORE_HANDLE_FADES_OUT = 4000; private static final int RECENT_CUT_COPY_DURATION = 15 * 1000; // seconds Loading