Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 218ac4be authored by cketti's avatar cketti
Browse files

Merge pull request #1205

Handle unsupported message types - display a toast if we fail create the message
parents 3840b875 cb260d0f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4,13 +4,17 @@ package com.fsck.k9.ui.message;
import android.content.AsyncTaskLoader;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mailstore.LocalMessageExtractor;
import com.fsck.k9.mailstore.MessageViewInfo;
import com.fsck.k9.ui.crypto.MessageCryptoAnnotations;

import java.util.Collections;


public class DecodeMessageLoader extends AsyncTaskLoader<MessageViewInfo> {
    private final Message message;
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mailstore.AttachmentViewInfo;
import com.fsck.k9.mailstore.LocalMessage;
import com.fsck.k9.mailstore.MessageViewInfo;
import com.fsck.k9.mailstore.MessageViewInfo.MessageViewContainer;
import com.fsck.k9.ui.crypto.MessageCryptoCallback;
import com.fsck.k9.ui.crypto.MessageCryptoHelper;
import com.fsck.k9.ui.message.DecodeMessageLoader;
@@ -272,10 +273,20 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
    }

    private void onDecodeMessageFinished(MessageViewInfo messageViewInfo) {
        if (messageViewInfo == null) {
            showUnableToDecodeError();
            messageViewInfo = new MessageViewInfo(Collections.<MessageViewContainer>emptyList(), mMessage);
        }

        this.messageViewInfo = messageViewInfo;
        showMessage(messageViewInfo);
    }

    private void showUnableToDecodeError() {
        Context context = getActivity().getApplicationContext();
        Toast.makeText(context, R.string.message_view_toast_unable_to_display_message, Toast.LENGTH_SHORT).show();
    }

    private void showMessage(MessageViewInfo messageViewInfo) {
        try {
            mMessageView.setMessage(mAccount, messageViewInfo);
+1 −0
Original line number Diff line number Diff line
@@ -281,6 +281,7 @@ Please submit bug reports, contribute new features and ask questions at
    <string name="message_view_show_more_attachments_action">More…</string>
    <string name="message_view_no_viewer">Unable to find viewer for <xliff:g id="mimetype">%s</xliff:g>.</string>
    <string name="message_view_download_remainder">Download complete message</string>
    <string name="message_view_toast_unable_to_display_message">Unable to display message</string>

    <!-- NOTE: The following message refers to strings with id account_setup_incoming_save_all_headers_label and account_setup_incoming_title -->
    <string name="message_no_additional_headers_available">All headers have been downloaded, but there are no additional headers to show.</string>