diff options
| author | Gilles Debunne <debunne@google.com> | 2010-10-11 09:57:05 -0700 |
|---|---|---|
| committer | Gilles Debunne <debunne@google.com> | 2010-10-11 09:57:05 -0700 |
| commit | 569a4bbae11789dd00412355f238b0a32d75a8df (patch) | |
| tree | 1a348c3ce416033305188bc099496275e0240d13 | |
| parent | ac0ed70cc76be87260da4f7c595bd0df7a13b864 (diff) | |
| parent | 42dd7ec9f03f169d373c3753d52eb5632ab5b142 (diff) | |
| download | frameworks_base-569a4bbae11789dd00412355f238b0a32d75a8df.zip frameworks_base-569a4bbae11789dd00412355f238b0a32d75a8df.tar.gz frameworks_base-569a4bbae11789dd00412355f238b0a32d75a8df.tar.bz2 | |
resolved conflicts for merge of 42dd7ec9 to master
Change-Id: Id388745d7ec22c48b34b744d5a4c07097cf2650b
| -rw-r--r-- | core/java/android/widget/TextView.java | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index a290ef6..e32c899 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -6612,7 +6612,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (!mFrozenWithFocus || (selStart < 0 || selEnd < 0)) { // If a tap was used to give focus to that view, move cursor at tap position. // Has to be done before onTakeFocus, which can be overloaded. - moveCursorToLastTapPosition(); + final int lastTapPosition = getLastTapPosition(); + if (lastTapPosition >= 0) { + Selection.setSelection((Spannable) mText, lastTapPosition); + } if (mMovement != null) { mMovement.onTakeFocus(this, (Spannable) mText, direction); @@ -6674,6 +6677,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else { terminateSelectionActionMode(); } + + if (mSelectionModifierCursorController != null) { + ((SelectionModifierCursorController) mSelectionModifierCursorController).resetTouchOffsets(); + } } startStopMarquee(focused); @@ -6685,20 +6692,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener super.onFocusChanged(focused, direction, previouslyFocusedRect); } - private void moveCursorToLastTapPosition() { + private int getLastTapPosition() { if (mSelectionModifierCursorController != null) { - int mTapToFocusPosition = ((SelectionModifierCursorController) + int lastTapPosition = ((SelectionModifierCursorController) mSelectionModifierCursorController).getMinTouchOffset(); - if (mTapToFocusPosition >= 0) { + if (lastTapPosition >= 0) { // Safety check, should not be possible. - if (mTapToFocusPosition > mText.length()) { - Log.e(LOG_TAG, "Invalid tap focus position (" + mTapToFocusPosition + " vs " + if (lastTapPosition > mText.length()) { + Log.e(LOG_TAG, "Invalid tap focus position (" + lastTapPosition + " vs " + mText.length() + ")"); - mTapToFocusPosition = mText.length(); + lastTapPosition = mText.length(); } - Selection.setSelection((Spannable) mText, mTapToFocusPosition); + return lastTapPosition; } } + + return -1; } @Override @@ -8167,7 +8176,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener SelectionModifierCursorController() { mStartHandle = new HandleView(this, HandleView.LEFT); mEndHandle = new HandleView(this, HandleView.RIGHT); - mMinTouchOffset = mMaxTouchOffset = -1; + resetTouchOffsets(); } public void show() { @@ -8299,6 +8308,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return mMaxTouchOffset; } + public void resetTouchOffsets() { + mMinTouchOffset = mMaxTouchOffset = -1; + } + /** * @return true iff this controller is currently used to move the selection start. */ |
