summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Gilles Debunne <debunne@google.com> 2011-06-15 09:46:55 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2011-06-15 09:46:55 -0700
commit0656bc32fa8bb59dae502a0f1409afe47f9f638d (patch)
tree531b008ee85d022b9b809921e9bccbeda780e70d
parent194369721a7b8d3255e8770d182f21f1efd569fb (diff)
parent4d8028082127003852016a6a1f480f5286118f96 (diff)
Merge "Bug 4579629. Send before and after text when suggestion is picked."
-rw-r--r--core/java/android/widget/TextView.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 470a23d6a77d..02c2b8f36988 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8574,11 +8574,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final String originalText = mText.subSequence(spanStart, spanEnd).toString();
((Editable) mText).replace(spanStart, spanEnd, suggestion);
- // Swap text content between actual text and Suggestion span
- String[] suggestions = suggestionInfo.suggestionSpan.getSuggestions();
- suggestions[suggestionInfo.suggestionIndex] = originalText;
-
- // Notify source IME of the suggestion pick
+ // Notify source IME of the suggestion pick. Do this before swaping texts.
if (!TextUtils.isEmpty(
suggestionInfo.suggestionSpan.getNotificationTargetClassName())) {
InputMethodManager imm = InputMethodManager.peekInstance();
@@ -8586,6 +8582,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
suggestionInfo.suggestionIndex);
}
+ // Swap text content between actual text and Suggestion span
+ String[] suggestions = suggestionInfo.suggestionSpan.getSuggestions();
+ suggestions[suggestionInfo.suggestionIndex] = originalText;
+
// Restore previous SuggestionSpans
final int lengthDifference = suggestion.length() - (spanEnd - spanStart);
for (int i = 0; i < length; i++) {