aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-15 12:37:09 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-15 15:34:12 +0100
commitcc4f3702a83b5f4d4d57aa66bf50c5ba3b96e72b (patch)
tree26b9bab0f9b275eeff353de203a648be11bf7936 /src/main/java/eu/siacs/conversations/ui
parent4ab558715cc279515894d8ad28053716d3d61ad2 (diff)
made file transfers cancelable
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 63d740c3..e15a6bbc 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -43,6 +43,7 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;
@@ -343,6 +344,7 @@ public class ConversationFragment extends Fragment {
MenuItem sendAgain = menu.findItem(R.id.send_again);
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) {
copyText.setVisible(false);
@@ -359,12 +361,15 @@ public class ConversationFragment extends Fragment {
|| this.selectedMessage.getImageParams().url == null) {
copyUrl.setVisible(false);
}
-
if (this.selectedMessage.getType() != Message.TYPE_TEXT
|| this.selectedMessage.getDownloadable() != null
|| !this.selectedMessage.bodyContainsDownloadable()) {
downloadImage.setVisible(false);
}
+ if (this.selectedMessage.getDownloadable() == null
+ || this.selectedMessage.getDownloadable().getStatus() == Downloadable.STATUS_DELETED) {
+ cancelTransmission.setVisible(false);
+ }
}
}
@@ -386,6 +391,9 @@ public class ConversationFragment extends Fragment {
case R.id.download_image:
downloadImage(selectedMessage);
return true;
+ case R.id.cancel_transmission:
+ cancelTransmission(selectedMessage);
+ return true;
default:
return super.onContextItemSelected(item);
}
@@ -428,6 +436,13 @@ public class ConversationFragment extends Fragment {
.createNewConnection(message);
}
+ private void cancelTransmission(Message message) {
+ Downloadable downloadable = message.getDownloadable();
+ if (downloadable!=null) {
+ downloadable.cancel();
+ }
+ }
+
protected void privateMessageWith(final Jid counterpart) {
this.mEditMessage.setText("");
this.conversation.setNextCounterpart(counterpart);