mirror of
https://github.com/moparisthebest/k-9
synced 2024-10-31 15:45:08 -04:00
Merge remote-tracking branch 'vincent/pgp_mime_preparations' into pgp_mime_preparations_view
Conflicts: k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageContainerView.java
This commit is contained in:
commit
4c78d12fc6
@ -1,20 +1,43 @@
|
|||||||
package com.fsck.k9.mailstore;
|
package com.fsck.k9.mailstore;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
|
|
||||||
|
|
||||||
public class MessageViewInfo {
|
public class MessageViewInfo {
|
||||||
public final String text;
|
|
||||||
public final List<AttachmentViewInfo> attachments;
|
|
||||||
public final Message message;
|
|
||||||
|
|
||||||
|
public final Message message;
|
||||||
|
public final List<MessageViewContainer> containers = new ArrayList<MessageViewContainer>();
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public MessageViewInfo(String text, List<AttachmentViewInfo> attachments, Message message) {
|
public MessageViewInfo(String text, List<AttachmentViewInfo> attachments, Message message) {
|
||||||
this.text = text;
|
containers.add(new MessageViewContainer(text, attachments));
|
||||||
this.attachments = Collections.unmodifiableList(attachments);
|
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MessageViewContainer {
|
||||||
|
|
||||||
|
final public String text;
|
||||||
|
final public List<AttachmentViewInfo> attachments;
|
||||||
|
final public OpenPgpSignatureResult signatureResult;
|
||||||
|
|
||||||
|
MessageViewContainer(String text, List<AttachmentViewInfo> attachments) {
|
||||||
|
this.text = text;
|
||||||
|
this.attachments = attachments;
|
||||||
|
this.signatureResult = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageViewContainer(String text, List<AttachmentViewInfo> attachments,
|
||||||
|
OpenPgpSignatureResult signatureResult) {
|
||||||
|
this.text = text;
|
||||||
|
this.attachments = attachments;
|
||||||
|
this.signatureResult = signatureResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
@ -55,15 +54,15 @@ import com.fsck.k9.mail.MessagingException;
|
|||||||
import com.fsck.k9.mail.internet.MimeUtility;
|
import com.fsck.k9.mail.internet.MimeUtility;
|
||||||
import com.fsck.k9.mailstore.AttachmentViewInfo;
|
import com.fsck.k9.mailstore.AttachmentViewInfo;
|
||||||
import com.fsck.k9.mailstore.MessageViewInfo;
|
import com.fsck.k9.mailstore.MessageViewInfo;
|
||||||
|
import com.fsck.k9.mailstore.MessageViewInfo.MessageViewContainer;
|
||||||
import com.fsck.k9.provider.AttachmentProvider.AttachmentProviderColumns;
|
import com.fsck.k9.provider.AttachmentProvider.AttachmentProviderColumns;
|
||||||
|
|
||||||
import com.fsck.k9.view.MessageHeader;
|
|
||||||
import com.fsck.k9.view.MessageHeader.OnLayoutChangedListener;
|
import com.fsck.k9.view.MessageHeader.OnLayoutChangedListener;
|
||||||
import com.fsck.k9.view.MessageWebView;
|
import com.fsck.k9.view.MessageWebView;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
|
||||||
public class SingleMessageView extends LinearLayout implements OnClickListener,
|
public class MessageContainerView extends LinearLayout implements OnClickListener,
|
||||||
OnLayoutChangedListener, OnCreateContextMenuListener {
|
OnLayoutChangedListener, OnCreateContextMenuListener {
|
||||||
private static final int MENU_ITEM_LINK_VIEW = Menu.FIRST;
|
private static final int MENU_ITEM_LINK_VIEW = Menu.FIRST;
|
||||||
private static final int MENU_ITEM_LINK_SHARE = Menu.FIRST + 1;
|
private static final int MENU_ITEM_LINK_SHARE = Menu.FIRST + 1;
|
||||||
@ -90,7 +89,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
|
|
||||||
private MessageOpenPgpViewOld mOpenPgpView;
|
private MessageOpenPgpViewOld mOpenPgpView;
|
||||||
private MessageWebView mMessageContentView;
|
private MessageWebView mMessageContentView;
|
||||||
private MessageHeader mHeaderContainer;
|
|
||||||
private LinearLayout mAttachments;
|
private LinearLayout mAttachments;
|
||||||
private Button mShowHiddenAttachments;
|
private Button mShowHiddenAttachments;
|
||||||
private LinearLayout mHiddenAttachments;
|
private LinearLayout mHiddenAttachments;
|
||||||
@ -99,7 +97,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
private View mShowAttachmentsAction;
|
private View mShowAttachmentsAction;
|
||||||
private boolean mShowPictures;
|
private boolean mShowPictures;
|
||||||
private boolean mHasAttachments;
|
private boolean mHasAttachments;
|
||||||
private Button mDownloadRemainder;
|
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private Contacts mContacts;
|
private Contacts mContacts;
|
||||||
private AttachmentViewCallback attachmentCallback;
|
private AttachmentViewCallback attachmentCallback;
|
||||||
@ -110,25 +107,21 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
|
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
|
||||||
|
|
||||||
|
|
||||||
public void initialize(Fragment fragment) {
|
public void initialize(Fragment fragment, AttachmentViewCallback attachmentCallback) {
|
||||||
|
this.attachmentCallback = attachmentCallback;
|
||||||
|
|
||||||
Activity activity = fragment.getActivity();
|
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);
|
activity.registerForContextMenu(mMessageContentView);
|
||||||
mMessageContentView.setOnCreateContextMenuListener(this);
|
mMessageContentView.setOnCreateContextMenuListener(this);
|
||||||
|
|
||||||
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
|
|
||||||
mHeaderContainer.setOnLayoutChangedListener(this);
|
|
||||||
|
|
||||||
mAttachmentsContainer = findViewById(R.id.attachments_container);
|
mAttachmentsContainer = findViewById(R.id.attachments_container);
|
||||||
mAttachments = (LinearLayout) findViewById(R.id.attachments);
|
mAttachments = (LinearLayout) findViewById(R.id.attachments);
|
||||||
mHiddenAttachments = (LinearLayout) findViewById(R.id.hidden_attachments);
|
mHiddenAttachments = (LinearLayout) findViewById(R.id.hidden_attachments);
|
||||||
mHiddenAttachments.setVisibility(View.GONE);
|
mHiddenAttachments.setVisibility(View.GONE);
|
||||||
mShowHiddenAttachments = (Button) findViewById(R.id.show_hidden_attachments);
|
mShowHiddenAttachments = (Button) findViewById(R.id.show_hidden_attachments);
|
||||||
mShowHiddenAttachments.setVisibility(View.GONE);
|
mShowHiddenAttachments.setVisibility(View.GONE);
|
||||||
mOpenPgpView = (MessageOpenPgpViewOld) findViewById(R.id.layout_decrypt_openpgp);
|
|
||||||
mOpenPgpView.setFragment(fragment);
|
|
||||||
mOpenPgpView.setupChildViews();
|
|
||||||
mShowPicturesAction = findViewById(R.id.show_pictures);
|
mShowPicturesAction = findViewById(R.id.show_pictures);
|
||||||
mShowMessageAction = findViewById(R.id.show_message);
|
mShowMessageAction = findViewById(R.id.show_message);
|
||||||
|
|
||||||
@ -139,23 +132,19 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
mContacts = Contacts.getInstance(activity);
|
mContacts = Contacts.getInstance(activity);
|
||||||
|
|
||||||
mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater();
|
mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater();
|
||||||
mDownloadRemainder = (Button) findViewById(R.id.download_remainder);
|
|
||||||
mDownloadRemainder.setVisibility(View.GONE);
|
|
||||||
mAttachmentsContainer.setVisibility(View.GONE);
|
|
||||||
mMessageContentView.setVisibility(View.VISIBLE);
|
mMessageContentView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
// 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);
|
getContext().getTheme().resolveAttribute(R.attr.messageViewHeaderBackgroundColor, outValue, true);
|
||||||
mHeaderContainer.setBackgroundColor(outValue.data);
|
|
||||||
// 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);
|
||||||
|
|
||||||
mShowHiddenAttachments.setOnClickListener(this);
|
mShowHiddenAttachments.setOnClickListener(this);
|
||||||
mShowMessageAction.setOnClickListener(this);
|
// mShowMessageAction.setOnClickListener(this);
|
||||||
mShowAttachmentsAction.setOnClickListener(this);
|
// mShowAttachmentsAction.setOnClickListener(this);
|
||||||
mShowPicturesAction.setOnClickListener(this);
|
// mShowPicturesAction.setOnClickListener(this);
|
||||||
|
|
||||||
mClipboardManager = ClipboardManager.getInstance(activity);
|
mClipboardManager = ClipboardManager.getInstance(activity);
|
||||||
}
|
}
|
||||||
@ -382,14 +371,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
onShowHiddenAttachments();
|
onShowHiddenAttachments();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.show_message: {
|
|
||||||
onShowMessage();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case R.id.show_attachments: {
|
|
||||||
onShowAttachments();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case R.id.show_pictures: {
|
case R.id.show_pictures: {
|
||||||
// Allow network access first...
|
// Allow network access first...
|
||||||
setLoadPictures(true);
|
setLoadPictures(true);
|
||||||
@ -405,21 +386,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
mHiddenAttachments.setVisibility(View.VISIBLE);
|
mHiddenAttachments.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onShowMessage() {
|
public MessageContainerView(Context context, AttributeSet attrs) {
|
||||||
showShowMessageAction(false);
|
|
||||||
showAttachments(false);
|
|
||||||
showShowAttachmentsAction(mHasAttachments);
|
|
||||||
showMessageWebView(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onShowAttachments() {
|
|
||||||
showMessageWebView(false);
|
|
||||||
showShowAttachmentsAction(false);
|
|
||||||
showShowMessageAction(true);
|
|
||||||
showAttachments(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SingleMessageView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,58 +413,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showShowPicturesAction(boolean show) {
|
public void showShowPicturesAction(boolean show) {
|
||||||
mShowPicturesAction.setVisibility(show ? View.VISIBLE : View.GONE);
|
// mShowPicturesAction.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
}
|
|
||||||
public void showShowMessageAction(boolean show) {
|
|
||||||
mShowMessageAction.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
public void showShowAttachmentsAction(boolean show) {
|
|
||||||
mShowAttachmentsAction.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch the message header view. This is not the same as the message headers; this is the View shown at the top
|
|
||||||
* of messages.
|
|
||||||
* @return MessageHeader View.
|
|
||||||
*/
|
|
||||||
public MessageHeader getMessageHeaderView() {
|
|
||||||
return mHeaderContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeaders(final Message message, Account account) {
|
|
||||||
try {
|
|
||||||
mHeaderContainer.populate(message, account);
|
|
||||||
mHeaderContainer.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception me) {
|
|
||||||
Log.e(K9.LOG_TAG, "setHeaders - error", me);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnToggleFlagClickListener(OnClickListener listener) {
|
|
||||||
mHeaderContainer.setOnFlagListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnDownloadButtonClickListener(OnClickListener listener) {
|
|
||||||
mDownloadRemainder.setOnClickListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableDownloadButton() {
|
|
||||||
mDownloadRemainder.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disableDownloadButton() {
|
|
||||||
mDownloadRemainder.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShowDownloadButton(Message message) {
|
|
||||||
if (message.isSet(Flag.X_DOWNLOADED_FULL)) {
|
|
||||||
mDownloadRemainder.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
mDownloadRemainder.setEnabled(true);
|
|
||||||
mDownloadRemainder.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableAttachmentButtons() {
|
public void enableAttachmentButtons() {
|
||||||
@ -512,36 +428,16 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAllHeaders() {
|
public void setMessage(MessageViewContainer messageViewContainer)
|
||||||
mHeaderContainer.onShowAdditionalHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean additionalHeadersVisible() {
|
|
||||||
return mHeaderContainer.additionalHeadersVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(Account account, MessageViewInfo messageViewInfo, PgpData pgpData)
|
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
resetView();
|
resetView();
|
||||||
|
|
||||||
String text = null;
|
|
||||||
if (pgpData != null) {
|
|
||||||
text = pgpData.getDecryptedData();
|
|
||||||
if (text != null) {
|
|
||||||
text = HtmlConverter.textToHtml(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text == null) {
|
|
||||||
text = messageViewInfo.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the text so we can reset the WebView when the user clicks the "Show pictures" button
|
// Save the text so we can reset the WebView when the user clicks the "Show pictures" button
|
||||||
mText = text;
|
mText = messageViewContainer.text;
|
||||||
|
|
||||||
mHasAttachments = !messageViewInfo.attachments.isEmpty();
|
mHasAttachments = !messageViewContainer.attachments.isEmpty();
|
||||||
if (mHasAttachments) {
|
if (mHasAttachments) {
|
||||||
renderAttachments(messageViewInfo);
|
renderAttachments(messageViewContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
mHiddenAttachments.setVisibility(View.GONE);
|
mHiddenAttachments.setVisibility(View.GONE);
|
||||||
@ -553,27 +449,20 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
lookForImages = false;
|
lookForImages = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSavedState.attachmentViewVisible) {
|
|
||||||
onShowAttachments();
|
|
||||||
} else {
|
|
||||||
onShowMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mSavedState.hiddenAttachmentsVisible) {
|
if (mSavedState.hiddenAttachmentsVisible) {
|
||||||
onShowHiddenAttachments();
|
onShowHiddenAttachments();
|
||||||
}
|
}
|
||||||
|
|
||||||
mSavedState = null;
|
mSavedState = null;
|
||||||
} else {
|
|
||||||
onShowMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (text != null && lookForImages) {
|
if (text != null && lookForImages) {
|
||||||
// If the message contains external pictures and the "Show pictures"
|
// If the message contains external pictures and the "Show pictures"
|
||||||
// button wasn't already pressed, see if the user's preferences has us
|
// button wasn't already pressed, see if the user's preferences has us
|
||||||
// showing them anyway.
|
// showing them anyway.
|
||||||
if (Utility.hasExternalImages(text) && !showPictures()) {
|
if (Utility.hasExternalImages(text) && !showPictures()) {
|
||||||
Address[] from = messageViewInfo.message.getFrom();
|
Address[] from = messageViewContainer.message.getFrom();
|
||||||
if ((account.getShowPictures() == Account.ShowPictures.ALWAYS) ||
|
if ((account.getShowPictures() == Account.ShowPictures.ALWAYS) ||
|
||||||
((account.getShowPictures() == Account.ShowPictures.ONLY_FROM_CONTACTS) &&
|
((account.getShowPictures() == Account.ShowPictures.ONLY_FROM_CONTACTS) &&
|
||||||
// Make sure we have at least one from address
|
// Make sure we have at least one from address
|
||||||
@ -585,11 +474,10 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (text != null) {
|
if (mText != null) {
|
||||||
loadBodyFromText(text);
|
loadBodyFromText(mText);
|
||||||
mOpenPgpView.updateLayout(account, pgpData.getDecryptedData(),
|
|
||||||
pgpData.getSignatureResult(), messageViewInfo.message);
|
|
||||||
} else {
|
} else {
|
||||||
showStatusMessage(getContext().getString(R.string.webview_empty_message));
|
showStatusMessage(getContext().getString(R.string.webview_empty_message));
|
||||||
}
|
}
|
||||||
@ -604,18 +492,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
mMessageContentView.setText(emailText);
|
mMessageContentView.setText(emailText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAttachments(boolean show) {
|
public void renderAttachments(MessageViewContainer messageContainer) throws MessagingException {
|
||||||
mAttachmentsContainer.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
boolean showHidden = (show && mHiddenAttachments.getVisibility() == View.GONE &&
|
|
||||||
mHiddenAttachments.getChildCount() > 0);
|
|
||||||
mShowHiddenAttachments.setVisibility(showHidden ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showMessageWebView(boolean show) {
|
|
||||||
mMessageContentView.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderAttachments(MessageViewInfo messageContainer) throws MessagingException {
|
|
||||||
for (AttachmentViewInfo attachment : messageContainer.attachments) {
|
for (AttachmentViewInfo attachment : messageContainer.attachments) {
|
||||||
AttachmentView view = (AttachmentView) mInflater.inflate(R.layout.message_view_attachment, null);
|
AttachmentView view = (AttachmentView) mInflater.inflate(R.layout.message_view_attachment, null);
|
||||||
view.setCallback(attachmentCallback);
|
view.setCallback(attachmentCallback);
|
||||||
@ -652,10 +529,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetView() {
|
public void resetView() {
|
||||||
mDownloadRemainder.setVisibility(View.GONE);
|
|
||||||
setLoadPictures(false);
|
setLoadPictures(false);
|
||||||
showShowAttachmentsAction(false);
|
|
||||||
showShowMessageAction(false);
|
|
||||||
showShowPicturesAction(false);
|
showShowPicturesAction(false);
|
||||||
mAttachments.removeAllViews();
|
mAttachments.removeAllViews();
|
||||||
mHiddenAttachments.removeAllViews();
|
mHiddenAttachments.removeAllViews();
|
||||||
@ -670,14 +544,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
|||||||
loadBodyFromText("");
|
loadBodyFromText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetHeaderView() {
|
|
||||||
mHeaderContainer.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttachmentCallback(AttachmentViewCallback attachmentCallback) {
|
|
||||||
this.attachmentCallback = attachmentCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Parcelable onSaveInstanceState() {
|
public Parcelable onSaveInstanceState() {
|
||||||
Parcelable superState = super.onSaveInstanceState();
|
Parcelable superState = super.onSaveInstanceState();
|
@ -0,0 +1,133 @@
|
|||||||
|
package com.fsck.k9.ui.messageview;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import com.fsck.k9.Account;
|
||||||
|
import com.fsck.k9.K9;
|
||||||
|
import com.fsck.k9.R;
|
||||||
|
import com.fsck.k9.crypto.PgpData;
|
||||||
|
import com.fsck.k9.mail.Flag;
|
||||||
|
import com.fsck.k9.mail.Message;
|
||||||
|
import com.fsck.k9.mail.MessagingException;
|
||||||
|
import com.fsck.k9.mailstore.MessageViewInfo;
|
||||||
|
import com.fsck.k9.mailstore.MessageViewInfo.MessageViewContainer;
|
||||||
|
import com.fsck.k9.view.MessageHeader;
|
||||||
|
|
||||||
|
|
||||||
|
public class MessageTopView extends LinearLayout {
|
||||||
|
|
||||||
|
private MessageHeader mHeaderContainer;
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
private LinearLayout containerViews;
|
||||||
|
private Fragment fragment;
|
||||||
|
private Button mDownloadRemainder;
|
||||||
|
private AttachmentViewCallback attachmentCallback;
|
||||||
|
|
||||||
|
public MessageTopView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize (Fragment fragment, AttachmentViewCallback attachmentCallback) {
|
||||||
|
this.fragment = fragment;
|
||||||
|
this.attachmentCallback = attachmentCallback;
|
||||||
|
|
||||||
|
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
|
||||||
|
// mHeaderContainer.setOnLayoutChangedListener(this);
|
||||||
|
mInflater = ((MessageViewFragment) fragment).getFragmentLayoutInflater();
|
||||||
|
|
||||||
|
TypedValue outValue = new TypedValue();
|
||||||
|
getContext().getTheme().resolveAttribute(R.attr.messageViewHeaderBackgroundColor, outValue, true);
|
||||||
|
mHeaderContainer.setBackgroundColor(outValue.data);
|
||||||
|
|
||||||
|
mDownloadRemainder = (Button) findViewById(R.id.download_remainder);
|
||||||
|
mDownloadRemainder.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
containerViews = (LinearLayout) findViewById(R.id.message_containers);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetView() {
|
||||||
|
mDownloadRemainder.setVisibility(View.GONE);
|
||||||
|
containerViews.removeAllViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(Account account, MessageViewInfo messageViewInfo)
|
||||||
|
throws MessagingException {
|
||||||
|
resetView();
|
||||||
|
|
||||||
|
for (MessageViewContainer container : messageViewInfo.containers) {
|
||||||
|
MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null);
|
||||||
|
view.initialize(fragment, attachmentCallback);
|
||||||
|
view.setMessage(container);
|
||||||
|
containerViews.addView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the message header view. This is not the same as the message headers; this is the View shown at the top
|
||||||
|
* of messages.
|
||||||
|
* @return MessageHeader View.
|
||||||
|
*/
|
||||||
|
public MessageHeader getMessageHeaderView() {
|
||||||
|
return mHeaderContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeaders(final Message message, Account account) {
|
||||||
|
try {
|
||||||
|
mHeaderContainer.populate(message, account);
|
||||||
|
mHeaderContainer.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception me) {
|
||||||
|
Log.e(K9.LOG_TAG, "setHeaders - error", me);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnToggleFlagClickListener(OnClickListener listener) {
|
||||||
|
mHeaderContainer.setOnFlagListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showAllHeaders() {
|
||||||
|
mHeaderContainer.onShowAdditionalHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean additionalHeadersVisible() {
|
||||||
|
return mHeaderContainer.additionalHeadersVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetHeaderView() {
|
||||||
|
mHeaderContainer.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnDownloadButtonClickListener(OnClickListener listener) {
|
||||||
|
mDownloadRemainder.setOnClickListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableDownloadButton() {
|
||||||
|
mDownloadRemainder.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableDownloadButton() {
|
||||||
|
mDownloadRemainder.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowDownloadButton(Message message) {
|
||||||
|
if (message.isSet(Flag.X_DOWNLOADED_FULL)) {
|
||||||
|
mDownloadRemainder.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
mDownloadRemainder.setEnabled(true);
|
||||||
|
mDownloadRemainder.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -78,7 +78,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SingleMessageView mMessageView;
|
private MessageTopView mMessageView;
|
||||||
private PgpData mPgpData;
|
private PgpData mPgpData;
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
private MessageReference mMessageReference;
|
private MessageReference mMessageReference;
|
||||||
@ -145,17 +145,16 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
View view = mLayoutInflater.inflate(R.layout.message, container, false);
|
View view = mLayoutInflater.inflate(R.layout.message, container, false);
|
||||||
|
|
||||||
|
|
||||||
mMessageView = (SingleMessageView) view.findViewById(R.id.message_view);
|
mMessageView = (MessageTopView) view.findViewById(R.id.message_view);
|
||||||
|
|
||||||
mMessageView.setAttachmentCallback(this);
|
mMessageView.initialize(this, this);
|
||||||
|
|
||||||
mMessageView.initialize(this);
|
|
||||||
mMessageView.setOnToggleFlagClickListener(new OnClickListener() {
|
mMessageView.setOnToggleFlagClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
onToggleFlagged();
|
onToggleFlagged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mMessageView.setOnDownloadButtonClickListener(new OnClickListener() {
|
mMessageView.setOnDownloadButtonClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -229,7 +228,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onLoadMessageFromDatabaseFailed() {
|
private void onLoadMessageFromDatabaseFailed() {
|
||||||
mMessageView.showStatusMessage(mContext.getString(R.string.status_invalid_id_error));
|
// mMessageView.showStatusMessage(mContext.getString(R.string.status_invalid_id_error));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startDownloadingMessageBody(LocalMessage message) {
|
private void startDownloadingMessageBody(LocalMessage message) {
|
||||||
@ -269,7 +268,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
|
|
||||||
private void showMessage(MessageViewInfo messageContainer) {
|
private void showMessage(MessageViewInfo messageContainer) {
|
||||||
try {
|
try {
|
||||||
mMessageView.setMessage(mAccount, messageContainer, mPgpData);
|
mMessageView.setMessage(mAccount, messageContainer);
|
||||||
mMessageView.setShowDownloadButton(mMessage);
|
mMessageView.setShowDownloadButton(mMessage);
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException e) {
|
||||||
Log.e(K9.LOG_TAG, "Error while trying to display message", e);
|
Log.e(K9.LOG_TAG, "Error while trying to display message", e);
|
||||||
@ -406,7 +405,8 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSelectText() {
|
public void onSelectText() {
|
||||||
mMessageView.beginSelectingText();
|
// FIXME
|
||||||
|
// mMessageView.beginSelectingText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startRefileActivity(int activity) {
|
private void startRefileActivity(int activity) {
|
||||||
@ -418,7 +418,6 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
startActivityForResult(intent, activity);
|
startActivityForResult(intent, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (resultCode != Activity.RESULT_OK) {
|
if (resultCode != Activity.RESULT_OK) {
|
||||||
@ -533,7 +532,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
PgpData data = new PgpData();
|
PgpData data = new PgpData();
|
||||||
data.setDecryptedData(decryptedData);
|
data.setDecryptedData(decryptedData);
|
||||||
data.setSignatureResult(signatureResult);
|
data.setSignatureResult(signatureResult);
|
||||||
mMessageView.setMessage(mAccount, messageViewInfo, data);
|
mMessageView.setMessage(mAccount, messageViewInfo);
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException e) {
|
||||||
Log.e(K9.LOG_TAG, "displayMessageBody failed", e);
|
Log.e(K9.LOG_TAG, "displayMessageBody failed", e);
|
||||||
}
|
}
|
||||||
@ -600,7 +599,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void zoom(KeyEvent event) {
|
public void zoom(KeyEvent event) {
|
||||||
mMessageView.zoom(event);
|
// mMessageView.zoom(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -668,11 +667,11 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableAttachmentButtons(AttachmentViewInfo attachment) {
|
public void disableAttachmentButtons(AttachmentViewInfo attachment) {
|
||||||
mMessageView.disableAttachmentButtons(attachment);
|
// mMessageView.disableAttachmentButtons(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableAttachmentButtons(AttachmentViewInfo attachment) {
|
public void enableAttachmentButtons(AttachmentViewInfo attachment) {
|
||||||
mMessageView.enableAttachmentButtons(attachment);
|
// mMessageView.enableAttachmentButtons(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runOnMainThread(Runnable runnable) {
|
public void runOnMainThread(Runnable runnable) {
|
||||||
@ -680,7 +679,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showAttachmentLoadingDialog() {
|
public void showAttachmentLoadingDialog() {
|
||||||
mMessageView.disableAttachmentButtons();
|
// mMessageView.disableAttachmentButtons();
|
||||||
showDialog(R.id.dialog_attachment_progress);
|
showDialog(R.id.dialog_attachment_progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,13 +688,13 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
removeDialog(R.id.dialog_attachment_progress);
|
removeDialog(R.id.dialog_attachment_progress);
|
||||||
mMessageView.enableAttachmentButtons();
|
// mMessageView.enableAttachmentButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshAttachmentThumbnail(AttachmentViewInfo attachment) {
|
public void refreshAttachmentThumbnail(AttachmentViewInfo attachment) {
|
||||||
mMessageView.refreshAttachmentThumbnail(attachment);
|
// mMessageView.refreshAttachmentThumbnail(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface MessageViewFragmentListener {
|
public interface MessageViewFragmentListener {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.fsck.k9.ui.messageview.SingleMessageView
|
<com.fsck.k9.ui.messageview.MessageTopView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/message_view"
|
android:id="@+id/message_view"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -20,41 +20,11 @@
|
|||||||
<!-- Header area -->
|
<!-- Header area -->
|
||||||
<include layout="@layout/message_view_header"/>
|
<include layout="@layout/message_view_header"/>
|
||||||
|
|
||||||
<!-- Content area -->
|
|
||||||
<com.fsck.k9.view.MessageWebView
|
|
||||||
android:id="@+id/message_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"/>
|
|
||||||
|
|
||||||
<!-- Attachments area -->
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/attachments_container"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/message_containers"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/attachments"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="4dip" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/show_hidden_attachments"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/message_view_show_more_attachments_action"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/hidden_attachments"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="4dip"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -66,4 +36,4 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_width="fill_parent"/>
|
android:layout_width="fill_parent"/>
|
||||||
|
|
||||||
</com.fsck.k9.ui.messageview.SingleMessageView>
|
</com.fsck.k9.ui.messageview.MessageTopView>
|
||||||
|
43
k9mail/src/main/res/layout/message_container.xml
Normal file
43
k9mail/src/main/res/layout/message_container.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.fsck.k9.ui.messageview.MessageContainerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- Content area -->
|
||||||
|
<com.fsck.k9.view.MessageWebView
|
||||||
|
android:id="@+id/message_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="fill_parent"/>
|
||||||
|
|
||||||
|
<!-- Attachments area -->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/attachments_container"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/attachments"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="4dip" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/show_hidden_attachments"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/message_view_show_more_attachments_action"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/hidden_attachments"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="4dip"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.fsck.k9.ui.messageview.MessageContainerView>
|
Loading…
Reference in New Issue
Block a user