aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-09-18 18:26:06 +0900
committerYohei Yukawa <yukawa@google.com>2014-09-18 18:27:45 +0900
commiteddfe51b38755e0068e3c322868c5e209f212f6f (patch)
tree280fda5e51e269da433b9e3acccfa33025833481 /java/src/com/android/inputmethod/latin/RichInputConnection.java
parentcdabc71c6da00ea1c2254e13021973c762c79be4 (diff)
parent233a2f21c38a27049fa3b03af699593f629d1681 (diff)
downloadlatinime-eddfe51b38755e0068e3c322868c5e209f212f6f.tar.gz
latinime-eddfe51b38755e0068e3c322868c5e209f212f6f.tar.xz
latinime-eddfe51b38755e0068e3c322868c5e209f212f6f.zip
resolved conflicts for merge of 233a2f21 to master
Change-Id: If391cc622367dfb4448c6a5c32b82111d352d86e
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index dc00ecc8f..d672430a1 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -252,7 +252,7 @@ public final class RichInputConnection {
* See {@link InputConnection#commitText(CharSequence, int)}.
*/
public void commitText(final CharSequence text, final int newCursorPosition) {
- commitTextWithBackgroundColor(text, newCursorPosition, Color.TRANSPARENT);
+ commitTextWithBackgroundColor(text, newCursorPosition, Color.TRANSPARENT, text.length());
}
/**
@@ -265,9 +265,11 @@ public final class RichInputConnection {
* the background color. Note that this method specifies {@link BackgroundColorSpan} with
* {@link Spanned#SPAN_COMPOSING} flag, meaning that the background color persists until
* {@link #finishComposingText()} is called.
+ * @param coloredTextLength the length of text, in Java chars, which should be rendered with
+ * the given background color.
*/
public void commitTextWithBackgroundColor(final CharSequence text, final int newCursorPosition,
- final int color) {
+ final int color, final int coloredTextLength) {
if (DEBUG_BATCH_NESTING) checkBatchEdit();
if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
mCommittedTextBeforeComposingText.append(text);
@@ -285,7 +287,8 @@ public final class RichInputConnection {
mTempObjectForCommitText.clear();
mTempObjectForCommitText.append(text);
final BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(color);
- mTempObjectForCommitText.setSpan(backgroundColorSpan, 0, text.length(),
+ final int spanLength = Math.min(coloredTextLength, text.length());
+ mTempObjectForCommitText.setSpan(backgroundColorSpan, 0, spanLength,
Spanned.SPAN_COMPOSING | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mIC.commitText(mTempObjectForCommitText, newCursorPosition);
mLastCommittedTextHasBackgroundColor = true;