1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Don't pass Fragment reference to MessageContainerView

This commit is contained in:
cketti 2015-02-17 01:30:41 +01:00
parent 15cb58fe42
commit e16f8af667
2 changed files with 9 additions and 12 deletions

View File

@ -3,8 +3,6 @@ package com.fsck.k9.ui.messageview;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import android.app.Activity;
import android.app.Fragment;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -88,19 +86,18 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
private OpenPgpHeaderView openPgpHeaderView; private OpenPgpHeaderView openPgpHeaderView;
public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback, public void initialize(AttachmentViewCallback attachmentCallback,
OpenPgpHeaderViewCallback openPgpHeaderViewCallback, OpenPgpHeaderViewCallback openPgpHeaderViewCallback, boolean displayPgpData) {
boolean displayPgpData) { Context context = getContext();
this.attachmentCallback = attachmentCallback; this.attachmentCallback = attachmentCallback;
this.openPgpHeaderViewCallback = openPgpHeaderViewCallback; this.openPgpHeaderViewCallback = openPgpHeaderViewCallback;
mOpenPgpHeaderStub = (ViewStub) findViewById(R.id.openpgp_header_stub); mOpenPgpHeaderStub = (ViewStub) findViewById(R.id.openpgp_header_stub);
mSidebar = findViewById(R.id.message_sidebar); mSidebar = findViewById(R.id.message_sidebar);
Activity activity = fragment.getActivity();
mMessageContentView = (MessageWebView) findViewById(R.id.message_content); mMessageContentView = (MessageWebView) findViewById(R.id.message_content);
mMessageContentView.configure(); mMessageContentView.configure();
activity.registerForContextMenu(mMessageContentView);
mMessageContentView.setOnCreateContextMenuListener(this); mMessageContentView.setOnCreateContextMenuListener(this);
mAttachmentsContainer = findViewById(R.id.attachments_container); mAttachmentsContainer = findViewById(R.id.attachments_container);
@ -116,9 +113,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
mShowPictures = false; mShowPictures = false;
mContacts = Contacts.getInstance(activity); mContacts = Contacts.getInstance(context);
mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater(); mInflater = LayoutInflater.from(context);
mMessageContentView.setVisibility(View.VISIBLE); mMessageContentView.setVisibility(View.VISIBLE);
this.displayPgpData = displayPgpData; this.displayPgpData = displayPgpData;
@ -131,7 +128,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
// the HTC version of WebView tries to force the background of the // the HTC version of WebView tries to force the background of the
// titlebar, which is really unfair. // titlebar, which is really unfair.
TypedValue outValue = new TypedValue(); TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(R.attr.messageViewHeaderBackgroundColor, outValue, true); context.getTheme().resolveAttribute(R.attr.messageViewHeaderBackgroundColor, outValue, true);
// also set background of the whole view (including the attachments view) // also set background of the whole view (including the attachments view)
setBackgroundColor(outValue.data); setBackgroundColor(outValue.data);
@ -140,7 +137,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
// mShowAttachmentsAction.setOnClickListener(this); // mShowAttachmentsAction.setOnClickListener(this);
// mShowPicturesAction.setOnClickListener(this); // mShowPicturesAction.setOnClickListener(this);
mClipboardManager = ClipboardManager.getInstance(activity); mClipboardManager = ClipboardManager.getInstance(context);
} }
@Override @Override

View File

@ -67,7 +67,7 @@ public class MessageTopView extends LinearLayout {
for (MessageViewContainer container : messageViewInfo.containers) { for (MessageViewContainer container : messageViewInfo.containers) {
MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null); MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null);
view.initialize(fragment, attachmentCallback, openPgpHeaderViewCallback, view.initialize(attachmentCallback, openPgpHeaderViewCallback,
!Account.NO_OPENPGP_PROVIDER.equals(account.getOpenPgpProvider())); !Account.NO_OPENPGP_PROVIDER.equals(account.getOpenPgpProvider()));
view.setMessageViewContainer(container); view.setMessageViewContainer(container);