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
This commit is contained in:
Barnaby James
2015-05-24 08:36:18 -07:00
parent 389cf34380
commit c54782071a
3 changed files with 22 additions and 9 deletions

View File

@@ -6241,22 +6241,25 @@
<!-- [CHAR LIMIT=60] Zen mode settings: End time option: Summary text value format when end time = next day --> <!-- [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> <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. --> <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only forever. -->
<string name="zen_mode_summary_alarams_only_indefinite">Change to alarms only indefinitely</string> <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"> <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="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> <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> </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"> <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="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> <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> </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> <string name="zen_mode_summary_always">Change to always interrupt</string>
<!-- [CHAR LIMIT=20] Notifications settings: Apps section header --> <!-- [CHAR LIMIT=20] Notifications settings: Apps section header -->

View File

@@ -58,7 +58,6 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
mode = Global.ZEN_MODE_ALARMS; mode = Global.ZEN_MODE_ALARMS;
} }
setZenModeConfig(mode, condition); setZenModeConfig(mode, condition);
notifySuccess(getChangeSummary(mode, minutes));
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (audioManager != null) { if (audioManager != null) {
@@ -67,10 +66,12 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
AudioManager.ADJUST_SAME, AudioManager.ADJUST_SAME,
AudioManager.FLAG_SHOW_UI); AudioManager.FLAG_SHOW_UI);
} }
notifySuccess(getChangeSummary(mode, minutes));
} else { } else {
Log.v(TAG, "Missing extra android.provider.Settings.EXTRA_DO_NOT_DISTURB_MODE_ENABLED"); 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) { private void setZenModeConfig(int mode, Condition condition) {
@@ -88,12 +89,14 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
int indefinite = -1; int indefinite = -1;
int byMinute = -1; int byMinute = -1;
int byHour = -1; int byHour = -1;
int byTime = -1;
switch (mode) { switch (mode) {
case Global.ZEN_MODE_ALARMS: 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; byMinute = R.plurals.zen_mode_summary_alarms_only_by_minute;
byHour = R.plurals.zen_mode_summary_alarms_only_by_hour; byHour = R.plurals.zen_mode_summary_alarms_only_by_hour;
byTime = R.string.zen_mode_summary_alarms_only_by_time;
break; break;
case Global.ZEN_MODE_OFF: case Global.ZEN_MODE_OFF:
indefinite = R.string.zen_mode_summary_always; indefinite = R.string.zen_mode_summary_always;
@@ -112,6 +115,8 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
if (minutes < 60) { if (minutes < 60) {
return res.getQuantityString(byMinute, minutes, minutes, formattedTime); return res.getQuantityString(byMinute, minutes, minutes, formattedTime);
} else if (minutes % 60 != 0) {
return res.getString(byTime, formattedTime);
} else { } else {
int hours = minutes / 60; int hours = minutes / 60;
return res.getQuantityString(byHour, hours, hours, formattedTime); return res.getQuantityString(byHour, hours, hours, formattedTime);

View File

@@ -65,7 +65,12 @@ abstract public class VoiceSettingsActivity extends Activity {
*/ */
protected void notifySuccess(CharSequence prompt) { protected void notifySuccess(CharSequence prompt) {
if (getVoiceInteractor() != null) { if (getVoiceInteractor() != null) {
getVoiceInteractor().submitRequest(new CompleteVoiceRequest(prompt, null)); getVoiceInteractor().submitRequest(new CompleteVoiceRequest(prompt, null) {
@Override
public void onCompleteResult(Bundle options) {
finish();
}
});
} }
} }