TTS preview

pull/184/head
M66B 5 years ago
parent c9cf140fe4
commit b4fd46b50c

@ -520,7 +520,13 @@ public class EntityRule {
return true; return true;
} }
private boolean onActionTts(Context context, EntityMessage message, JSONObject jargs) { private boolean onActionTts(Context context, EntityMessage message, JSONObject jargs) throws IOException {
if (!message.content) {
EntityOperation.queue(context, message, EntityOperation.BODY);
EntityOperation.queue(context, message, EntityOperation.RULE, this.id);
return true;
}
Locale locale = (message.language == null ? Locale.getDefault() : new Locale(message.language)); Locale locale = (message.language == null ? Locale.getDefault() : new Locale(message.language));
Configuration configuration = new Configuration(context.getResources().getConfiguration()); Configuration configuration = new Configuration(context.getResources().getConfiguration());
@ -538,6 +544,12 @@ public class EntityRule {
sb.append(res.getString(R.string.title_rule_tts_subject)) sb.append(res.getString(R.string.title_rule_tts_subject))
.append(' ').append(message.subject).append(". "); .append(' ').append(message.subject).append(". ");
String body = Helper.readText(message.getFile(context));
String preview = HtmlHelper.getPreview(body);
if (!TextUtils.isEmpty(preview))
sb.append(res.getString(R.string.title_rule_tts_content))
.append(' ').append(preview);
TTSHelper.speak(context, "rule:" + message.id, sb.toString(), locale); TTSHelper.speak(context, "rule:" + message.id, sb.toString(), locale);
return true; return true;

@ -1117,6 +1117,7 @@
<string name="title_rule_tts_prefix">New message</string> <string name="title_rule_tts_prefix">New message</string>
<string name="title_rule_tts_from">From</string> <string name="title_rule_tts_from">From</string>
<string name="title_rule_tts_subject">Subject</string> <string name="title_rule_tts_subject">Subject</string>
<string name="title_rule_tts_content">Text</string>
<string name="title_legend_section_synchronize">Synchronize</string> <string name="title_legend_section_synchronize">Synchronize</string>
<string name="title_legend_section_folders">Folders</string> <string name="title_legend_section_folders">Folders</string>

Loading…
Cancel
Save