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

Commit 8525faea authored by Sally's avatar Sally Committed by Sally Kovacs
Browse files

Add IntRange to TtsSpan TimeBuilder APIs

TimeBuilder is restricted to [0, 59] for seconds and minutes, and [0, 24] for hours.

Flag: com.android.text.flags.tts_span_duration
Test: builds
Bug: 372323279
Change-Id: I71b06e8e9904e11d03552abfa5d7f0b9d5b44c5f
parent dba90841
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -50062,9 +50062,9 @@ package android.text.style {
  public static class TtsSpan.TimeBuilder extends android.text.style.TtsSpan.SemioticClassBuilder<android.text.style.TtsSpan.TimeBuilder> {
    ctor public TtsSpan.TimeBuilder();
    ctor public TtsSpan.TimeBuilder(int, int);
    method public android.text.style.TtsSpan.TimeBuilder setHours(int);
    method public android.text.style.TtsSpan.TimeBuilder setMinutes(int);
    method @FlaggedApi("com.android.text.flags.tts_span_duration") @NonNull public android.text.style.TtsSpan.TimeBuilder setSeconds(int);
    method public android.text.style.TtsSpan.TimeBuilder setHours(@IntRange(from=0, to=24) int);
    method public android.text.style.TtsSpan.TimeBuilder setMinutes(@IntRange(from=0, to=59) int);
    method @FlaggedApi("com.android.text.flags.tts_span_duration") @NonNull public android.text.style.TtsSpan.TimeBuilder setSeconds(@IntRange(from=0, to=59) int);
  }
  public static class TtsSpan.VerbatimBuilder extends android.text.style.TtsSpan.SemioticClassBuilder<android.text.style.TtsSpan.VerbatimBuilder> {
+6 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.text.style;
import static com.android.text.flags.Flags.FLAG_TTS_SPAN_DURATION;

import android.annotation.FlaggedApi;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.PersistableBundle;
@@ -324,7 +325,8 @@ public class TtsSpan implements ParcelableSpan {

    /**
     * Argument used to specify the seconds of a time or duration. The seconds should be
     * provided as an integer in the range from 0 up to and including 59.
     * provided as an integer in the range from 0 up to and including 59 for
     * {@link #TYPE_TIME}.
     * Can be used with {@link #TYPE_TIME} or {@link #TYPE_DURATION}.
     */
    @FlaggedApi(FLAG_TTS_SPAN_DURATION)
@@ -1140,7 +1142,7 @@ public class TtsSpan implements ParcelableSpan {
         * @return This instance.
         * @see #ARG_HOURS
         */
        public TimeBuilder setHours(int hours) {
        public TimeBuilder setHours(@IntRange(from = 0, to = 24) int hours) {
            return setIntArgument(TtsSpan.ARG_HOURS, hours);
        }

@@ -1151,7 +1153,7 @@ public class TtsSpan implements ParcelableSpan {
         * @return This instance.
         * @see #ARG_MINUTES
         */
        public TimeBuilder setMinutes(int minutes) {
        public TimeBuilder setMinutes(@IntRange(from = 0, to = 59) int minutes) {
            return setIntArgument(TtsSpan.ARG_MINUTES, minutes);
        }

@@ -1162,7 +1164,7 @@ public class TtsSpan implements ParcelableSpan {
         */
        @FlaggedApi(FLAG_TTS_SPAN_DURATION)
        @NonNull
        public TimeBuilder setSeconds(int seconds) {
        public TimeBuilder setSeconds(@IntRange(from = 0, to = 59) int seconds) {
            return setIntArgument(TtsSpan.ARG_SECONDS, seconds);
        }
    }