summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/inputmethod
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-06-27 12:24:20 +0900
committerYohei Yukawa <yukawa@google.com>2014-06-27 16:23:09 +0900
commita1fda005f9583486f4372ecbb0eec503ee9cece8 (patch)
tree5e00ba6ee78ea95f3d890fc9816fdfe7959ee4aa /core/java/android/view/inputmethod
parent0c9b72b09f7ca91d2832f42c64b81e5d790a2d78 (diff)
downloadframeworks_base-a1fda005f9583486f4372ecbb0eec503ee9cece8.zip
frameworks_base-a1fda005f9583486f4372ecbb0eec503ee9cece8.tar.gz
frameworks_base-a1fda005f9583486f4372ecbb0eec503ee9cece8.tar.bz2
Use CharSequence instead of String in CursorAnchorInfo
This might be useful if we need to pass some spans from the application to the input method through CursorAnchorInfo. This change makes CursorAnchorInfo more consistent with other input method APIs where CharSequence is preferred over String. BUG: 15088391 Change-Id: Ie04e8a27050849fee1c93ef14b9944acc70fafe4
Diffstat (limited to 'core/java/android/view/inputmethod')
-rw-r--r--core/java/android/view/inputmethod/CursorAnchorInfo.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/java/android/view/inputmethod/CursorAnchorInfo.java b/core/java/android/view/inputmethod/CursorAnchorInfo.java
index 66f5f6c..d3d5fff 100644
--- a/core/java/android/view/inputmethod/CursorAnchorInfo.java
+++ b/core/java/android/view/inputmethod/CursorAnchorInfo.java
@@ -21,6 +21,8 @@ import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.Layout;
+import android.text.SpannedString;
+import android.text.TextUtils;
import android.view.inputmethod.SparseRectFArray.SparseRectFArrayBuilder;
import java.util.Objects;
@@ -40,7 +42,7 @@ public final class CursorAnchorInfo implements Parcelable {
/**
* The text, tracked as a composing region.
*/
- private final String mComposingText;
+ private final CharSequence mComposingText;
/**
* Horizontal position of the insertion marker, in the local coordinates that will be
@@ -88,7 +90,7 @@ public final class CursorAnchorInfo implements Parcelable {
mSelectionStart = source.readInt();
mSelectionEnd = source.readInt();
mComposingTextStart = source.readInt();
- mComposingText = source.readString();
+ mComposingText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
mInsertionMarkerHorizontal = source.readFloat();
mInsertionMarkerTop = source.readFloat();
mInsertionMarkerBaseline = source.readFloat();
@@ -109,7 +111,7 @@ public final class CursorAnchorInfo implements Parcelable {
dest.writeInt(mSelectionStart);
dest.writeInt(mSelectionEnd);
dest.writeInt(mComposingTextStart);
- dest.writeString(mComposingText);
+ TextUtils.writeToParcel(mComposingText, dest, flags);
dest.writeFloat(mInsertionMarkerHorizontal);
dest.writeFloat(mInsertionMarkerTop);
dest.writeFloat(mInsertionMarkerBaseline);
@@ -210,12 +212,13 @@ public final class CursorAnchorInfo implements Parcelable {
if (composingText == null) {
mComposingText = null;
} else {
- mComposingText = composingText.toString();
+ // Make a snapshot of the given char sequence.
+ mComposingText = new SpannedString(composingText);
}
return this;
}
private int mComposingTextStart = -1;
- private String mComposingText = null;
+ private CharSequence mComposingText = null;
/**
* Sets the location of the text insertion point (zero width cursor) as a rectangle in
@@ -362,7 +365,7 @@ public final class CursorAnchorInfo implements Parcelable {
* Returns the entire composing text.
* @return null if there is no composition.
*/
- public String getComposingText() {
+ public CharSequence getComposingText() {
return mComposingText;
}