Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf655982 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

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
parent 55269780
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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();
    }

    /**