Use external image viewer

pull/178/head
M66B 5 years ago
parent 8d2d35550f
commit 82296dd31f

@ -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) {

Loading…
Cancel
Save