Merge "Bug fixes in Text selection." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
4d3baaf530
@@ -63,7 +63,6 @@ import android.text.StaticLayout;
|
|||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.method.ArrowKeyMovementMethod;
|
|
||||||
import android.text.method.DateKeyListener;
|
import android.text.method.DateKeyListener;
|
||||||
import android.text.method.DateTimeKeyListener;
|
import android.text.method.DateTimeKeyListener;
|
||||||
import android.text.method.DialerKeyListener;
|
import android.text.method.DialerKeyListener;
|
||||||
@@ -92,7 +91,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
|
||||||
import android.view.ViewDebug;
|
import android.view.ViewDebug;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.ViewRoot;
|
import android.view.ViewRoot;
|
||||||
@@ -1155,7 +1153,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
fixFocusableAndClickableSettings();
|
fixFocusableAndClickableSettings();
|
||||||
|
|
||||||
// SelectionModifierCursorController depends on canSelectText, which depends on mMovement
|
// SelectionModifierCursorController depends on textCanBeSelected, which depends on mMovement
|
||||||
prepareCursorControllers();
|
prepareCursorControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2725,7 +2723,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
sendAfterTextChanged((Editable) text);
|
sendAfterTextChanged((Editable) text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectionModifierCursorController depends on canSelectText, which depends on text
|
// SelectionModifierCursorController depends on textCanBeSelected, which depends on text
|
||||||
prepareCursorControllers();
|
prepareCursorControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6604,6 +6602,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
} else {
|
} else {
|
||||||
terminateTextSelectionMode();
|
terminateTextSelectionMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mLastTouchOffset = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
startStopMarquee(focused);
|
startStopMarquee(focused);
|
||||||
@@ -6836,7 +6836,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
mInsertionPointCursorController = null;
|
mInsertionPointCursorController = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSelectText() && mLayout != null) {
|
if (textCanBeSelected() && mLayout != null) {
|
||||||
if (mSelectionModifierCursorController == null) {
|
if (mSelectionModifierCursorController == null) {
|
||||||
mSelectionModifierCursorController = new SelectionModifierCursorController();
|
mSelectionModifierCursorController = new SelectionModifierCursorController();
|
||||||
}
|
}
|
||||||
@@ -7054,7 +7054,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
|
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.KEYCODE_A:
|
case KeyEvent.KEYCODE_A:
|
||||||
if (canSelectAll()) {
|
if (canSelectText()) {
|
||||||
return onTextContextMenuItem(ID_SELECT_ALL);
|
return onTextContextMenuItem(ID_SELECT_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7085,11 +7085,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
return super.onKeyShortcut(keyCode, event);
|
return super.onKeyShortcut(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSelectAll() {
|
private boolean canSelectText() {
|
||||||
return canSelectText() && mText.length() != 0;
|
return textCanBeSelected() && mText.length() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSelectText() {
|
private boolean textCanBeSelected() {
|
||||||
// prepareCursorController() relies on this method.
|
// prepareCursorController() relies on this method.
|
||||||
// If you change this condition, make sure prepareCursorController is called anywhere
|
// If you change this condition, make sure prepareCursorController is called anywhere
|
||||||
// the value of this condition might be changed.
|
// the value of this condition might be changed.
|
||||||
@@ -7397,11 +7397,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
if (canSelectText()) {
|
if (canSelectText()) {
|
||||||
menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText).
|
menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText).
|
||||||
setOnMenuItemClickListener(handler);
|
setOnMenuItemClickListener(handler);
|
||||||
added = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canSelectAll()) {
|
|
||||||
menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll).
|
menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll).
|
||||||
setOnMenuItemClickListener(handler).
|
setOnMenuItemClickListener(handler).
|
||||||
setAlphabeticShortcut('a');
|
setAlphabeticShortcut('a');
|
||||||
@@ -7424,8 +7420,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paste location is too imprecise. Only allow on empty text fields.
|
if (canPaste()) {
|
||||||
if (canPaste() && textIsOnlySpaces()) {
|
|
||||||
menu.add(0, ID_PASTE, 0, com.android.internal.R.string.paste).
|
menu.add(0, ID_PASTE, 0, com.android.internal.R.string.paste).
|
||||||
setOnMenuItemClickListener(handler).
|
setOnMenuItemClickListener(handler).
|
||||||
setAlphabeticShortcut('v');
|
setAlphabeticShortcut('v');
|
||||||
@@ -7453,16 +7448,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean textIsOnlySpaces() {
|
|
||||||
final int length = mTransformed.length();
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
if (!Character.isSpaceChar(mTransformed.charAt(i))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this text view is a current input method target. The
|
* Returns whether this text view is a current input method target. The
|
||||||
* default implementation just checks with {@link InputMethodManager}.
|
* default implementation just checks with {@link InputMethodManager}.
|
||||||
|
|||||||
Reference in New Issue
Block a user