aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java25
-rw-r--r--src/main/res/values/strings.xml1
3 files changed, 30 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index da788b43..8af342a7 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -44,6 +44,7 @@ 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.DownloadableFile;
import eu.siacs.conversations.entities.DownloadablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
@@ -421,6 +422,14 @@ public class ConversationFragment extends Fragment {
}
private void resendMessage(Message message) {
+ if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) {
+ DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
+ if (!file.exists()) {
+ Toast.makeText(activity,R.string.file_deleted,Toast.LENGTH_SHORT).show();
+ message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_DELETED));
+ return;
+ }
+ }
activity.xmppConnectionService.resendFailedMessages(message);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index c82f5be7..fc80c234 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -1,6 +1,8 @@
package eu.siacs.conversations.ui.adapter;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.graphics.Typeface;
import android.net.Uri;
import android.text.Spannable;
@@ -495,7 +497,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else if (d.getStatus() == Downloadable.STATUS_CHECKING) {
displayInfoMessage(viewHolder,activity.getString(R.string.checking_image));
} else if (d.getStatus() == Downloadable.STATUS_DELETED) {
- displayInfoMessage(viewHolder,activity.getString(R.string.image_file_deleted));
+ if (item.getType() == Message.TYPE_FILE) {
+ displayInfoMessage(viewHolder, activity.getString(R.string.file_deleted));
+ } else {
+ displayInfoMessage(viewHolder, activity.getString(R.string.image_file_deleted));
+ }
} else if (d.getStatus() == Downloadable.STATUS_OFFER) {
if (item.getType() == Message.TYPE_FILE) {
displayDownloadableMessage(viewHolder,item,activity.getString(R.string.download_file,d.getMimeType()));
@@ -558,10 +564,19 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
public void openDonwloadable(DownloadableFile file) {
- Log.d(Config.LOGTAG,"file "+file.getAbsolutePath());
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.fromFile(file), file.getMimeType());
- getContext().startActivity(intent);
+ if (!file.exists()) {
+ Toast.makeText(activity,R.string.file_deleted,Toast.LENGTH_SHORT).show();
+ return;
+ }
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
+ openIntent.setDataAndType(Uri.fromFile(file), file.getMimeType());
+ PackageManager manager = activity.getPackageManager();
+ List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
+ if (infos.size() > 0) {
+ getContext().startActivity(openIntent);
+ } else {
+ Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
+ }
}
public interface OnContactPictureClicked {
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index bf7d35a7..3d69e0f3 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -322,4 +322,5 @@
<string name="cancel_transmission">Cancel transmission</string>
<string name="file_transmission_failed">file transmission failed</string>
<string name="file_deleted">The file has been deleted</string>
+ <string name="no_application_found_to_open_file">No application found to open file</string>
</resources>