Loading core/java/android/widget/TextView.java +54 −64 Original line number Diff line number Diff line Loading @@ -16,11 +16,6 @@ package android.widget; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import android.R; import android.content.ClipData; import android.content.ClipData.Item; Loading Loading @@ -132,6 +127,11 @@ import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.RemoteViews.RemoteView; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.lang.ref.WeakReference; import java.text.BreakIterator; Loading Loading @@ -1119,6 +1119,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } super.setEnabled(enabled); prepareCursorControllers(); } /** Loading Loading @@ -2841,8 +2842,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Do not change the movement method for text that support text selection as it // would prevent an arbitrary cursor displacement. final boolean hasTextSelection = this instanceof EditText || mTextIsSelectable; if (mLinksClickable && !hasTextSelection) { if (mLinksClickable && !textCanBeSelected()) { setMovementMethod(LinkMovementMethod.getInstance()); } } Loading Loading @@ -4228,7 +4228,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * {@link android.R.styleable#TextView_textIsSelectable} XML attribute to make this TextView * selectable (text is not selectable by default). * * Note that the content of an EditText is always selectable. * Note that this method simply returns the state of this flag. Although this flag has to be set * in order to select text in non-editable TextView, the content of an {@link EditText} can * always be selected, independently of the value of this flag. * * @return True if the text displayed in this TextView can be selected by the user. * Loading Loading @@ -4465,12 +4467,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener selStart = getSelectionStart(); selEnd = getSelectionEnd(); if ((isCursorVisible() || mTextIsSelectable) && selStart >= 0 && isEnabled()) { if (selStart >= 0) { if (mHighlightPath == null) mHighlightPath = new Path(); if (selStart == selEnd) { if (!mTextIsSelectable && if (isCursorVisible() && (SystemClock.uptimeMillis() - mShowCursor) % (2 * BLINK) < BLINK) { if (mHighlightPathBogus) { mHighlightPath.reset(); Loading @@ -4489,7 +4491,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener highlight = mHighlightPath; drawCursor = mCursorCount > 0; } } else { } else if (textCanBeSelected()) { if (mHighlightPathBogus) { mHighlightPath.reset(); mLayout.getSelectionPath(selStart, selEnd, mHighlightPath); Loading Loading @@ -7450,9 +7452,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener public boolean onTouchEvent(MotionEvent event) { final int action = event.getActionMasked(); if (hasInsertionController()) { getInsertionController().onTouchEvent(event); } if (hasSelectionController()) { getSelectionController().onTouchEvent(event); } Loading Loading @@ -7880,7 +7879,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // prepareCursorController() relies on this method. // If you change this condition, make sure prepareCursorController is called anywhere // the value of this condition might be changed. return mText instanceof Spannable && mMovement != null && mMovement.canSelectArbitrarily(); if (mMovement == null || !mMovement.canSelectArbitrarily()) return false; return isTextEditable() || (mTextIsSelectable && mText instanceof Spannable && isEnabled()); } private boolean canCut() { Loading Loading @@ -7968,6 +7968,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int minOffset = extractRangeStartFromLong(lastTouchOffsets); final int maxOffset = extractRangeEndFromLong(lastTouchOffsets); // Safety check in case standard touch event handling has been bypassed if (minOffset < 0 || minOffset >= mText.length()) return false; if (maxOffset < 0 || maxOffset >= mText.length()) return false; int selectionStart, selectionEnd; // If a URLSpan (web address, email, phone...) is found at that position, select it. Loading Loading @@ -9722,13 +9726,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ public void hide(); /** * This method is called by {@link #onTouchEvent(MotionEvent)} and gives the controller * a chance to become active and/or visible. * @param event The touch event */ public boolean onTouchEvent(MotionEvent event); /** * Called when the view is detached from window. Perform house keeping task, such as * stopping Runnable thread that would otherwise keep a reference on the context, thus Loading Loading @@ -9756,10 +9753,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } public boolean onTouchEvent(MotionEvent ev) { return false; } public void onTouchModeChanged(boolean isInTouchMode) { if (!isInTouchMode) { hide(); Loading Loading @@ -9818,10 +9811,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mEndHandle != null) mEndHandle.hide(); } public boolean onTouchEvent(MotionEvent event) { public void onTouchEvent(MotionEvent event) { // This is done even when the View does not have focus, so that long presses can start // selection and tap can move cursor from this tap position. if (isTextEditable() || mTextIsSelectable) { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: final float x = event.getX(); Loading Loading @@ -9863,8 +9855,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener break; } } return false; } /** * @param event Loading Loading
core/java/android/widget/TextView.java +54 −64 Original line number Diff line number Diff line Loading @@ -16,11 +16,6 @@ package android.widget; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import android.R; import android.content.ClipData; import android.content.ClipData.Item; Loading Loading @@ -132,6 +127,11 @@ import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.RemoteViews.RemoteView; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.lang.ref.WeakReference; import java.text.BreakIterator; Loading Loading @@ -1119,6 +1119,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } super.setEnabled(enabled); prepareCursorControllers(); } /** Loading Loading @@ -2841,8 +2842,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Do not change the movement method for text that support text selection as it // would prevent an arbitrary cursor displacement. final boolean hasTextSelection = this instanceof EditText || mTextIsSelectable; if (mLinksClickable && !hasTextSelection) { if (mLinksClickable && !textCanBeSelected()) { setMovementMethod(LinkMovementMethod.getInstance()); } } Loading Loading @@ -4228,7 +4228,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * {@link android.R.styleable#TextView_textIsSelectable} XML attribute to make this TextView * selectable (text is not selectable by default). * * Note that the content of an EditText is always selectable. * Note that this method simply returns the state of this flag. Although this flag has to be set * in order to select text in non-editable TextView, the content of an {@link EditText} can * always be selected, independently of the value of this flag. * * @return True if the text displayed in this TextView can be selected by the user. * Loading Loading @@ -4465,12 +4467,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener selStart = getSelectionStart(); selEnd = getSelectionEnd(); if ((isCursorVisible() || mTextIsSelectable) && selStart >= 0 && isEnabled()) { if (selStart >= 0) { if (mHighlightPath == null) mHighlightPath = new Path(); if (selStart == selEnd) { if (!mTextIsSelectable && if (isCursorVisible() && (SystemClock.uptimeMillis() - mShowCursor) % (2 * BLINK) < BLINK) { if (mHighlightPathBogus) { mHighlightPath.reset(); Loading @@ -4489,7 +4491,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener highlight = mHighlightPath; drawCursor = mCursorCount > 0; } } else { } else if (textCanBeSelected()) { if (mHighlightPathBogus) { mHighlightPath.reset(); mLayout.getSelectionPath(selStart, selEnd, mHighlightPath); Loading Loading @@ -7450,9 +7452,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener public boolean onTouchEvent(MotionEvent event) { final int action = event.getActionMasked(); if (hasInsertionController()) { getInsertionController().onTouchEvent(event); } if (hasSelectionController()) { getSelectionController().onTouchEvent(event); } Loading Loading @@ -7880,7 +7879,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // prepareCursorController() relies on this method. // If you change this condition, make sure prepareCursorController is called anywhere // the value of this condition might be changed. return mText instanceof Spannable && mMovement != null && mMovement.canSelectArbitrarily(); if (mMovement == null || !mMovement.canSelectArbitrarily()) return false; return isTextEditable() || (mTextIsSelectable && mText instanceof Spannable && isEnabled()); } private boolean canCut() { Loading Loading @@ -7968,6 +7968,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int minOffset = extractRangeStartFromLong(lastTouchOffsets); final int maxOffset = extractRangeEndFromLong(lastTouchOffsets); // Safety check in case standard touch event handling has been bypassed if (minOffset < 0 || minOffset >= mText.length()) return false; if (maxOffset < 0 || maxOffset >= mText.length()) return false; int selectionStart, selectionEnd; // If a URLSpan (web address, email, phone...) is found at that position, select it. Loading Loading @@ -9722,13 +9726,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ public void hide(); /** * This method is called by {@link #onTouchEvent(MotionEvent)} and gives the controller * a chance to become active and/or visible. * @param event The touch event */ public boolean onTouchEvent(MotionEvent event); /** * Called when the view is detached from window. Perform house keeping task, such as * stopping Runnable thread that would otherwise keep a reference on the context, thus Loading Loading @@ -9756,10 +9753,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } public boolean onTouchEvent(MotionEvent ev) { return false; } public void onTouchModeChanged(boolean isInTouchMode) { if (!isInTouchMode) { hide(); Loading Loading @@ -9818,10 +9811,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mEndHandle != null) mEndHandle.hide(); } public boolean onTouchEvent(MotionEvent event) { public void onTouchEvent(MotionEvent event) { // This is done even when the View does not have focus, so that long presses can start // selection and tap can move cursor from this tap position. if (isTextEditable() || mTextIsSelectable) { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: final float x = event.getX(); Loading Loading @@ -9863,8 +9855,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener break; } } return false; } /** * @param event Loading