diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 050821b074..71e0ebbc0d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -4692,78 +4692,72 @@ public class FragmentCompose extends FragmentBase { snackbar.setAction(R.string.title_fix, new View.OnClickListener() { @Override public void onClick(View v) { - if (ex.getCause() instanceof CertificateException) - v.getContext().startActivity(new Intent(v.getContext(), ActivitySetup.class) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) - .putExtra("tab", "encryption")); - else { - EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem(); + EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem(); - PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), vwAnchor); - popupMenu.getMenu().add(Menu.NONE, R.string.title_send_dialog, 1, R.string.title_send_dialog); - if (identity != null) - popupMenu.getMenu().add(Menu.NONE, R.string.title_reset_sign_key, 2, R.string.title_reset_sign_key); - popupMenu.getMenu().add(Menu.NONE, R.string.title_advanced_manage_certificates, 3, R.string.title_advanced_manage_certificates); + PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), vwAnchor); + popupMenu.getMenu().add(Menu.NONE, R.string.title_send_dialog, 1, R.string.title_send_dialog); + if (identity != null) + popupMenu.getMenu().add(Menu.NONE, R.string.title_reset_sign_key, 2, R.string.title_reset_sign_key); + popupMenu.getMenu().add(Menu.NONE, R.string.title_advanced_manage_certificates, 3, R.string.title_advanced_manage_certificates); - popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - int itemId = item.getItemId(); - if (itemId == R.string.title_send_dialog) { - Helper.hideKeyboard(view); + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + int itemId = item.getItemId(); + if (itemId == R.string.title_send_dialog) { + Helper.hideKeyboard(view); - FragmentDialogSend fragment = new FragmentDialogSend(); - fragment.setArguments(args); - fragment.setTargetFragment(FragmentCompose.this, REQUEST_SEND); - fragment.show(getParentFragmentManager(), "compose:send"); - return true; - } else if (itemId == R.string.title_reset_sign_key) { - Bundle args = new Bundle(); - args.putLong("id", identity.id); + FragmentDialogSend fragment = new FragmentDialogSend(); + fragment.setArguments(args); + fragment.setTargetFragment(FragmentCompose.this, REQUEST_SEND); + fragment.show(getParentFragmentManager(), "compose:send"); + return true; + } else if (itemId == R.string.title_reset_sign_key) { + Bundle args = new Bundle(); + args.putLong("id", identity.id); - new SimpleTask() { - @Override - protected void onPostExecute(Bundle args) { - ToastEx.makeText(getContext(), R.string.title_completed, Toast.LENGTH_LONG).show(); + new SimpleTask() { + @Override + protected void onPostExecute(Bundle args) { + ToastEx.makeText(getContext(), R.string.title_completed, Toast.LENGTH_LONG).show(); + } + + @Override + protected Void onExecute(Context context, Bundle args) throws Throwable { + long id = args.getLong("id"); + + DB db = DB.getInstance(context); + try { + db.beginTransaction(); + + db.identity().setIdentitySignKey(id, null); + db.identity().setIdentitySignKeyAlias(id, null); + db.identity().setIdentityEncrypt(id, 0); + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); } - @Override - protected Void onExecute(Context context, Bundle args) throws Throwable { - long id = args.getLong("id"); + return null; + } - DB db = DB.getInstance(context); - try { - db.beginTransaction(); - - db.identity().setIdentitySignKey(id, null); - db.identity().setIdentitySignKeyAlias(id, null); - db.identity().setIdentityEncrypt(id, 0); - - db.setTransactionSuccessful(); - } finally { - db.endTransaction(); - } - - return null; - } - - @Override - protected void onException(Bundle args, Throwable ex) { - Log.unexpectedError(getParentFragmentManager(), ex); - } - }.execute(FragmentCompose.this, args, "identity:reset"); - } else if (itemId == R.string.title_advanced_manage_certificates) { - startActivity(new Intent(getContext(), ActivitySetup.class) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) - .putExtra("tab", "encryption")); - return true; - } - return false; + @Override + protected void onException(Bundle args, Throwable ex) { + Log.unexpectedError(getParentFragmentManager(), ex); + } + }.execute(FragmentCompose.this, args, "identity:reset"); + } else if (itemId == R.string.title_advanced_manage_certificates) { + startActivity(new Intent(getContext(), ActivitySetup.class) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) + .putExtra("tab", "encryption")); + return true; } - }); + return false; + } + }); - popupMenu.show(); - } + popupMenu.show(); } }); snackbar.show();