Merge "Revert "Text selection - Don't select vertical white space"" into mnc-dev
This commit is contained in:
@@ -3903,10 +3903,6 @@ public class Editor {
|
|||||||
public void updatePosition(float x, float y) {
|
public void updatePosition(float x, float y) {
|
||||||
final int trueOffset = mTextView.getOffsetForPosition(x, y);
|
final int trueOffset = mTextView.getOffsetForPosition(x, y);
|
||||||
final int currLine = mTextView.getLineAtCoordinate(y);
|
final int currLine = mTextView.getLineAtCoordinate(y);
|
||||||
|
|
||||||
// Don't select white space on different lines.
|
|
||||||
if (isWhitespaceLine(mPrevLine, currLine, trueOffset)) return;
|
|
||||||
|
|
||||||
boolean positionCursor = false;
|
boolean positionCursor = false;
|
||||||
int offset = trueOffset;
|
int offset = trueOffset;
|
||||||
int end = getWordEnd(offset, true);
|
int end = getWordEnd(offset, true);
|
||||||
@@ -4005,10 +4001,6 @@ public class Editor {
|
|||||||
public void updatePosition(float x, float y) {
|
public void updatePosition(float x, float y) {
|
||||||
final int trueOffset = mTextView.getOffsetForPosition(x, y);
|
final int trueOffset = mTextView.getOffsetForPosition(x, y);
|
||||||
final int currLine = mTextView.getLineAtCoordinate(y);
|
final int currLine = mTextView.getLineAtCoordinate(y);
|
||||||
|
|
||||||
// Don't select white space on different lines.
|
|
||||||
if (isWhitespaceLine(mPrevLine, currLine, trueOffset)) return;
|
|
||||||
|
|
||||||
int offset = trueOffset;
|
int offset = trueOffset;
|
||||||
boolean positionCursor = false;
|
boolean positionCursor = false;
|
||||||
|
|
||||||
@@ -4069,36 +4061,6 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether selection is happening on a different line than previous and
|
|
||||||
* if that line only contains whitespace up to the touch location.
|
|
||||||
*
|
|
||||||
* @param prevLine The previous line the selection was on.
|
|
||||||
* @param currLine The current line being selected.
|
|
||||||
* @param offset The offset in the text where the touch occurred.
|
|
||||||
* @return Whether or not it was just a white space line being selected.
|
|
||||||
*/
|
|
||||||
private boolean isWhitespaceLine(int prevLine, int currLine, int offset) {
|
|
||||||
if (prevLine == currLine) {
|
|
||||||
// Same line; don't care.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CharSequence text = mTextView.getText();
|
|
||||||
if (offset == text.length()) {
|
|
||||||
// No character at the last position.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int lineEndOffset = mTextView.getLayout().getLineEnd(currLine);
|
|
||||||
for (int cp, i = offset; i < lineEndOffset; i += Character.charCount(cp)) {
|
|
||||||
cp = Character.codePointAt(text, i);
|
|
||||||
if (!Character.isSpaceChar(cp) && !Character.isWhitespace(cp)) {
|
|
||||||
// There are non white space chars on the line.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A CursorController instance can be used to control a cursor in the text.
|
* A CursorController instance can be used to control a cursor in the text.
|
||||||
*/
|
*/
|
||||||
@@ -4178,8 +4140,6 @@ public class Editor {
|
|||||||
private int mStartOffset = -1;
|
private int mStartOffset = -1;
|
||||||
// Indicates whether the user is selecting text and using the drag accelerator.
|
// Indicates whether the user is selecting text and using the drag accelerator.
|
||||||
private boolean mDragAcceleratorActive;
|
private boolean mDragAcceleratorActive;
|
||||||
// Indicates the line of text the drag accelerator is on.
|
|
||||||
private int mPrevLine = -1;
|
|
||||||
|
|
||||||
SelectionModifierCursorController() {
|
SelectionModifierCursorController() {
|
||||||
resetTouchOffsets();
|
resetTouchOffsets();
|
||||||
@@ -4272,8 +4232,6 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New selection, reset line.
|
|
||||||
mPrevLine = mTextView.getLineAtCoordinate(y);
|
|
||||||
mDownPositionX = x;
|
mDownPositionX = x;
|
||||||
mDownPositionY = y;
|
mDownPositionY = y;
|
||||||
mGestureStayedInTapRegion = true;
|
mGestureStayedInTapRegion = true;
|
||||||
@@ -4330,13 +4288,6 @@ public class Editor {
|
|||||||
if (my > fingerOffset) my -= fingerOffset;
|
if (my > fingerOffset) my -= fingerOffset;
|
||||||
offset = mTextView.getOffsetForPosition(mx, my);
|
offset = mTextView.getOffsetForPosition(mx, my);
|
||||||
|
|
||||||
int currLine = mTextView.getLineAtCoordinate(my);
|
|
||||||
|
|
||||||
// Don't select white space on different lines.
|
|
||||||
if (isWhitespaceLine(mPrevLine, currLine, offset)) return;
|
|
||||||
|
|
||||||
mPrevLine = currLine;
|
|
||||||
|
|
||||||
// Perform the check for closeness at edge of view, if we're very close
|
// Perform the check for closeness at edge of view, if we're very close
|
||||||
// don't adjust the offset to be in front of the finger - otherwise the
|
// don't adjust the offset to be in front of the finger - otherwise the
|
||||||
// user can't select words at the edge.
|
// user can't select words at the edge.
|
||||||
|
|||||||
Reference in New Issue
Block a user