Loading k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageContainerView.java +24 −12 Original line number Diff line number Diff line Loading @@ -73,9 +73,11 @@ public class MessageContainerView extends LinearLayout implements OnClickListene private View mAttachmentsContainer; private SavedState mSavedState; private ClipboardManager mClipboardManager; private String mText; private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>(); private String currentHtmlText; private AttachmentResolver currentAttachmentResolver; @Override public void onFinishInflate() { Loading Loading @@ -379,7 +381,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene public void showPictures() { setLoadPictures(true); displayHtmlContentWithInlineAttachments(mText, null); refreshDisplayedContent(); } public void enableAttachmentButtons() { Loading Loading @@ -424,9 +426,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene mSavedState = null; } mText = getTextToDisplay(messageViewContainer); if (mText != null && lookForImages) { if (Utility.hasExternalImages(mText) && !isShowingPictures()) { String textToDisplay = getTextToDisplay(messageViewContainer); if (textToDisplay != null && lookForImages) { if (Utility.hasExternalImages(textToDisplay) && !isShowingPictures()) { if (automaticallyLoadPictures) { setLoadPictures(true); } else { Loading @@ -447,14 +449,11 @@ public class MessageContainerView extends LinearLayout implements OnClickListene mSidebar.setVisibility(View.GONE); } String text; if (mText != null) { text = mText; } else { text = wrapStatusMessage(getContext().getString(R.string.webview_empty_message)); if (textToDisplay == null) { textToDisplay = wrapStatusMessage(getContext().getString(R.string.webview_empty_message)); } displayHtmlContentWithInlineAttachments(text, messageViewContainer.attachmentResolver); displayHtmlContentWithInlineAttachments(textToDisplay, messageViewContainer.attachmentResolver); } private String getTextToDisplay(MessageViewContainer messageViewContainer) { Loading Loading @@ -486,9 +485,19 @@ public class MessageContainerView extends LinearLayout implements OnClickListene } private void displayHtmlContentWithInlineAttachments(String htmlText, AttachmentResolver attachmentResolver) { currentHtmlText = htmlText; currentAttachmentResolver = attachmentResolver; mMessageContentView.displayHtmlContentWithInlineAttachments(htmlText, attachmentResolver); } private void refreshDisplayedContent() { mMessageContentView.displayHtmlContentWithInlineAttachments(currentHtmlText, currentAttachmentResolver); } private void clearDisplayedContent() { mMessageContentView.displayHtmlContentWithInlineAttachments("", null); } public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException { for (AttachmentViewInfo attachment : messageContainer.attachments) { ViewGroup parent = attachment.firstClassAttachment ? mAttachments : mHiddenAttachments; Loading Loading @@ -518,6 +527,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene mAttachments.removeAllViews(); mHiddenAttachments.removeAllViews(); currentHtmlText = null; currentAttachmentResolver = null; /* * Clear the WebView content * Loading @@ -525,7 +537,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene * its size because the button to download the complete message was previously shown and * is now hidden. */ displayHtmlContentWithInlineAttachments("", null); clearDisplayedContent(); } @Override Loading k9mail/src/main/java/com/fsck/k9/view/K9WebViewClient.java +8 −2 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.net.Uri; import android.os.Build; import android.os.Build.VERSION_CODES; import android.provider.Browser; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.Log; import android.webkit.WebResourceRequest; Loading @@ -32,10 +33,11 @@ abstract class K9WebViewClient extends WebViewClient { private static final WebResourceResponse RESULT_DUMMY_RESPONSE = new WebResourceResponse(null, null, null); @Nullable private final AttachmentResolver attachmentResolver; public static K9WebViewClient newInstance(AttachmentResolver attachmentResolver) { public static K9WebViewClient newInstance(@Nullable AttachmentResolver attachmentResolver) { if (Build.VERSION.SDK_INT < 21) { return new PreLollipopWebViewClient(attachmentResolver); } Loading @@ -44,7 +46,7 @@ abstract class K9WebViewClient extends WebViewClient { } private K9WebViewClient(AttachmentResolver attachmentResolver) { private K9WebViewClient(@Nullable AttachmentResolver attachmentResolver) { this.attachmentResolver = attachmentResolver; } Loading Loading @@ -85,6 +87,10 @@ abstract class K9WebViewClient extends WebViewClient { return RESULT_DO_NOT_INTERCEPT; } if (attachmentResolver == null) { return RESULT_DUMMY_RESPONSE; } String cid = uri.getSchemeSpecificPart(); if (TextUtils.isEmpty(cid)) { return RESULT_DUMMY_RESPONSE; Loading k9mail/src/main/java/com/fsck/k9/view/MessageWebView.java +6 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ package com.fsck.k9.view; import android.content.Context; import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; Loading Loading @@ -104,17 +106,18 @@ public class MessageWebView extends RigidWebView { getSettings().setDisplayZoomControls(!supportsMultiTouch); } public void displayHtmlContentWithInlineAttachments(String htmlText, AttachmentResolver attachmentResolver) { public void displayHtmlContentWithInlineAttachments(@NonNull String htmlText, @Nullable AttachmentResolver attachmentResolver) { setAttachmentResolverWebViewClient(attachmentResolver); setHtmlContent(htmlText); } private void setAttachmentResolverWebViewClient(AttachmentResolver attachmentResolver) { private void setAttachmentResolverWebViewClient(@Nullable AttachmentResolver attachmentResolver) { K9WebViewClient webViewClient = K9WebViewClient.newInstance(attachmentResolver); setWebViewClient(webViewClient); } private void setHtmlContent(String htmlText) { private void setHtmlContent(@NonNull String htmlText) { // Include a meta tag so the WebView will not use a fixed viewport width of 980 px String content = "<html><head><meta name=\"viewport\" content=\"width=device-width\"/>"; if (K9.getK9MessageViewTheme() == K9.Theme.DARK) { Loading Loading
k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageContainerView.java +24 −12 Original line number Diff line number Diff line Loading @@ -73,9 +73,11 @@ public class MessageContainerView extends LinearLayout implements OnClickListene private View mAttachmentsContainer; private SavedState mSavedState; private ClipboardManager mClipboardManager; private String mText; private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>(); private String currentHtmlText; private AttachmentResolver currentAttachmentResolver; @Override public void onFinishInflate() { Loading Loading @@ -379,7 +381,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene public void showPictures() { setLoadPictures(true); displayHtmlContentWithInlineAttachments(mText, null); refreshDisplayedContent(); } public void enableAttachmentButtons() { Loading Loading @@ -424,9 +426,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene mSavedState = null; } mText = getTextToDisplay(messageViewContainer); if (mText != null && lookForImages) { if (Utility.hasExternalImages(mText) && !isShowingPictures()) { String textToDisplay = getTextToDisplay(messageViewContainer); if (textToDisplay != null && lookForImages) { if (Utility.hasExternalImages(textToDisplay) && !isShowingPictures()) { if (automaticallyLoadPictures) { setLoadPictures(true); } else { Loading @@ -447,14 +449,11 @@ public class MessageContainerView extends LinearLayout implements OnClickListene mSidebar.setVisibility(View.GONE); } String text; if (mText != null) { text = mText; } else { text = wrapStatusMessage(getContext().getString(R.string.webview_empty_message)); if (textToDisplay == null) { textToDisplay = wrapStatusMessage(getContext().getString(R.string.webview_empty_message)); } displayHtmlContentWithInlineAttachments(text, messageViewContainer.attachmentResolver); displayHtmlContentWithInlineAttachments(textToDisplay, messageViewContainer.attachmentResolver); } private String getTextToDisplay(MessageViewContainer messageViewContainer) { Loading Loading @@ -486,9 +485,19 @@ public class MessageContainerView extends LinearLayout implements OnClickListene } private void displayHtmlContentWithInlineAttachments(String htmlText, AttachmentResolver attachmentResolver) { currentHtmlText = htmlText; currentAttachmentResolver = attachmentResolver; mMessageContentView.displayHtmlContentWithInlineAttachments(htmlText, attachmentResolver); } private void refreshDisplayedContent() { mMessageContentView.displayHtmlContentWithInlineAttachments(currentHtmlText, currentAttachmentResolver); } private void clearDisplayedContent() { mMessageContentView.displayHtmlContentWithInlineAttachments("", null); } public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException { for (AttachmentViewInfo attachment : messageContainer.attachments) { ViewGroup parent = attachment.firstClassAttachment ? mAttachments : mHiddenAttachments; Loading Loading @@ -518,6 +527,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene mAttachments.removeAllViews(); mHiddenAttachments.removeAllViews(); currentHtmlText = null; currentAttachmentResolver = null; /* * Clear the WebView content * Loading @@ -525,7 +537,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene * its size because the button to download the complete message was previously shown and * is now hidden. */ displayHtmlContentWithInlineAttachments("", null); clearDisplayedContent(); } @Override Loading
k9mail/src/main/java/com/fsck/k9/view/K9WebViewClient.java +8 −2 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.net.Uri; import android.os.Build; import android.os.Build.VERSION_CODES; import android.provider.Browser; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.Log; import android.webkit.WebResourceRequest; Loading @@ -32,10 +33,11 @@ abstract class K9WebViewClient extends WebViewClient { private static final WebResourceResponse RESULT_DUMMY_RESPONSE = new WebResourceResponse(null, null, null); @Nullable private final AttachmentResolver attachmentResolver; public static K9WebViewClient newInstance(AttachmentResolver attachmentResolver) { public static K9WebViewClient newInstance(@Nullable AttachmentResolver attachmentResolver) { if (Build.VERSION.SDK_INT < 21) { return new PreLollipopWebViewClient(attachmentResolver); } Loading @@ -44,7 +46,7 @@ abstract class K9WebViewClient extends WebViewClient { } private K9WebViewClient(AttachmentResolver attachmentResolver) { private K9WebViewClient(@Nullable AttachmentResolver attachmentResolver) { this.attachmentResolver = attachmentResolver; } Loading Loading @@ -85,6 +87,10 @@ abstract class K9WebViewClient extends WebViewClient { return RESULT_DO_NOT_INTERCEPT; } if (attachmentResolver == null) { return RESULT_DUMMY_RESPONSE; } String cid = uri.getSchemeSpecificPart(); if (TextUtils.isEmpty(cid)) { return RESULT_DUMMY_RESPONSE; Loading
k9mail/src/main/java/com/fsck/k9/view/MessageWebView.java +6 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ package com.fsck.k9.view; import android.content.Context; import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; Loading Loading @@ -104,17 +106,18 @@ public class MessageWebView extends RigidWebView { getSettings().setDisplayZoomControls(!supportsMultiTouch); } public void displayHtmlContentWithInlineAttachments(String htmlText, AttachmentResolver attachmentResolver) { public void displayHtmlContentWithInlineAttachments(@NonNull String htmlText, @Nullable AttachmentResolver attachmentResolver) { setAttachmentResolverWebViewClient(attachmentResolver); setHtmlContent(htmlText); } private void setAttachmentResolverWebViewClient(AttachmentResolver attachmentResolver) { private void setAttachmentResolverWebViewClient(@Nullable AttachmentResolver attachmentResolver) { K9WebViewClient webViewClient = K9WebViewClient.newInstance(attachmentResolver); setWebViewClient(webViewClient); } private void setHtmlContent(String htmlText) { private void setHtmlContent(@NonNull String htmlText) { // Include a meta tag so the WebView will not use a fixed viewport width of 980 px String content = "<html><head><meta name=\"viewport\" content=\"width=device-width\"/>"; if (K9.getK9MessageViewTheme() == K9.Theme.DARK) { Loading