Prevent pgp/inline in sign-only mode and vice versa

This commit is contained in:
Vincent Breitmoser 2016-11-14 14:18:19 +01:00
parent b72a3ce8a0
commit 0378f1a812
3 changed files with 29 additions and 4 deletions

View file

@ -335,7 +335,15 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
Toast.makeText(activity, R.string.compose_error_private_missing_keys, Toast.LENGTH_LONG).show();
}
public void showErrorAttachInline() {
public void showErrorSignOnlyInline() {
Toast.makeText(activity, R.string.error_crypto_sign_only_inline, Toast.LENGTH_LONG).show();
}
public void showErrorInlineSignOnly() {
Toast.makeText(activity, R.string.error_crypto_inline_sign_only, Toast.LENGTH_LONG).show();
}
public void showErrorInlineAttach() {
Toast.makeText(activity, R.string.error_crypto_inline_attach, Toast.LENGTH_LONG).show();
}

View file

@ -602,7 +602,7 @@ public class RecipientPresenter implements PermissionPingCallback {
public void showPgpAttachError(AttachErrorState attachErrorState) {
switch (attachErrorState) {
case IS_INLINE:
recipientMvpView.showErrorAttachInline();
recipientMvpView.showErrorInlineAttach();
break;
default:
throw new AssertionError("not all error states handled, this is a bug!");
@ -721,8 +721,17 @@ public class RecipientPresenter implements PermissionPingCallback {
}
public void onMenuSetPgpInline(boolean enablePgpInline) {
cryptoEnablePgpInline = enablePgpInline;
updateCryptoStatus();
if (getCurrentCryptoStatus().isSignOnly()) {
if (cryptoEnablePgpInline) {
Log.e(K9.LOG_TAG, "Inconsistent state: PGP/INLINE was enabled in sign-only mode!");
onCryptoPgpInlineChanged(false);
}
recipientMvpView.showErrorSignOnlyInline();
return;
}
onCryptoPgpInlineChanged(enablePgpInline);
if (enablePgpInline) {
boolean shouldShowPgpInlineDialog = checkAndIncrementPgpInlineDialogCounter();
if (shouldShowPgpInlineDialog) {
@ -733,6 +742,12 @@ public class RecipientPresenter implements PermissionPingCallback {
public void onMenuSetSignOnly(boolean enableSignOnly) {
if (enableSignOnly) {
if (getCurrentCryptoStatus().isPgpInlineModeEnabled()) {
recipientMvpView.showErrorInlineSignOnly();
return;
}
onCryptoPgpInlineChanged(false);
onCryptoModeChanged(CryptoMode.SIGN_ONLY);
boolean shouldShowPgpSignOnlyDialog = checkAndIncrementPgpSignOnlyDialogCounter();
if (shouldShowPgpSignOnlyDialog) {

View file

@ -1161,6 +1161,8 @@ Please submit bug reports, contribute new features and ask questions at
<string name="error_crypto_provider_connect">Cannot connect to crypto provider, check your settings or click crypto icon to retry!</string>
<string name="error_crypto_provider_ui_required">Crypto provider access denied, click crypto icon to retry!</string>
<string name="error_crypto_inline_attach">PGP/INLINE mode does not support attachments!</string>
<string name="error_crypto_inline_sign_only">PGP/INLINE mode does not support sign-only mode!</string>
<string name="error_crypto_sign_only_inline">Sign-Only mode does not support PGP/INLINE!</string>
<string name="enable_inline_pgp">Enable PGP/INLINE</string>
<string name="disable_inline_pgp">Disable PGP/INLINE</string>
<string name="enable_sign_only">Enable PGP Sign-Only</string>