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,33 +42,25 @@ 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();
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();
}
});
builder.setPositiveButton(R.string.openpgp_enabled_error_disable, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Activity activity = getActivity();
if (activity == null) {
return;
}
});
} else {
builder.setNegativeButton(R.string.openpgp_enabled_error_back, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setPositiveButton(R.string.openpgp_enabled_error_disable, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Activity activity = getActivity();
if (activity == null) {
return;
}
((OnOpenPgpDisableListener) activity).onOpenPgpClickDisable();
dialog.dismiss();
}
});
}
((OnOpenPgpDisableListener) activity).onOpenPgpClickDisable();
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,71 +101,80 @@
</com.fsck.k9.view.ToolableViewAnimator>
<com.fsck.k9.view.ToolableViewAnimator
android:layout_width="36dp"
android:layout_height="32dp"
<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:layout_gravity="center_vertical"
android:id="@+id/crypto_status"
android:visibility="gone"
tools:visibility="visible"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
custom:previewInitialChild="0">
android:clipChildren="false"
android:id="@+id/crypto_status_anchor"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/crypto_status_disabled"
android:src="@drawable/status_lock_disabled"
android:tint="?attr/openpgp_dark_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/crypto_status_enabled"
android:src="@drawable/status_lock"
android:tint="?attr/openpgp_green"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/crypto_status_trusted"
>
<com.fsck.k9.view.ToolableViewAnimator
android:layout_width="36dp"
android:layout_height="32dp"
android:id="@+id/crypto_status"
android:visibility="gone"
tools:visibility="visible"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
custom:previewInitialChild="0">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="?attr/openpgp_grey"
android:layout_gravity="center"
android:id="@+id/crypto_status_disabled"
android:src="@drawable/status_lock_disabled"
android:tint="?attr/openpgp_dark_grey"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_lock_dots_3"
android:layout_gravity="center"
android:id="@+id/crypto_status_enabled"
android:src="@drawable/status_lock"
android:tint="?attr/openpgp_green"
/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/crypto_status_trusted"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/crypto_status_error"
android:src="@drawable/status_lock_error"
android:tint="?attr/openpgp_red"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_dots"
android:tint="?attr/openpgp_grey"
/>
</com.fsck.k9.view.ToolableViewAnimator>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/status_lock_dots_3"
android:tint="?attr/openpgp_green"
/>
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/crypto_status_error"
android:src="@drawable/status_lock_error"
android:tint="?attr/openpgp_red"
/>
</com.fsck.k9.view.ToolableViewAnimator>
</FrameLayout>
</LinearLayout>