aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authorDaniel Gultsch <inputmice@siacs.eu>2015-01-02 14:27:49 +0100
committerDaniel Gultsch <inputmice@siacs.eu>2015-01-02 14:27:49 +0100
commit3df23a4f75263d17a4db95a9a4f8c26c0246962c (patch)
tree68fdc078020c095081cf90cf4690155a1b2ca4e8 /src/main/java/eu
parentbcd3be59ce78609e608f4a8f7a868be977fdb4bb (diff)
allow cancellation of waiting files
Diffstat (limited to 'src/main/java/eu')
-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);
}
}