aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-25 22:41:43 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-25 22:41:43 +0100
commitda4e384258f4e07e441872726094c7ffe691160e (patch)
tree97b43a77ff317b2d4f76d0eee468f830cc0f3827
parent55c83afb676e5d4c5d2fe58132dceeefa7e9ee71 (diff)
extend open with to audio files
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java12
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/ViewUtil.java13
3 files changed, 21 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 55f6d7334..d7205506d 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -107,6 +107,7 @@ import de.pixart.messenger.ui.util.ScrollState;
import de.pixart.messenger.ui.util.SendButtonAction;
import de.pixart.messenger.ui.util.SendButtonTool;
import de.pixart.messenger.ui.util.ShareUtil;
+import de.pixart.messenger.ui.util.ViewUtil;
import de.pixart.messenger.ui.widget.EditMessage;
import de.pixart.messenger.utils.Compatibility;
import de.pixart.messenger.utils.GeoHelper;
@@ -1359,7 +1360,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);
}
}
@@ -1856,6 +1858,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);
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index f579df82f..9d7624e79 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -1119,16 +1119,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) {
diff --git a/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java b/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java
index 07e25e31d..db729f0e4 100644
--- a/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java
+++ b/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java
@@ -14,6 +14,7 @@ import java.util.List;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
+import de.pixart.messenger.entities.DownloadableFile;
import de.pixart.messenger.persistance.FileBackend;
import de.pixart.messenger.ui.MediaViewerActivity;
@@ -25,6 +26,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) {
Uri uri;
try {