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.SendButtonAction;
|
||||||
import eu.siacs.conversations.ui.util.SendButtonTool;
|
import eu.siacs.conversations.ui.util.SendButtonTool;
|
||||||
import eu.siacs.conversations.ui.util.ShareUtil;
|
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.ui.widget.EditMessage;
|
||||||
import eu.siacs.conversations.utils.Compatibility;
|
import eu.siacs.conversations.utils.Compatibility;
|
||||||
import eu.siacs.conversations.utils.GeoHelper;
|
import eu.siacs.conversations.utils.GeoHelper;
|
||||||
|
@ -1135,7 +1136,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
if (showError) {
|
if (showError) {
|
||||||
showErrorMessage.setVisible(true);
|
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);
|
openWith.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1630,6 +1632,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
private void openWith(final Message message) {
|
private void openWith(final Message message) {
|
||||||
if (message.isGeoUri()) {
|
if (message.isGeoUri()) {
|
||||||
GeoHelper.view(getActivity(),message);
|
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);
|
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, ConversationsActivity.REQUEST_OPEN_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
||||||
if (!file.exists()) {
|
ViewUtil.view(activity, file);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showLocation(Message message) {
|
public void showLocation(Message message) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.entities.DownloadableFile;
|
||||||
import eu.siacs.conversations.persistance.FileBackend;
|
import eu.siacs.conversations.persistance.FileBackend;
|
||||||
|
|
||||||
public class ViewUtil {
|
public class ViewUtil {
|
||||||
|
@ -24,6 +25,18 @@ public class ViewUtil {
|
||||||
view(context, file, mime);
|
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) {
|
public static void view(Context context, File file, String mime) {
|
||||||
Intent openIntent = new Intent(Intent.ACTION_VIEW);
|
Intent openIntent = new Intent(Intent.ACTION_VIEW);
|
||||||
Uri uri;
|
Uri uri;
|
||||||
|
|
Loading…
Reference in a new issue