mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-04 16:45:09 -05:00
Use Part from MessageViewContainer for K9WebViewClient
Now K9WebViewClient can find encrypted attachments referenced by Content-ID.
This commit is contained in:
parent
cadac6dd89
commit
ee1180e34c
@ -35,7 +35,6 @@ import com.fsck.k9.R;
|
||||
import com.fsck.k9.helper.ClipboardManager;
|
||||
import com.fsck.k9.helper.Contacts;
|
||||
import com.fsck.k9.mail.Address;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mailstore.AttachmentViewInfo;
|
||||
import com.fsck.k9.mailstore.MessageViewInfo.MessageViewContainer;
|
||||
@ -424,11 +423,10 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessageViewContainer(Message message, MessageViewContainer messageViewContainer)
|
||||
throws MessagingException {
|
||||
public void setMessageViewContainer(MessageViewContainer messageViewContainer) throws MessagingException {
|
||||
resetView();
|
||||
|
||||
WebViewClient webViewClient = K9WebViewClient.newInstance(message);
|
||||
WebViewClient webViewClient = K9WebViewClient.newInstance(messageViewContainer.rootPart);
|
||||
mMessageContentView.setWebViewClient(webViewClient);
|
||||
|
||||
// Save the text so we can reset the WebView when the user clicks the "Show pictures" button
|
||||
|
@ -65,12 +65,11 @@ public class MessageTopView extends LinearLayout {
|
||||
throws MessagingException {
|
||||
resetView();
|
||||
|
||||
Message message = messageViewInfo.message;
|
||||
for (MessageViewContainer container : messageViewInfo.containers) {
|
||||
MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null);
|
||||
view.initialize(fragment, attachmentCallback, openPgpHeaderViewCallback,
|
||||
!Account.NO_OPENPGP_PROVIDER.equals(account.getOpenPgpProvider()));
|
||||
view.setMessageViewContainer(message, container);
|
||||
view.setMessageViewContainer(container);
|
||||
|
||||
containerViews.addView(view);
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import android.webkit.WebViewClient;
|
||||
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.Multipart;
|
||||
import com.fsck.k9.mail.Part;
|
||||
import com.fsck.k9.mailstore.AttachmentViewInfo;
|
||||
@ -34,19 +33,19 @@ public abstract class K9WebViewClient extends WebViewClient {
|
||||
private static final WebResourceResponse RESULT_DO_NOT_INTERCEPT = null;
|
||||
private static final WebResourceResponse RESULT_DUMMY_RESPONSE = new WebResourceResponse(null, null, null);
|
||||
|
||||
public static WebViewClient newInstance(Message message) {
|
||||
public static WebViewClient newInstance(Part part) {
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
return new PreLollipopWebViewClient(message);
|
||||
return new PreLollipopWebViewClient(part);
|
||||
}
|
||||
|
||||
return new LollipopWebViewClient(message);
|
||||
return new LollipopWebViewClient(part);
|
||||
}
|
||||
|
||||
|
||||
private final Message message;
|
||||
private final Part part;
|
||||
|
||||
private K9WebViewClient(Message message) {
|
||||
this.message = message;
|
||||
private K9WebViewClient(Part part) {
|
||||
this.part = part;
|
||||
}
|
||||
|
||||
protected WebResourceResponse shouldInterceptRequest(WebView webView, Uri uri) {
|
||||
@ -80,7 +79,7 @@ public abstract class K9WebViewClient extends WebViewClient {
|
||||
|
||||
private Part getPartForContentId(String cid) {
|
||||
Stack<Part> partsToCheck = new Stack<Part>();
|
||||
partsToCheck.push(message);
|
||||
partsToCheck.push(part);
|
||||
|
||||
while (!partsToCheck.isEmpty()) {
|
||||
Part part = partsToCheck.pop();
|
||||
@ -101,8 +100,8 @@ public abstract class K9WebViewClient extends WebViewClient {
|
||||
|
||||
|
||||
private static class PreLollipopWebViewClient extends K9WebViewClient {
|
||||
protected PreLollipopWebViewClient(Message message) {
|
||||
super(message);
|
||||
protected PreLollipopWebViewClient(Part part) {
|
||||
super(part);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -114,8 +113,8 @@ public abstract class K9WebViewClient extends WebViewClient {
|
||||
|
||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
||||
private static class LollipopWebViewClient extends K9WebViewClient {
|
||||
protected LollipopWebViewClient(Message message) {
|
||||
super(message);
|
||||
protected LollipopWebViewClient(Part part) {
|
||||
super(part);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user