extend open with to audio files
This commit is contained in:
parent
918b3223b3
commit
c5e35dc4b3
|
@ -100,6 +100,7 @@ import eu.siacs.conversations.ui.util.ScrollState;
|
|||
import eu.siacs.conversations.ui.util.SendButtonAction;
|
||||
import eu.siacs.conversations.ui.util.SendButtonTool;
|
||||
import eu.siacs.conversations.ui.util.ShareUtil;
|
||||
import eu.siacs.conversations.ui.util.ViewUtil;
|
||||
import eu.siacs.conversations.ui.widget.EditMessage;
|
||||
import eu.siacs.conversations.utils.Compatibility;
|
||||
import eu.siacs.conversations.utils.GeoHelper;
|
||||
|
@ -1135,7 +1136,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
if (showError) {
|
||||
showErrorMessage.setVisible(true);
|
||||
}
|
||||
if (m.isGeoUri() && GeoHelper.openInOsmAnd(getActivity(),m)) {
|
||||
final String mime = m.isFileOrImage() ? m.getMimeType() : null;
|
||||
if ((m.isGeoUri() && GeoHelper.openInOsmAnd(getActivity(),m)) || (mime != null && mime.startsWith("audio/"))) {
|
||||
openWith.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
@ -1630,6 +1632,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
private void openWith(final Message message) {
|
||||
if (message.isGeoUri()) {
|
||||
GeoHelper.view(getActivity(),message);
|
||||
} else {
|
||||
final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
||||
ViewUtil.view(activity, file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -898,16 +898,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
|||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, ConversationsActivity.REQUEST_OPEN_MESSAGE);
|
||||
return;
|
||||
}
|
||||
DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
||||
if (!file.exists()) {
|
||||
Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
String mime = file.getMimeType();
|
||||
if (mime == null) {
|
||||
mime = "*/*";
|
||||
}
|
||||
ViewUtil.view(activity, file, mime);
|
||||
final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
||||
ViewUtil.view(activity, file);
|
||||
}
|
||||
|
||||
public void showLocation(Message message) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
|||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.DownloadableFile;
|
||||
import eu.siacs.conversations.persistance.FileBackend;
|
||||
|
||||
public class ViewUtil {
|
||||
|
@ -24,6 +25,18 @@ public class ViewUtil {
|
|||
view(context, file, mime);
|
||||
}
|
||||
|
||||
public static void view (Context context, DownloadableFile file) {
|
||||
if (!file.exists()) {
|
||||
Toast.makeText(context, R.string.file_deleted, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
String mime = file.getMimeType();
|
||||
if (mime == null) {
|
||||
mime = "*/*";
|
||||
}
|
||||
view(context, file, mime);
|
||||
}
|
||||
|
||||
public static void view(Context context, File file, String mime) {
|
||||
Intent openIntent = new Intent(Intent.ACTION_VIEW);
|
||||
Uri uri;
|
||||
|
|
Loading…
Reference in a new issue