Fixed wearable message preview

pull/162/head
M66B 5 years ago
parent 724bb1af23
commit 3f2d636718

@ -2790,7 +2790,8 @@ class Core {
sb.append("<br>"); sb.append("<br>");
} }
builder.setContentText(sb.toString()); // Wearable should ignore summary notification
builder.setContentText(title);
builder.setStyle(new NotificationCompat.BigTextStyle() builder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(HtmlHelper.fromHtml(sb.toString())) .bigText(HtmlHelper.fromHtml(sb.toString()))
@ -3012,27 +3013,40 @@ class Core {
mbuilder.extend(new NotificationCompat.WearableExtender() mbuilder.extend(new NotificationCompat.WearableExtender()
.addActions(wactions)); .addActions(wactions));
if (!TextUtils.isEmpty(message.subject))
mbuilder.setContentText(message.subject);
if (message.content && notify_preview) if (message.content && notify_preview)
try { try {
String body = Helper.readText(message.getFile(context)); String body = Helper.readText(message.getFile(context));
String preview = HtmlHelper.getPreview(body);
String summary =
(TextUtils.isEmpty(message.subject) ? "" : message.subject) +
" - " +
(TextUtils.isEmpty(preview) ? "" : preview);
// Wearable
mbuilder.setContentText(summary);
StringBuilder sbm = new StringBuilder(); StringBuilder sbm = new StringBuilder();
if (!TextUtils.isEmpty(message.subject)) if (!TextUtils.isEmpty(message.subject))
sbm.append(message.subject).append("<br>"); sbm.append(message.subject).append("<br>");
String preview = HtmlHelper.getPreview(body);
if (!TextUtils.isEmpty(preview)) if (!TextUtils.isEmpty(preview))
sbm.append("<em>").append(preview).append("</em>"); sbm.append("<em>").append(preview).append("</em>");
mbuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(HtmlHelper.fromHtml(sbm.toString()))); mbuilder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(HtmlHelper.fromHtml(sbm.toString()))
.setSummaryText(summary));
} catch (IOException ex) { } catch (IOException ex) {
Log.e(ex); Log.e(ex);
mbuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(ex.toString())); mbuilder.setStyle(new NotificationCompat.BigTextStyle()
db.message().setMessageContent(message.id, false, null, null, null); .bigText(ex.toString())
.setSummaryText(Helper.formatThrowable(ex)));
} }
else {
//mbuilder.setLocalOnly(true);
if (!TextUtils.isEmpty(message.subject))
mbuilder.setContentText(message.subject);
}
if (info.hasPhoto()) if (info.hasPhoto())
mbuilder.setLargeIcon(info.getPhotoBitmap()); mbuilder.setLargeIcon(info.getPhotoBitmap());

Loading…
Cancel
Save