From ea4b999d8a1e4457d4296b4d1fb66ff55b2afd29 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Mon, 9 Sep 2019 20:07:13 +0200 Subject: include ticker information in notification --- .../messenger/services/NotificationService.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index 4d8c39d22..cc79f7b6a 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -15,14 +15,12 @@ import android.media.AudioAttributes; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; -import android.os.DeadSystemException; import android.os.SystemClock; import android.preference.PreferenceManager; import android.support.annotation.RequiresApi; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat.BigPictureStyle; import android.support.v4.app.NotificationCompat.Builder; -import android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation; import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.Person; import android.support.v4.app.RemoteInput; @@ -32,7 +30,6 @@ import android.text.SpannableString; import android.text.style.StyleSpan; import android.util.DisplayMetrics; import android.util.Log; -import android.util.Pair; import java.io.File; import java.io.IOException; @@ -320,7 +317,7 @@ public class NotificationService { if (!notify(message)) { if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) { mXmppConnectionService.vibrate(); - } + } Log.d(Config.LOGTAG, message.getConversation().getAccount().getJid().asBareJid() + ": suppressing notification because turned off"); return; } @@ -482,10 +479,7 @@ public class NotificationService { private Builder buildMultipleConversation(final boolean notify, final boolean quietHours) { final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService, quietHours ? "quiet_hours" : (notify ? "messages" : "silent_messages")); final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); - style.setBigContentTitle(notifications.size() - + " " - + mXmppConnectionService - .getString(R.string.unread_conversations)); + style.setBigContentTitle(mXmppConnectionService.getString(R.string.x_unread_conversations, notifications.size())); final StringBuilder names = new StringBuilder(); Conversation conversation = null; for (final ArrayList messages : notifications.values()) { @@ -510,10 +504,8 @@ public class NotificationService { if (names.length() >= 2) { names.delete(names.length() - 2, names.length()); } - mBuilder.setContentTitle(notifications.size() - + " " - + mXmppConnectionService - .getString(R.string.unread_conversations)); + mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.x_unread_conversations, notifications.size())); + mBuilder.setTicker(mXmppConnectionService.getString(R.string.x_unread_conversations, notifications.size())); mBuilder.setContentText(names.toString()); mBuilder.setStyle(style); if (conversation != null) { @@ -638,8 +630,11 @@ public class NotificationService { CharSequence text = getMergedBodies(tmp); bigPictureStyle.setSummaryText(text); builder.setContentText(text); + builder.setTicker(text); } else { - builder.setContentText(UIHelper.getFileDescriptionString(mXmppConnectionService, message)); + final String description = UIHelper.getFileDescriptionString(mXmppConnectionService, message); + builder.setContentText(description); + builder.setTicker(description); } builder.setStyle(bigPictureStyle); } catch (final IOException e) { @@ -696,7 +691,9 @@ public class NotificationService { } else { if (messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) { builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); - builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(messages.size() - 1)).first); + final CharSequence preview = UIHelper.getMessagePreview(mXmppConnectionService, messages.get(messages.size() - 1)).first; + builder.setContentText(preview); + builder.setTicker(preview); builder.setNumber(messages.size()); } else { final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); @@ -714,8 +711,11 @@ public class NotificationService { styledString = new SpannableString(name + ": " + messages.get(0).getBody()); styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); builder.setContentText(styledString); + builder.setTicker(styledString); } else { - builder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count)); + final String text = mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count); + builder.setContentText(text); + builder.setTicker(text); } } } -- cgit v1.2.3