aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-25 20:13:51 +0100
committerlookshe <github@lookshe.org>2016-03-25 20:13:51 +0100
commit711ab9f2b1b625373a7046774c7b78e59f826589 (patch)
treeadbfec9c7f9cac33351b1b09c4f5057c6ef674b5 /src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
parentd25ab854dae2be0d5286d46b5038494d503dd367 (diff)
parent27c16b4b9acaad33b36145d63f6bfd7e04a3b3f1 (diff)
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
index 1bf95910..5a8bd3db 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
@@ -527,6 +527,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
final Message m = this.selectedMessage;
final Transferable t = m.getTransferable();
if (m.getType() != Message.TYPE_STATUS) {
+ final boolean treatAsFile = m.getType() != Message.TYPE_TEXT
+ && m.getType() != Message.TYPE_PRIVATE
+ && t == null;
activity.getMenuInflater().inflate(R.menu.message_context, menu);
menu.setHeaderTitle(R.string.message_options);
MenuItem copyText = menu.findItem(R.id.copy_text);
@@ -536,8 +539,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
MenuItem copyUrl = menu.findItem(R.id.copy_url);
MenuItem downloadFile = menu.findItem(R.id.download_file);
MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission);
- if ((m.getType() == Message.TYPE_TEXT || m.getType() == Message.TYPE_PRIVATE)
- && t == null
+ MenuItem deleteFile = menu.findItem(R.id.delete_file);
+ if (!treatAsFile
&& !GeoHelper.isGeoUri(m.getBody())
&& m.treatAsDownloadable() != Message.Decision.MUST) {
copyText.setVisible(true);
@@ -545,11 +548,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
retryDecryption.setVisible(true);
}
-
- if ((m.getType() != Message.TYPE_TEXT
- && m.getType() != Message.TYPE_PRIVATE
- && t == null)
- || (GeoHelper.isGeoUri(m.getBody()))) {
+ if (treatAsFile || (GeoHelper.isGeoUri(m.getBody()))) {
shareWith.setVisible(true);
}
if (m.getStatus() == Message.STATUS_SEND_FAILED) {
@@ -571,6 +570,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|| m.getStatus() == Message.STATUS_OFFERED))) {
cancelTransmission.setVisible(true);
}
+ if (treatAsFile) {
+ deleteFile.setVisible(true);
+ deleteFile.setTitle(activity.getString(R.string.delete_x_file,UIHelper.getFileDescriptionString(activity, m)));
+ }
}
}
@@ -601,6 +604,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case R.id.retry_decryption:
retryDecryption(selectedMessage);
return true;
+ case R.id.delete_file:
+ deleteFile(selectedMessage);
+ return true;
default:
return super.onContextItemSelected(item);
}
@@ -638,12 +644,20 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
}
+ private void deleteFile(Message message) {
+ if (FileBackend.deleteFile(message, activity.xmppConnectionService)) {
+ message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
+ activity.xmppConnectionService.updateConversationUi();
+ }
+ }
+
private void resendMessage(Message message) {
if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) {
DownloadableFile file = FileBackend.getFile(message);
if (!file.exists()) {
Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
+ activity.xmppConnectionService.updateConversationUi();
return;
}
}