summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2010-08-18 21:24:35 -0700
committerGilles Debunne <debunne@google.com>2010-08-19 11:18:05 -0700
commited279f8f19098aef31aba43663ab7b3fa43f1999 (patch)
treebbe5b19fbbf4a1d8772958b9c54ec13a9e8e553a
parent73040de4f6722c1c2c6e3a8b26f8b966bd415860 (diff)
downloadframeworks_base-ed279f8f19098aef31aba43663ab7b3fa43f1999.zip
frameworks_base-ed279f8f19098aef31aba43663ab7b3fa43f1999.tar.gz
frameworks_base-ed279f8f19098aef31aba43663ab7b3fa43f1999.tar.bz2
Fix for a bug that prevents text selection on initially empty text edits.
Change-Id: I0346b632e7de32b082c0ed7e605873946e3eb554
-rw-r--r--core/java/android/widget/TextView.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 0510701..25c5b24 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6584,7 +6584,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
onEndBatchEdit();
hideInsertionPointCursorController();
- stopSelectionActionMode();
+ terminateSelectionActionMode();
}
startStopMarquee(focused);
@@ -6680,7 +6680,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
} else {
// Tapping outside stops selection mode, if any
- finishSelectionActionMode();
+ stopSelectionActionMode();
}
}
@@ -6782,9 +6782,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mSelectionModifierCursorController = new SelectionModifierCursorController();
}
} else {
- mSelectionModifierCursorController = null;
// Stop selection mode if the controller becomes unavailable.
- finishSelectionActionMode();
+ stopSelectionActionMode();
+ mSelectionModifierCursorController = null;
}
}
@@ -7029,7 +7029,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private boolean canSelectAll() {
- return canSelectText();
+ return canSelectText() && mText.length() != 0;
}
private boolean canSelectText() {
@@ -7037,7 +7037,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// If you change this condition, make sure prepareCursorController is called anywhere
// the value of this condition might be changed.
return (mText instanceof Spannable &&
- mText.length() != 0 &&
mMovement != null &&
mMovement.canSelectArbitrarily());
}
@@ -7388,13 +7387,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
/**
- * Same as {@link #finishSelectionActionMode()}, except that there is no cursor controller
+ * Same as {@link #stopSelectionActionMode()}, except that there is no cursor controller
* fade out animation. Needed since the drawable and their alpha values are shared by all
* TextViews. Switching from one TextView to another would fade the cursor controllers in the
* new one otherwise.
*/
- private void stopSelectionActionMode() {
- finishSelectionActionMode();
+ private void terminateSelectionActionMode() {
+ stopSelectionActionMode();
if (mSelectionModifierCursorController != null) {
SelectionModifierCursorController selectionModifierCursorController =
(SelectionModifierCursorController) mSelectionModifierCursorController;
@@ -7402,7 +7401,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
- private void finishSelectionActionMode() {
+ private void stopSelectionActionMode() {
if (mSelectionActionMode != null) {
mSelectionActionMode.finish();
}
@@ -7544,7 +7543,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
}
- finishSelectionActionMode();
+ stopSelectionActionMode();
}
return true;
@@ -7553,13 +7552,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
clipboard.setPrimaryClip(new ClippedData(null, null,
new ClippedData.Item(mTransformed.subSequence(min, max))));
((Editable) mText).delete(min, max);
- finishSelectionActionMode();
+ stopSelectionActionMode();
return true;
case ID_COPY:
clipboard.setPrimaryClip(new ClippedData(null, null,
new ClippedData.Item(mTransformed.subSequence(min, max))));
- finishSelectionActionMode();
+ stopSelectionActionMode();
return true;
}
@@ -8058,7 +8057,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private void hideControllers() {
hideInsertionPointCursorController();
- finishSelectionActionMode();
+ stopSelectionActionMode();
}
/**