use of com.fsck.k9.view.MessageCryptoDisplayStatus in project k-9 by k9mail.
the class CryptoInfoDialog method onCreateDialog.
// inflating without root element is fine for creating a dialog
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Builder b = new AlertDialog.Builder(getActivity());
dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.message_crypto_info_dialog, null);
topIconFrame = dialogView.findViewById(R.id.crypto_info_top_frame);
topIcon_1 = (ImageView) topIconFrame.findViewById(R.id.crypto_info_top_icon_1);
topIcon_2 = (ImageView) topIconFrame.findViewById(R.id.crypto_info_top_icon_2);
topIcon_3 = (ImageView) topIconFrame.findViewById(R.id.crypto_info_top_icon_3);
topText = (TextView) dialogView.findViewById(R.id.crypto_info_top_text);
bottomIconFrame = dialogView.findViewById(R.id.crypto_info_bottom_frame);
bottomIcon_1 = (ImageView) bottomIconFrame.findViewById(R.id.crypto_info_bottom_icon_1);
bottomIcon_2 = (ImageView) bottomIconFrame.findViewById(R.id.crypto_info_bottom_icon_2);
bottomText = (TextView) dialogView.findViewById(R.id.crypto_info_bottom_text);
MessageCryptoDisplayStatus displayStatus = MessageCryptoDisplayStatus.valueOf(getArguments().getString(ARG_DISPLAY_STATUS));
setMessageForDisplayStatus(displayStatus);
b.setView(dialogView);
b.setPositiveButton(R.string.crypto_info_ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
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();
}
use of com.fsck.k9.view.MessageCryptoDisplayStatus in project k-9 by k9mail.
the class MessageCryptoPresenter method maybeHandleShowMessage.
public boolean maybeHandleShowMessage(MessageTopView messageView, Account account, MessageViewInfo messageViewInfo) {
this.cryptoResultAnnotation = messageViewInfo.cryptoResultAnnotation;
MessageCryptoDisplayStatus displayStatus = MessageCryptoDisplayStatus.fromResultAnnotation(messageViewInfo.cryptoResultAnnotation);
if (displayStatus == MessageCryptoDisplayStatus.DISABLED) {
return false;
}
boolean suppressSignOnlyMessages = !K9.getOpenPgpSupportSignOnly();
if (suppressSignOnlyMessages && displayStatus.isUnencryptedSigned()) {
return false;
}
messageView.getMessageHeaderView().setCryptoStatus(displayStatus);
switch(displayStatus) {
case UNENCRYPTED_SIGN_REVOKED:
case ENCRYPTED_SIGN_REVOKED:
{
showMessageCryptoWarning(messageView, account, messageViewInfo, R.string.messageview_crypto_warning_revoked);
break;
}
case UNENCRYPTED_SIGN_EXPIRED:
case ENCRYPTED_SIGN_EXPIRED:
{
showMessageCryptoWarning(messageView, account, messageViewInfo, R.string.messageview_crypto_warning_expired);
break;
}
case UNENCRYPTED_SIGN_INSECURE:
case ENCRYPTED_SIGN_INSECURE:
{
showMessageCryptoWarning(messageView, account, messageViewInfo, R.string.messageview_crypto_warning_insecure);
break;
}
case UNENCRYPTED_SIGN_ERROR:
case ENCRYPTED_SIGN_ERROR:
{
showMessageCryptoWarning(messageView, account, messageViewInfo, R.string.messageview_crypto_warning_error);
break;
}
case ENCRYPTED_UNSIGNED:
{
showMessageCryptoWarning(messageView, account, messageViewInfo, R.string.messageview_crypto_warning_unsigned);
break;
}
case CANCELLED:
{
Drawable providerIcon = getOpenPgpApiProviderIcon(messageView.getContext());
messageView.showMessageCryptoCancelledView(messageViewInfo, providerIcon);
break;
}
case INCOMPLETE_ENCRYPTED:
{
Drawable providerIcon = getOpenPgpApiProviderIcon(messageView.getContext());
messageView.showMessageEncryptedButIncomplete(messageViewInfo, providerIcon);
break;
}
case ENCRYPTED_ERROR:
case UNSUPPORTED_ENCRYPTED:
{
Drawable providerIcon = getOpenPgpApiProviderIcon(messageView.getContext());
messageView.showMessageCryptoErrorView(messageViewInfo, providerIcon);
break;
}
case ENCRYPTED_NO_PROVIDER:
{
messageView.showCryptoProviderNotConfigured(messageViewInfo);
break;
}
case INCOMPLETE_SIGNED:
case UNSUPPORTED_SIGNED:
default:
{
messageView.showMessage(account, messageViewInfo);
break;
}
case LOADING:
{
throw new IllegalStateException("Displaying message while in loading state!");
}
}
return true;
}
Aggregations