summaryrefslogtreecommitdiff
path: root/core/java/android/widget
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-04-29 11:40:22 -0700
committerGilles Debunne <debunne@google.com>2011-04-29 13:27:37 -0700
commit75beb336f4b164c3bed5d4b91f0b9c6ea49a3437 (patch)
tree57761ba39c683a201db0fe4ff753f0dadce31b6f /core/java/android/widget
parentefe2a0e6ac8183c98dfe969928509e3b32903b40 (diff)
SuggestionSpans are removed around edited text.
SuggestionSpans do not make sense anymore when the text they refer to is modified. Removed these at the lowest possible common level: In the SpannableStringBuilder that is used to back the Editable. This way, IME do not have to care about removing these when they change text. And they cannot forget to so either. Also fixed a bug in TextView's paste with multi-item paste text (never exercised, since we have no source for such a thing). Change-Id: I08ed921f8c04ffb1a00936a3e554a85ee82f103c
Diffstat (limited to 'core/java/android/widget')
-rw-r--r--core/java/android/widget/TextView.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 6c5d117c9bf2..667bb2f22aa6 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8177,7 +8177,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mInsertionControllerEnabled) {
final int offset = getOffset(mLastDownPositionX, mLastDownPositionY);
stopSelectionActionMode();
- Selection.setSelection((Spannable)mText, offset);
+ Selection.setSelection((Spannable) mText, offset);
getInsertionController().showWithPaste();
handled = true;
}
@@ -8695,16 +8695,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
(ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = clipboard.getPrimaryClip();
if (clip != null) {
- boolean didfirst = false;
+ boolean didFirst = false;
for (int i=0; i<clip.getItemCount(); i++) {
CharSequence paste = clip.getItemAt(i).coerceToText(getContext());
if (paste != null) {
- if (!didfirst) {
+ if (!didFirst) {
long minMax = prepareSpacesAroundPaste(min, max, paste);
min = extractRangeStartFromLong(minMax);
max = extractRangeEndFromLong(minMax);
Selection.setSelection((Spannable) mText, max);
((Editable) mText).replace(min, max, paste);
+ didFirst = true;
} else {
((Editable) mText).insert(getSelectionEnd(), "\n");
((Editable) mText).insert(getSelectionEnd(), paste);