MCPcopy Create free account
hub / github.com/M66B/FairEmail / speak

Method speak

app/src/main/java/eu/faircode/email/EntityRule.java:1347–1382  ·  view source on GitHub ↗
(Context context, EntityRule rule, EntityMessage message)

Source from the content-addressed store, hash-verified

1345 }
1346
1347 private static void speak(Context context, EntityRule rule, EntityMessage message) throws IOException {
1348 if (Helper.isPlayStoreInstall())
1349 throw new IllegalArgumentException("TTS is available in the GitHub version only because Google doesn't allow it in the Play Store :-(");
1350
1351 Log.i("Speaking name=" + rule.name);
1352
1353 if (message.ui_seen)
1354 return;
1355
1356 StringBuilder sb = new StringBuilder();
1357 sb.append(context.getString(R.string.title_rule_tts_prefix)).append(". ");
1358
1359 if (message.from != null && message.from.length > 0)
1360 sb.append(context.getString(R.string.title_rule_tts_from))
1361 .append(' ').append(MessageHelper.formatAddressesShort(message.from)).append(". ");
1362
1363 if (!TextUtils.isEmpty(message.subject))
1364 sb.append(context.getString(R.string.title_rule_tts_subject))
1365 .append(' ').append(message.subject).append(". ");
1366
1367 String body = Helper.readText(message.getFile(context));
1368 String text = HtmlHelper.getFullText(context, body);
1369 String preview = HtmlHelper.getPreview(text);
1370
1371 if (!TextUtils.isEmpty(preview))
1372 sb.append(context.getString(R.string.title_rule_tts_content))
1373 .append(' ').append(preview);
1374
1375 Intent intent = new Intent(context, ServiceTTS.class)
1376 .setAction("tts:" + message.id)
1377 .putExtra(ServiceTTS.EXTRA_FLUSH, false)
1378 .putExtra(ServiceTTS.EXTRA_TEXT, sb.toString())
1379 .putExtra(ServiceTTS.EXTRA_LANGUAGE, message.language)
1380 .putExtra(ServiceTTS.EXTRA_UTTERANCE_ID, "rule:" + message.id);
1381 context.startService(intent);
1382 }
1383
1384 private boolean onActionSnooze(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
1385 int duration = jargs.getInt("duration");

Callers 2

runMethod · 0.95
delegateMethod · 0.80

Calls 13

isPlayStoreInstallMethod · 0.95
iMethod · 0.95
formatAddressesShortMethod · 0.95
readTextMethod · 0.95
getFullTextMethod · 0.95
getPreviewMethod · 0.95
setActionMethod · 0.80
startServiceMethod · 0.80
appendMethod · 0.45
getStringMethod · 0.45
isEmptyMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected