diff options
author | Andrew Sapperstein <asapperstein@google.com> | 2013-12-17 18:27:55 -0800 |
---|---|---|
committer | Andrew Sapperstein <asapperstein@google.com> | 2014-01-07 15:17:11 -0800 |
commit | 8ec43e877a9c1925514f066655984e21fbd255e8 (patch) | |
tree | dd831a590b39360b7cfc60efa595a3318a20c1ff /assets | |
parent | 57559cd46a7f4f22c06e95e5e8d0ad507c02ecfb (diff) | |
download | android_packages_apps_UnifiedEmail-8ec43e877a9c1925514f066655984e21fbd255e8.tar.gz android_packages_apps_UnifiedEmail-8ec43e877a9c1925514f066655984e21fbd255e8.tar.bz2 android_packages_apps_UnifiedEmail-8ec43e877a9c1925514f066655984e21fbd255e8.zip |
View inline images in photo viewer. b/5555553.
Uses the existing javascript image src rewriting
step to build a mapping of urls to message ids.
This mapping is passed into the InlineAttachmentViewIntentBuilder
so that it can use this information along with the
conversation id and account name to build attachment
and attachment list uris so that a photo viewer open
intent can be created.
Additionally, SecureConversationViewController will need a different
mechanism for this UI to work in Email/the eml viewer.
Change-Id: If14800348fe2191d0633bf768b8cb4e9746f6578
Diffstat (limited to 'assets')
-rw-r--r-- | assets/script.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/assets/script.js b/assets/script.js index 4667addf5..79987d353 100644 --- a/assets/script.js +++ b/assets/script.js @@ -447,6 +447,9 @@ function hideUnsafeImages(msgContentDivs) { var msgContentDiv, image; var images; var showImages; + var k = 0; + var urls = new Array(); + var messageIds = new Array(); for (i = 0, msgContentCount = msgContentDivs.length; i < msgContentCount; i++) { msgContentDiv = msgContentDivs[i]; showImages = msgContentDiv.classList.contains("mail-show-images"); @@ -454,7 +457,12 @@ function hideUnsafeImages(msgContentDivs) { images = msgContentDiv.getElementsByTagName("img"); for (j = 0, imgCount = images.length; j < imgCount; j++) { image = images[j]; - rewriteRelativeImageSrc(image); + var src = rewriteRelativeImageSrc(image); + if (src) { + urls[k] = src; + messageIds[k] = msgContentDiv.parentNode.id; + k++; + } attachImageLoadListener(image); // TODO: handle inline image attachments for all supported protocols if (!showImages) { @@ -462,11 +470,14 @@ function hideUnsafeImages(msgContentDivs) { } } } + + window.mail.onInlineAttachmentsParsed(urls, messageIds); } /** - * Changes relative paths to absolute path by pre-pending the account uri + * Changes relative paths to absolute path by pre-pending the account uri. * @param {Element} imgElement Image for which the src path will be updated. + * @returns the rewritten image src string or null if the imgElement was not rewritten. */ function rewriteRelativeImageSrc(imgElement) { var src = imgElement.src; @@ -476,7 +487,10 @@ function rewriteRelativeImageSrc(imgElement) { // The conversation specifies a different base uri than the document src = CONVERSATION_BASE_URI + src.substring(DOC_BASE_URI.length); imgElement.src = src; + return src; } + + return null; }; |