aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
diff options
context:
space:
mode:
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;
}
}