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

Commit c12ce959 authored by Vincent Breitmoser's avatar Vincent Breitmoser Committed by Vincent Breitmoser
Browse files

messageview: add "View Key" button to crypto info dialog

parent 675b1673
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.ui.messageview.CryptoInfoDialog.OnClickShowCryptoKeyListener;
import com.fsck.k9.ui.messageview.MessageViewFragment;
import com.fsck.k9.ui.messageview.MessageViewFragment.MessageViewFragmentListener;
import com.fsck.k9.view.MessageHeader;
+17 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
@@ -79,6 +80,18 @@ public class CryptoInfoDialog extends DialogFragment {
                dismiss();
            }
        });
        if (displayStatus.hasAssociatedKey()) {
            b.setNeutralButton(R.string.crypto_info_view_key, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Fragment frag = getTargetFragment();
                    if (! (frag instanceof OnClickShowCryptoKeyListener)) {
                        throw new AssertionError("Displaying activity must implement OnClickShowCryptoKeyListener!");
                    }
                    ((OnClickShowCryptoKeyListener) frag).onClickShowCryptoKey();
                }
            });
        }

        return b.create();
    }
@@ -166,4 +179,8 @@ public class CryptoInfoDialog extends DialogFragment {
            }
        });
    }

    public interface OnClickShowCryptoKeyListener {
        void onClickShowCryptoKey();
    }
}
+15 −3
Original line number Diff line number Diff line
@@ -70,8 +70,20 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
        try {
            PendingIntent pendingIntent = messageViewInfo.cryptoResultAnnotation.getOpenPgpPendingIntent();
            if (pendingIntent != null) {
                messageCryptoMvpView.startPendingIntentForCryptoPresenter(pendingIntent.getIntentSender(),
                        REQUEST_CODE_UNKNOWN_KEY, null, 0, 0, 0);
                messageCryptoMvpView.startPendingIntentForCryptoPresenter(
                        pendingIntent.getIntentSender(), REQUEST_CODE_UNKNOWN_KEY, null, 0, 0, 0);
            }
        } catch (IntentSender.SendIntentException e) {
            Log.e(K9.LOG_TAG, "SendIntentException", e);
        }
    }

    public void onClickShowCryptoKey() {
        try {
            PendingIntent pendingIntent = messageViewInfo.cryptoResultAnnotation.getOpenPgpPendingIntent();
            if (pendingIntent != null) {
                messageCryptoMvpView.startPendingIntentForCryptoPresenter(
                        pendingIntent.getIntentSender(), null, null, 0, 0, 0);
            }
        } catch (IntentSender.SendIntentException e) {
            Log.e(K9.LOG_TAG, "SendIntentException", e);
@@ -81,7 +93,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
    public interface MessageCryptoMvpView {
        void restartMessageCryptoProcessing();

        void startPendingIntentForCryptoPresenter(IntentSender si, int requestCode, Intent fillIntent,
        void startPendingIntentForCryptoPresenter(IntentSender si, Integer requestCode, Intent fillIntent,
                int flagsMask, int flagValues, int extraFlags) throws IntentSender.SendIntentException;

        void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus);
+14 −2
Original line number Diff line number Diff line
@@ -55,13 +55,14 @@ import com.fsck.k9.ui.crypto.MessageCryptoCallback;
import com.fsck.k9.ui.crypto.MessageCryptoHelper;
import com.fsck.k9.ui.message.LocalMessageExtractorLoader;
import com.fsck.k9.ui.message.LocalMessageLoader;
import com.fsck.k9.ui.messageview.CryptoInfoDialog.OnClickShowCryptoKeyListener;
import com.fsck.k9.ui.messageview.MessageCryptoPresenter.MessageCryptoMvpView;
import com.fsck.k9.view.MessageCryptoDisplayStatus;
import com.fsck.k9.view.MessageHeader;


public class MessageViewFragment extends Fragment implements ConfirmationDialogFragmentListener,
        AttachmentViewCallback, MessageCryptoCallback, MessageCryptoMvpView {
        AttachmentViewCallback, MessageCryptoCallback, MessageCryptoMvpView, OnClickShowCryptoKeyListener {

    private static final String ARG_REFERENCE = "reference";

@@ -770,8 +771,13 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
    }

    @Override
    public void startPendingIntentForCryptoPresenter(IntentSender si, int requestCode, Intent fillIntent,
    public void startPendingIntentForCryptoPresenter(IntentSender si, Integer requestCode, Intent fillIntent,
            int flagsMask, int flagValues, int extraFlags) throws SendIntentException {
        if (requestCode == null) {
            getActivity().startIntentSender(si, fillIntent, flagsMask, flagValues, extraFlags);
            return;
        }

        requestCode |= REQUEST_MASK_CRYPTO_PRESENTER;
        getActivity().startIntentSenderForResult(
                si, requestCode, fillIntent, flagsMask, flagValues, extraFlags);
@@ -780,6 +786,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
    @Override
    public void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus) {
        CryptoInfoDialog dialog = CryptoInfoDialog.newInstance(displayStatus);
        dialog.setTargetFragment(this, 0);
        dialog.show(getFragmentManager(), "crypto_info_dialog");
    }

@@ -801,6 +808,11 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
        }
    }

    @Override
    public void onClickShowCryptoKey() {
        messageCryptoPresenter.onClickShowCryptoKey();
    }

    public interface MessageViewFragmentListener {
        public void onForward(LocalMessage mMessage);
        public void disableDeleteAction();
+22 −0
Original line number Diff line number Diff line
@@ -276,4 +276,26 @@ public enum MessageCryptoDisplayStatus {
        }
    }

    public boolean hasAssociatedKey() {
        switch (this) {
            case ENCRYPTED_SIGN_UNKNOWN:
            case ENCRYPTED_SIGN_VERIFIED:
            case ENCRYPTED_SIGN_UNVERIFIED:
            case ENCRYPTED_SIGN_MISMATCH:
            case ENCRYPTED_SIGN_EXPIRED:
            case ENCRYPTED_SIGN_REVOKED:
            case ENCRYPTED_SIGN_INSECURE:

            case UNENCRYPTED_SIGN_UNKNOWN:
            case UNENCRYPTED_SIGN_VERIFIED:
            case UNENCRYPTED_SIGN_UNVERIFIED:
            case UNENCRYPTED_SIGN_MISMATCH:
            case UNENCRYPTED_SIGN_EXPIRED:
            case UNENCRYPTED_SIGN_REVOKED:
            case UNENCRYPTED_SIGN_INSECURE:
                return true;
        }
        return false;
    }

}
Loading