aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java4
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java38
2 files changed, 23 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 38e88fa4..b5a1897d 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -518,6 +518,10 @@ public class Message extends AbstractEntity {
this.mPreviousMessage = null;
}
+ public boolean isFileOrImage() {
+ return type == TYPE_FILE || type == TYPE_IMAGE;
+ }
+
public class ImageParams {
public URL url;
public long size = 0;
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 98f70728..d73af194 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -396,7 +396,8 @@ public class ConversationFragment extends Fragment {
}
private void populateContextMenu(ContextMenu menu) {
- if (this.selectedMessage.getType() != Message.TYPE_STATUS) {
+ final Message m = this.selectedMessage;
+ if (m.getType() != Message.TYPE_STATUS) {
activity.getMenuInflater().inflate(R.menu.message_context, menu);
menu.setHeaderTitle(R.string.message_options);
MenuItem copyText = menu.findItem(R.id.copy_text);
@@ -405,31 +406,28 @@ public class ConversationFragment extends Fragment {
MenuItem copyUrl = menu.findItem(R.id.copy_url);
MenuItem downloadImage = menu.findItem(R.id.download_image);
MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission);
- if (this.selectedMessage.getType() != Message.TYPE_TEXT
- || this.selectedMessage.getDownloadable() != null) {
+ if (m.getType() != Message.TYPE_TEXT || m.getDownloadable() != null) {
copyText.setVisible(false);
- }
- if (this.selectedMessage.getType() != Message.TYPE_IMAGE
- || this.selectedMessage.getDownloadable() != null) {
+ }
+ if (m.getType() != Message.TYPE_IMAGE || m.getDownloadable() != null) {
shareImage.setVisible(false);
- }
- if (this.selectedMessage.getStatus() != Message.STATUS_SEND_FAILED) {
+ }
+ if (m.getStatus() != Message.STATUS_SEND_FAILED) {
sendAgain.setVisible(false);
}
- if ((this.selectedMessage.getType() != Message.TYPE_IMAGE && this.selectedMessage
- .getDownloadable() == null)
- || this.selectedMessage.getImageParams().url == null) {
+ if ((m.getType() != Message.TYPE_IMAGE && m.getDownloadable() == null)
+ || m.getImageParams().url == null) {
copyUrl.setVisible(false);
- }
- if (this.selectedMessage.getType() != Message.TYPE_TEXT
- || this.selectedMessage.getDownloadable() != null
- || !this.selectedMessage.bodyContainsDownloadable()) {
+ }
+ if (m.getType() != Message.TYPE_TEXT
+ || m.getDownloadable() != null
+ || !m.bodyContainsDownloadable()) {
downloadImage.setVisible(false);
- }
- if (this.selectedMessage.getDownloadable() == null
- || this.selectedMessage.getDownloadable() instanceof DownloadablePlaceholder) {
+ }
+ if (!((m.getDownloadable() != null && !(m.getDownloadable() instanceof DownloadablePlaceholder))
+ || (m.isFileOrImage() && m.getStatus() == Message.STATUS_WAITING))) {
cancelTransmission.setVisible(false);
- }
+ }
}
}
@@ -508,6 +506,8 @@ public class ConversationFragment extends Fragment {
Downloadable downloadable = message.getDownloadable();
if (downloadable!=null) {
downloadable.cancel();
+ } else {
+ activity.xmppConnectionService.markMessage(message,Message.STATUS_SEND_FAILED);
}
}