Use external image viewer

This commit is contained in:
M66B 2020-05-23 17:30:23 +02:00
parent 8d2d35550f
commit 82296dd31f
1 changed files with 34 additions and 4 deletions

View File

@ -3851,17 +3851,47 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return true;
}
private void onOpenImage(long id, String source) {
private void onOpenImage(long id, @NonNull String source) {
Log.i("Viewing image source=" + source);
Uri uri = Uri.parse(source);
String scheme = uri.getScheme();
Bundle args = new Bundle();
args.putLong("id", id);
args.putString("source", source);
args.putInt("zoom", zoom);
FragmentDialogImage fragment = new FragmentDialogImage();
fragment.setArguments(args);
fragment.show(parentFragment.getParentFragmentManager(), "view:image");
if ("cid".equals(scheme)) {
new SimpleTask<EntityAttachment>() {
@Override
protected EntityAttachment onExecute(Context context, Bundle args) {
long id = args.getLong("id");
String source = args.getString("source");
DB db = DB.getInstance(context);
String cid = "<" + source.substring(4) + ">";
return db.attachment().getAttachment(id, cid);
}
@Override
protected void onExecuted(Bundle args, EntityAttachment attachment) {
if (attachment != null)
Helper.share(context, attachment.getFile(context), attachment.getMimeType(), attachment.name);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "view:cid");
} else if ("http".equals(scheme) || "https".equals(scheme))
Helper.view(context, uri, false);
else {
FragmentDialogImage fragment = new FragmentDialogImage();
fragment.setArguments(args);
fragment.show(parentFragment.getParentFragmentManager(), "view:image");
}
}
private void onMenuUnseen(final TupleMessageEx message) {