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

Commit c5478207 authored by Barnaby James's avatar Barnaby James
Browse files

Fix TTS for Zen mode voice activity.

Don't finish activity until TTS has finished.
Incorrect TTS for mix of hours / mins - e.g. 1 hour 45 minutes.
Improve the description of TTS strings for translators.

BUG: 20248251
BUG: 21413212
BUG: 21411622

Change-Id: Id2693ea82b76492216147012216ba07ce75a9d12
parent 389cf343
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -6241,22 +6241,25 @@
    <!-- [CHAR LIMIT=60] Zen mode settings: End time option: Summary text value format when end time = next day -->
    <string name="zen_mode_end_time_next_day_summary_format"><xliff:g id="formatted_time" example="7:00 AM">%s</xliff:g> next day</string>

    <!-- [CHAR LIMIT=NONE] Zen mode voice - spoken summary: alarms only duration indefinite. -->
    <string name="zen_mode_summary_alarams_only_indefinite">Change to alarms only indefinitely</string>
    <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only forever. -->
    <string name="zen_mode_summary_alarms_only_indefinite">Change to alarms only indefinitely</string>

    <!-- [CHAR LIMIT=NONE] Zen mode voice- spoken summary: alarms only duration minutes. -->
    <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only for < 60 minutes. -->
    <plurals name="zen_mode_summary_alarms_only_by_minute">
        <item quantity="one">Change to alarms only for one minute until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g></item>
        <item quantity="other">Change to alarms only for <xliff:g id="duration" example="2">%1$d</xliff:g> minutes (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
    </plurals>

    <!-- [CHAR LIMIT=NONE] Zen mode voice- spoken summary: alarms only duration hours. -->
    <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only for N hours. -->
    <plurals name="zen_mode_summary_alarms_only_by_hour">
        <item quantity="one">Change to alarms only for one hour until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g></item>
        <item quantity="other">Change to alarms only for <xliff:g id="duration" example="2">%1$d</xliff:g> hours until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g></item>
    </plurals>

    <!-- [CHAR LIMIT=NONE] Zen mode voice - spoken summary: off. -->
    <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only until a specific time. -->
    <string name="zen_mode_summary_alarms_only_by_time">Change to alarms only until <xliff:g id="formattedTime" example="10:00 PM">%1$s</xliff:g></string>

    <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: Turn on all notifications. -->
    <string name="zen_mode_summary_always">Change to always interrupt</string>

    <!-- [CHAR LIMIT=20] Notifications settings: Apps section header -->
+8 −3
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
                mode = Global.ZEN_MODE_ALARMS;
            }
            setZenModeConfig(mode, condition);
            notifySuccess(getChangeSummary(mode, minutes));

            AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            if (audioManager != null) {
@@ -67,10 +66,12 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
                         AudioManager.ADJUST_SAME,
                         AudioManager.FLAG_SHOW_UI);
            }
            notifySuccess(getChangeSummary(mode, minutes));
        } else {
            Log.v(TAG, "Missing extra android.provider.Settings.EXTRA_DO_NOT_DISTURB_MODE_ENABLED");
            finish();
        }
        return true;
        return false;
    }

    private void setZenModeConfig(int mode, Condition condition) {
@@ -88,12 +89,14 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
        int indefinite = -1;
        int byMinute = -1;
        int byHour = -1;
        int byTime = -1;

        switch (mode) {
            case Global.ZEN_MODE_ALARMS:
                indefinite = R.string.zen_mode_summary_alarams_only_indefinite;
                indefinite = R.string.zen_mode_summary_alarms_only_indefinite;
                byMinute = R.plurals.zen_mode_summary_alarms_only_by_minute;
                byHour = R.plurals.zen_mode_summary_alarms_only_by_hour;
                byTime = R.string.zen_mode_summary_alarms_only_by_time;
                break;
            case Global.ZEN_MODE_OFF:
                indefinite = R.string.zen_mode_summary_always;
@@ -112,6 +115,8 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {

        if (minutes < 60) {
            return res.getQuantityString(byMinute, minutes, minutes, formattedTime);
        } else if (minutes % 60 != 0) {
            return res.getString(byTime, formattedTime);
        } else {
            int hours = minutes / 60;
            return res.getQuantityString(byHour, hours, hours, formattedTime);
+6 −1
Original line number Diff line number Diff line
@@ -65,7 +65,12 @@ abstract public class VoiceSettingsActivity extends Activity {
     */
    protected void notifySuccess(CharSequence prompt) {
        if (getVoiceInteractor() != null) {
            getVoiceInteractor().submitRequest(new CompleteVoiceRequest(prompt, null));
            getVoiceInteractor().submitRequest(new CompleteVoiceRequest(prompt, null) {
                @Override
                public void onCompleteResult(Bundle options) {
                    finish();
                }
            });
        }
    }