aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui/adapter
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-10-20 17:41:07 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-10-20 17:41:07 +0200
commitf4a33a007c777eaacd6d55048346b2a4be850ee5 (patch)
tree3cb2ea07cce40ed661fc2a76c70edadb4aa2a9ff /src/main/java/eu/siacs/conversations/ui/adapter
parent569b9f4e66bab9dc9481ca374289c07b9200bac7 (diff)
open unknown files with wildcard intent
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/adapter')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java23
1 files changed, 14 insertions, 9 deletions
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 a31adf187..d9fea8170 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -603,7 +603,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
Toast.LENGTH_SHORT).show();
}
} else if (message.treatAsDownloadable() != Message.Decision.NEVER) {
- activity.xmppConnectionService.getHttpConnectionManager().createNewDownloadConnection(message,true);
+ activity.xmppConnectionService.getHttpConnectionManager().createNewDownloadConnection(message, true);
}
}
@@ -614,16 +614,21 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return;
}
Intent openIntent = new Intent(Intent.ACTION_VIEW);
- openIntent.setDataAndType(Uri.fromFile(file), file.getMimeType());
+ String mime = file.getMimeType();
+ if (mime == null) {
+ mime = "*/*";
+ }
+ openIntent.setDataAndType(Uri.fromFile(file), mime);
PackageManager manager = activity.getPackageManager();
List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
- if (infos.size() > 0) {
- try {
- getContext().startActivity(openIntent);
- return;
- } catch (ActivityNotFoundException e) {
- //ignored
- }
+ if (infos.size() == 0) {
+ openIntent.setDataAndType(Uri.fromFile(file),"*/*");
+ }
+ try {
+ getContext().startActivity(openIntent);
+ return;
+ } catch (ActivityNotFoundException e) {
+ //ignored
}
Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
}