Merge "Add TtsSpan to schedule-time modes trigger segment so that full day names are read" into main

This commit is contained in:
Matías Hernández
2024-10-28 16:26:40 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference; import androidx.preference.Preference;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.notification.modes.ZenMode; import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend; import com.android.settingslib.notification.modes.ZenModesBackend;
@@ -108,7 +109,9 @@ class ZenModeTriggerUpdatePreferenceController extends AbstractZenModePreference
tryParseScheduleConditionId(mode.getRule().getConditionId()); tryParseScheduleConditionId(mode.getRule().getConditionId());
if (schedule != null) { if (schedule != null) {
preference.setTitle(SystemZenRules.getTimeSummary(mContext, schedule)); 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 { } else {
// Fallback, but shouldn't happen. // Fallback, but shouldn't happen.
Log.wtf(TAG, "SCHEDULE_TIME mode without schedule: " + mode); Log.wtf(TAG, "SCHEDULE_TIME mode without schedule: " + mode);

View File

@@ -44,6 +44,8 @@ import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.flag.junit.SetFlagsRule;
import android.service.notification.SystemZenRules; import android.service.notification.SystemZenRules;
import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig;
import android.text.Spanned;
import android.text.style.TtsSpan;
import android.widget.TextView; import android.widget.TextView;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@@ -293,7 +295,14 @@ public class ZenModeTriggerUpdatePreferenceControllerTest {
assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.isVisible()).isTrue();
assertThat(mPreference.getTitle()).isEqualTo("1:00 AM - 3:00 PM"); 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 // Destination as written into the intent by SubSettingLauncher
assertThat( assertThat(
mPreference.getIntent().getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)) mPreference.getIntent().getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))