diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-07-25 14:15:47 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-07-25 19:50:19 +0200 |
commit | e388c64361a3dad44442dd1f8633e452302188e8 (patch) | |
tree | bfc9b12da582a92af1296e04ac032ee8a3263a22 /src/main/java/eu/siacs/conversations/services/NotificationService.java | |
parent | 3fbee39579b4b2232fc98d50f6b16ec4f9f33022 (diff) |
refactored how view intents are handled
processing view intents before saved instance caused troubles when the activity was destroyed
fixes #1969
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index cef240f5f..dd708731c 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -381,8 +381,10 @@ public class NotificationService { private Message getFirstDownloadableMessage(final Iterable<Message> messages) { for (final Message message : messages) { - if ((message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) && - message.getTransferable() != null) { + if (message.getTransferable() != null + && (message.getType() == Message.TYPE_FILE + || message.getType() == Message.TYPE_IMAGE + || message.treatAsDownloadable() != Message.Decision.NEVER)) { return message; } } @@ -420,28 +422,23 @@ public class NotificationService { } private PendingIntent createContentIntent(final String conversationUuid, final String downloadMessageUuid) { - final TaskStackBuilder stackBuilder = TaskStackBuilder - .create(mXmppConnectionService); - stackBuilder.addParentStack(ConversationActivity.class); - - final Intent viewConversationIntent = new Intent(mXmppConnectionService, - ConversationActivity.class); - if (downloadMessageUuid != null) { - viewConversationIntent.setAction(ConversationActivity.ACTION_DOWNLOAD); - } else { - viewConversationIntent.setAction(Intent.ACTION_VIEW); - } + final Intent viewConversationIntent = new Intent(mXmppConnectionService,ConversationActivity.class); + viewConversationIntent.setAction(ConversationActivity.ACTION_VIEW_CONVERSATION); if (conversationUuid != null) { viewConversationIntent.putExtra(ConversationActivity.CONVERSATION, conversationUuid); - viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION); } if (downloadMessageUuid != null) { - viewConversationIntent.putExtra(ConversationActivity.MESSAGE, downloadMessageUuid); + viewConversationIntent.putExtra(ConversationActivity.EXTRA_DOWNLOAD_UUID, downloadMessageUuid); + return PendingIntent.getActivity(mXmppConnectionService, + 57, + viewConversationIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + } else { + return PendingIntent.getActivity(mXmppConnectionService, + 58, + viewConversationIntent, + PendingIntent.FLAG_UPDATE_CURRENT); } - - stackBuilder.addNextIntent(viewConversationIntent); - - return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); } private PendingIntent createDownloadIntent(final Message message) { |