Replace "cid:" URI with "content://" URI when viewing/saving inline image

Fix #818
This commit is contained in:
cketti 2015-09-27 08:10:46 +02:00
parent 952da74b0e
commit d84ce23ecf

View file

@ -163,7 +163,11 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
}
case HitTestResult.IMAGE_TYPE:
case HitTestResult.SRC_IMAGE_ANCHOR_TYPE: {
final String url = result.getExtra();
final String url = getUriForExternalAccess(result.getExtra());
if (url == null) {
return;
}
final boolean externalImage = url.startsWith("http");
OnMenuItemClickListener listener = new OnMenuItemClickListener() {
@Override
@ -309,6 +313,31 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
}
}
private String getUriForExternalAccess(String url) {
if (!url.startsWith("cid:")) {
return url;
}
String cid = Uri.parse(url).getSchemeSpecificPart();
AttachmentViewInfo attachment = getAttachmentByContentId(cid);
if (attachment == null) {
return null;
}
return attachment.uri.toString();
}
private AttachmentViewInfo getAttachmentByContentId(String cid) {
for (AttachmentViewInfo attachment : attachments.keySet()) {
if (cid.equals(attachment.part.getContentId())) {
return attachment;
}
}
return null;
}
private void startActivityIfAvailable(Context context, Intent intent) {
try {
context.startActivity(intent);