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

Commit 9b1e51c5 authored by Vincent Breitmoser's avatar Vincent Breitmoser Committed by Vincent Breitmoser
Browse files

messageview: draw progress bar while crypto is processing

parent 293e23d0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class QuotedMessageMvpView {
    }

    public void setQuotedHtml(String quotedContent, AttachmentResolver attachmentResolver) {
        mQuotedHTML.displayHtmlContentWithInlineAttachments(quotedContent, attachmentResolver);
        mQuotedHTML.displayHtmlContentWithInlineAttachments(quotedContent, attachmentResolver, null);
    }

    public void setQuotedText(String quotedText) {
+10 −4
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public class MessageCryptoHelper {
    private static final int INVALID_OPENPGP_RESULT_CODE = -1;
    private static final MimeBodyPart NO_REPLACEMENT_PART = null;
    public static final int REQUEST_CODE_USER_INTERACTION = 124;
    public static final int PROGRESS_SIZE_THRESHOLD = 4096;


    private final Context context;
@@ -277,7 +278,8 @@ public class MessageCryptoHelper {

            @Override
            public void onProgress(int current, int max) {
                Log.d(K9.LOG_TAG, "got progress: " + current + " / " + max);
                Log.d(K9.LOG_TAG, "received progress status: " + current + " / " + max);
                callback.onCryptoHelperProgress(current, max);
            }
        });
    }
@@ -297,7 +299,8 @@ public class MessageCryptoHelper {

            @Override
            public void onProgress(int current, int max) {
                Log.d(K9.LOG_TAG, "got progress: " + current + " / " + max);
                Log.d(K9.LOG_TAG, "received progress status: " + current + " / " + max);
                callback.onCryptoHelperProgress(current, max);
            }
        });
    }
@@ -321,7 +324,7 @@ public class MessageCryptoHelper {
    private OpenPgpDataSource getDataSourceForEncryptedOrInlineData() throws IOException {
        return new OpenPgpApi.OpenPgpDataSource() {
            @Override
            public Long getTotalDataSize() {
            public Long getSizeForProgress() {
                Part part = currentCryptoPart.part;
                CryptoPartType cryptoPartType = currentCryptoPart.type;
                Body body;
@@ -335,7 +338,10 @@ public class MessageCryptoHelper {
                    throw new IllegalStateException("part to stream must be encrypted or inline!");
                }
                if (body instanceof SizeAware) {
                    return ((SizeAware) body).getSize();
                    long bodySize = ((SizeAware) body).getSize();
                    if (bodySize > PROGRESS_SIZE_THRESHOLD) {
                        return bodySize;
                    }
                }
                return null;
            }
+3 −0
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ public class CryptoInfoDialog extends DialogFragment {
    }

    private void setMessageForDisplayStatus(MessageCryptoDisplayStatus displayStatus) {
        if (displayStatus.textResFirst == null) {
            throw new AssertionError("Crypto info dialog can only be displayed for items with text!");
        }

        if (displayStatus.textResSecond == null) {
            setMessageSingleLine(displayStatus.color, displayStatus.textResFirst, displayStatus.iconResFirst, displayStatus.iconResSecond);
+21 −6
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.fsck.k9.mailstore.AttachmentViewInfo;
import com.fsck.k9.mailstore.MessageViewInfo;
import com.fsck.k9.view.MessageHeader.OnLayoutChangedListener;
import com.fsck.k9.view.MessageWebView;
import com.fsck.k9.view.MessageWebView.OnPageFinishedListener;


public class MessageContainerView extends LinearLayout implements OnClickListener,
@@ -401,7 +402,8 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
    }

    public void displayMessageViewContainer(MessageViewInfo messageViewInfo,
            boolean automaticallyLoadPictures, ShowPicturesController showPicturesController,
            final OnRenderingFinishedListener onRenderingFinishedListener, boolean automaticallyLoadPictures,
            ShowPicturesController showPicturesController,
            AttachmentViewCallback attachmentCallback) throws MessagingException {

        this.attachmentCallback = attachmentCallback;
@@ -441,7 +443,15 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
            textToDisplay = wrapStatusMessage(getContext().getString(R.string.webview_empty_message));
        }

        displayHtmlContentWithInlineAttachments(textToDisplay, messageViewInfo.attachmentResolver);
        OnPageFinishedListener onPageFinishedListener = new OnPageFinishedListener() {
            @Override
            public void onPageFinished() {
                onRenderingFinishedListener.onLoadFinished();
            }
        };

        displayHtmlContentWithInlineAttachments(
                textToDisplay, messageViewInfo.attachmentResolver, onPageFinishedListener);

        if (!TextUtils.isEmpty(messageViewInfo.extraText)) {
            unsignedTextContainer.setVisibility(View.VISIBLE);
@@ -453,18 +463,19 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
        return "<div style=\"text-align:center; color: grey;\">" + status + "</div>";
    }

    private void displayHtmlContentWithInlineAttachments(String htmlText, AttachmentResolver attachmentResolver) {
    private void displayHtmlContentWithInlineAttachments(String htmlText, AttachmentResolver attachmentResolver,
            OnPageFinishedListener onPageFinishedListener) {
        currentHtmlText = htmlText;
        currentAttachmentResolver = attachmentResolver;
        mMessageContentView.displayHtmlContentWithInlineAttachments(htmlText, attachmentResolver);
        mMessageContentView.displayHtmlContentWithInlineAttachments(htmlText, attachmentResolver, onPageFinishedListener);
    }

    private void refreshDisplayedContent() {
        mMessageContentView.displayHtmlContentWithInlineAttachments(currentHtmlText, currentAttachmentResolver);
        mMessageContentView.displayHtmlContentWithInlineAttachments(currentHtmlText, currentAttachmentResolver, null);
    }

    private void clearDisplayedContent() {
        mMessageContentView.displayHtmlContentWithInlineAttachments("", null);
        mMessageContentView.displayHtmlContentWithInlineAttachments("", null, null);
    }

    public void renderAttachments(MessageViewInfo messageViewInfo) throws MessagingException {
@@ -614,4 +625,8 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
            out.writeInt((this.showingPictures) ? 1 : 0);
        }
    }

    interface OnRenderingFinishedListener {
        void onLoadFinished();
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -37,11 +37,14 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
        MessageCryptoDisplayStatus displayStatus =
                MessageCryptoDisplayStatus.fromResultAnnotation(messageViewInfo.cryptoResultAnnotation);
        switch (displayStatus) {
            case LOADING:
                // no need to do anything, there is a progress bar...
                break;
            case UNENCRYPTED_SIGN_UNKNOWN:
                launchPendingIntent(messageViewInfo);
                break;
            default:
                displaySignatureInfoDialog(displayStatus);
                displayCryptoInfoDialog(displayStatus);
                break;
        }
    }
@@ -59,7 +62,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
        messageCryptoMvpView.restartMessageCryptoProcessing();
    }

    private void displaySignatureInfoDialog(MessageCryptoDisplayStatus displayStatus) {
    private void displayCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus) {
        messageCryptoMvpView.showCryptoInfoDialog(displayStatus);
    }

Loading