diff options
author | Yohei Yukawa <yukawa@google.com> | 2014-07-09 22:15:19 +0900 |
---|---|---|
committer | Yohei Yukawa <yukawa@google.com> | 2014-07-09 23:36:45 +0900 |
commit | bf655982f8b05ee6aa3a35cf4581a6849d846b25 (patch) | |
tree | 0ed2d934e79882721626914a0be6192c9986f3be /core/java/android/view/textservice | |
parent | 552697802fdad40177e757738ad17504ca30464d (diff) | |
download | frameworks_base-bf655982f8b05ee6aa3a35cf4581a6849d846b25.zip frameworks_base-bf655982f8b05ee6aa3a35cf4581a6849d846b25.tar.gz frameworks_base-bf655982f8b05ee6aa3a35cf4581a6849d846b25.tar.bz2 |
Fix regressions in existing constructors of TextInfo
This is a follow up CL for Ib58ece68dee4c6187d469049,
which unexpectedly changed behavior of existing public
constructors of TextInfo class.
BUG: 15869548
Change-Id: If5837eb771d78cc24f4d68079009eb98a5641db7
Diffstat (limited to 'core/java/android/view/textservice')
-rw-r--r-- | core/java/android/view/textservice/TextInfo.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/android/view/textservice/TextInfo.java b/core/java/android/view/textservice/TextInfo.java index 55fc048..5499918 100644 --- a/core/java/android/view/textservice/TextInfo.java +++ b/core/java/android/view/textservice/TextInfo.java @@ -31,12 +31,15 @@ public final class TextInfo implements Parcelable { private final int mCookie; private final int mSequenceNumber; + private static final int DEFAULT_COOKIE = 0; + private static final int DEFAULT_SEQUENCE_NUMBER = 0; + /** * Constructor. * @param text the text which will be input to TextService */ public TextInfo(String text) { - this(text, 0, 0, 0, 0); + this(text, 0, getStringLengthOrZero(text), DEFAULT_COOKIE, DEFAULT_SEQUENCE_NUMBER); } /** @@ -46,7 +49,11 @@ public final class TextInfo implements Parcelable { * @param sequenceNumber the sequence number for this TextInfo */ public TextInfo(String text, int cookie, int sequenceNumber) { - this(text, 0, 0, 0, 0); + this(text, 0, getStringLengthOrZero(text), cookie, sequenceNumber); + } + + private static int getStringLengthOrZero(final String text) { + return TextUtils.isEmpty(text) ? 0 : text.length(); } /** |