mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 09:42:17 -05:00
open unknown files with wildcard intent
This commit is contained in:
parent
569b9f4e66
commit
f4a33a007c
@ -541,7 +541,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||||||
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
String mime = message.getMimeType();
|
String mime = message.getMimeType();
|
||||||
if (mime == null) {
|
if (mime == null) {
|
||||||
mime = "image/webp";
|
mime = "*/*";
|
||||||
}
|
}
|
||||||
shareIntent.setType(mime);
|
shareIntent.setType(mime);
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
} else if (message.treatAsDownloadable() != Message.Decision.NEVER) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
Intent openIntent = new Intent(Intent.ACTION_VIEW);
|
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();
|
PackageManager manager = activity.getPackageManager();
|
||||||
List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
|
List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
|
||||||
if (infos.size() > 0) {
|
if (infos.size() == 0) {
|
||||||
try {
|
openIntent.setDataAndType(Uri.fromFile(file),"*/*");
|
||||||
getContext().startActivity(openIntent);
|
}
|
||||||
return;
|
try {
|
||||||
} catch (ActivityNotFoundException e) {
|
getContext().startActivity(openIntent);
|
||||||
//ignored
|
return;
|
||||||
}
|
} catch (ActivityNotFoundException e) {
|
||||||
|
//ignored
|
||||||
}
|
}
|
||||||
Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user