Replace "cid:" URI with "content://" URI when viewing/saving inline image
Fix #818
This commit is contained in:
parent
952da74b0e
commit
d84ce23ecf
1 changed files with 30 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue