diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-12 16:09:39 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-12 16:09:39 +0100 |
commit | 77e4e1c2acfffcb64d0538c00b087462d15a4bbf (patch) | |
tree | f8c2ac3f18e9728c576c2836def9ebcf039583c6 /src/main/java/eu/siacs/conversations/services/NotificationService.java | |
parent | 50c8065015352db57eacd2551a080b91fc507b35 (diff) |
reworked message preview / message meta information (ie file offered, received * file)
fixed #837
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 594b356f9..961428c59 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -40,6 +40,7 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.ManageAccountActivity; import eu.siacs.conversations.ui.TimePreference; +import eu.siacs.conversations.utils.UIHelper; public class NotificationService { @@ -210,7 +211,7 @@ public class NotificationService { conversation = messages.get(0).getConversation(); String name = conversation.getName(); style.addLine(Html.fromHtml("<b>" + name + "</b> " - + getReadableBody(messages.get(0)))); + + UIHelper.getMessagePreview(mXmppConnectionService,messages.get(0)).first)); names.append(name); names.append(", "); } @@ -268,7 +269,7 @@ public class NotificationService { bigPictureStyle.bigPicture(bitmap); if (tmp.size() > 0) { bigPictureStyle.setSummaryText(getMergedBodies(tmp)); - builder.setContentText(getReadableBody(tmp.get(0))); + builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService,tmp.get(0)).first); } else { builder.setContentText(mXmppConnectionService.getString(R.string.image_file)); } @@ -280,11 +281,10 @@ public class NotificationService { private void modifyForTextOnly(final Builder builder, final ArrayList<Message> messages, final boolean notify) { - builder.setStyle(new NotificationCompat.BigTextStyle() - .bigText(getMergedBodies(messages))); - builder.setContentText(getReadableBody(messages.get(0))); + builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); + builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService,messages.get(0)).first); if (notify) { - builder.setTicker(getReadableBody(messages.get(messages.size() - 1))); + builder.setTicker(UIHelper.getMessagePreview(mXmppConnectionService,messages.get(messages.size() - 1)).first); } } @@ -302,7 +302,7 @@ public class NotificationService { private String getMergedBodies(final ArrayList<Message> messages) { final StringBuilder text = new StringBuilder(); for (int i = 0; i < messages.size(); ++i) { - text.append(getReadableBody(messages.get(i))); + text.append(UIHelper.getMessagePreview(mXmppConnectionService,messages.get(i)).first); if (i != messages.size() - 1) { text.append("\n"); } @@ -310,33 +310,6 @@ public class NotificationService { return text.toString(); } - private String getReadableBody(final Message message) { - if (message.getDownloadable() != null - && (message.getDownloadable().getStatus() == Downloadable.STATUS_OFFER || message - .getDownloadable().getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE)) { - if (message.getType() == Message.TYPE_FILE) { - return mXmppConnectionService.getString(R.string.file_offered_for_download); - } else { - return mXmppConnectionService.getText( - R.string.image_offered_for_download).toString(); - } - } else if (message.getEncryption() == Message.ENCRYPTION_PGP) { - return mXmppConnectionService.getText( - R.string.encrypted_message_received).toString(); - } else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { - return mXmppConnectionService.getText(R.string.decryption_failed) - .toString(); - } else if (message.getType() == Message.TYPE_FILE) { - DownloadableFile file = mXmppConnectionService.getFileBackend().getFile(message); - return mXmppConnectionService.getString(R.string.file,file.getMimeType()); - } else if (message.getType() == Message.TYPE_IMAGE) { - return mXmppConnectionService.getText(R.string.image_file) - .toString(); - } else { - return message.getBody().trim(); - } - } - private PendingIntent createContentIntent(final String conversationUuid) { final TaskStackBuilder stackBuilder = TaskStackBuilder .create(mXmppConnectionService); |