improve error dialog behavior if crypto not available but enabled from menu

This commit is contained in:
Vincent Breitmoser 2017-08-24 15:54:51 +02:00
parent c3d5dbf0b7
commit 99a1725765
4 changed files with 78 additions and 76 deletions

View file

@ -42,15 +42,8 @@ public class PgpEnabledErrorDialog extends HighlightDialogFragment {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(view);
if (isGotItDialog) {
builder.setNeutralButton(R.string.openpgp_enabled_error_gotit, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
} else {
builder.setNegativeButton(R.string.openpgp_enabled_error_back, new OnClickListener() {
builder.setNegativeButton(isGotItDialog ? R.string.openpgp_enabled_error_gotit :
R.string.openpgp_enabled_error_back, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
@ -68,7 +61,6 @@ public class PgpEnabledErrorDialog extends HighlightDialogFragment {
dialog.dismiss();
}
});
}
return builder.create();
}

View file

@ -418,13 +418,13 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
dialog.show(activity.getFragmentManager(), "openpgp_signonly");
}
public void showOpenPgpEnabledErrorDialog(boolean isGotItDialog) {
PgpEnabledErrorDialog dialog = PgpEnabledErrorDialog.newInstance(isGotItDialog, R.id.crypto_status);
public void showOpenPgpEnabledErrorDialog(final boolean isGotItDialog) {
PgpEnabledErrorDialog dialog = PgpEnabledErrorDialog.newInstance(isGotItDialog, R.id.crypto_status_anchor);
dialog.show(activity.getFragmentManager(), "openpgp_error");
}
public void showOpenPgpEncryptExplanationDialog() {
PgpEncryptDescriptionDialog dialog = PgpEncryptDescriptionDialog.newInstance(R.id.crypto_status);
PgpEncryptDescriptionDialog dialog = PgpEncryptDescriptionDialog.newInstance(R.id.crypto_status_anchor);
dialog.show(activity.getFragmentManager(), "openpgp_description");
}

View file

@ -896,6 +896,7 @@ public class RecipientPresenter implements PermissionPingCallback {
}
if (enableEncryption) {
if (!cachedCryptoStatus.canEncrypt()) {
onCryptoModeChanged(CryptoMode.CHOICE_ENABLED);
recipientMvpView.showOpenPgpEnabledErrorDialog(true);
} else if (cachedCryptoStatus.canEncryptAndIsMutual()) {
onCryptoModeChanged(CryptoMode.NO_CHOICE);

View file

@ -101,12 +101,19 @@
</com.fsck.k9.view.ToolableViewAnimator>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:clipChildren="false"
android:id="@+id/crypto_status_anchor"
>
<com.fsck.k9.view.ToolableViewAnimator
android:layout_width="36dp"
android:layout_height="32dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:id="@+id/crypto_status"
android:visibility="gone"
tools:visibility="visible"
@ -167,6 +174,8 @@
</com.fsck.k9.view.ToolableViewAnimator>
</FrameLayout>
</LinearLayout>
<View