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

Commit f201899e authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Add TtsSpan to schedule-time modes trigger segment so that full day...

Merge "Add TtsSpan to schedule-time modes trigger segment so that full day names are read" into main
parents 75e2dc4b 1e893312
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;
@@ -108,7 +109,9 @@ class ZenModeTriggerUpdatePreferenceController extends AbstractZenModePreference
                    tryParseScheduleConditionId(mode.getRule().getConditionId());
            if (schedule != null) {
                preference.setTitle(SystemZenRules.getTimeSummary(mContext, schedule));
                preference.setSummary(SystemZenRules.getShortDaysSummary(mContext, schedule));
                preference.setSummary(Utils.createAccessibleSequence(
                        SystemZenRules.getDaysOfWeekShort(mContext, schedule),
                        SystemZenRules.getDaysOfWeekFull(mContext, schedule)));
            } else {
                // Fallback, but shouldn't happen.
                Log.wtf(TAG, "SCHEDULE_TIME mode without schedule: " + mode);
+10 −1
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.service.notification.SystemZenRules;
import android.service.notification.ZenModeConfig;
import android.text.Spanned;
import android.text.style.TtsSpan;
import android.widget.TextView;

import androidx.preference.PreferenceManager;
@@ -293,7 +295,14 @@ public class ZenModeTriggerUpdatePreferenceControllerTest {

        assertThat(mPreference.isVisible()).isTrue();
        assertThat(mPreference.getTitle()).isEqualTo("1:00 AM - 3:00 PM");
        assertThat(mPreference.getSummary()).isEqualTo("Mon - Tue, Thu");
        Spanned summary = (Spanned) mPreference.getSummary();
        assertThat(summary.toString()).isEqualTo("Mon - Tue, Thu");
        TtsSpan[] ttsSpans = summary.getSpans(0, summary.length(), TtsSpan.class);
        assertThat(ttsSpans).hasLength(1);
        assertThat(ttsSpans[0].getType()).isEqualTo(TtsSpan.TYPE_TEXT);
        assertThat(ttsSpans[0].getArgs().getString(TtsSpan.ARG_TEXT)).isEqualTo(
                "Monday to Tuesday, Thursday");

        // Destination as written into the intent by SubSettingLauncher
        assertThat(
                mPreference.getIntent().getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))