diff --git a/app/src/main/java/eu/faircode/email/DaoIdentity.java b/app/src/main/java/eu/faircode/email/DaoIdentity.java index a5f2bb2d29..06db743d5d 100644 --- a/app/src/main/java/eu/faircode/email/DaoIdentity.java +++ b/app/src/main/java/eu/faircode/email/DaoIdentity.java @@ -141,6 +141,9 @@ public interface DaoIdentity { @Query("UPDATE identity SET sign_key_alias = :alias WHERE id = :id AND NOT (sign_key_alias IS :alias)") int setIdentitySignKeyAlias(long id, String alias); + @Query("UPDATE identity SET sign_key_alias = NULL") + int clearIdentitySignKeyAliases(); + @Query("UPDATE identity SET max_size = :max_size WHERE id = :id AND NOT (max_size IS :max_size)") int setIdentityMaxSize(long id, Long max_size); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsEncryption.java b/app/src/main/java/eu/faircode/email/FragmentOptionsEncryption.java index a669b597fd..50e4e15810 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsEncryption.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsEncryption.java @@ -89,6 +89,7 @@ public class FragmentOptionsEncryption extends FragmentBase private SwitchCompat swEncryptAuto; private SwitchCompat swAutoDecrypt; private SwitchCompat swAutoUndoDecrypt; + private Button btnReset; private Spinner spOpenPgp; private ImageButton ibOpenKeychain; @@ -140,6 +141,7 @@ public class FragmentOptionsEncryption extends FragmentBase swEncryptAuto = view.findViewById(R.id.swEncryptAuto); swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt); swAutoUndoDecrypt = view.findViewById(R.id.swAutoUndoDecrypt); + btnReset = view.findViewById(R.id.btnReset); spOpenPgp = view.findViewById(R.id.spOpenPgp); ibOpenKeychain = view.findViewById(R.id.ibOpenKeychain); @@ -237,6 +239,30 @@ public class FragmentOptionsEncryption extends FragmentBase } }); + btnReset.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + new SimpleTask() { + @Override + protected Void onExecute(Context context, Bundle args) throws Throwable { + DB db = DB.getInstance(context); + db.identity().clearIdentitySignKeyAliases(); + return null; + } + + @Override + protected void onExecuted(Bundle args, Void data) { + ToastEx.makeText(v.getContext(), R.string.title_completed, Toast.LENGTH_LONG).show(); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Log.unexpectedError(getParentFragmentManager(), ex); + } + }.execute(FragmentOptionsEncryption.this, new Bundle(), "encryption:reset"); + } + }); + // PGP spOpenPgp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/app/src/main/res/layout/fragment_options_encryption.xml b/app/src/main/res/layout/fragment_options_encryption.xml index 28752a7055..76ec8feabd 100644 --- a/app/src/main/res/layout/fragment_options_encryption.xml +++ b/app/src/main/res/layout/fragment_options_encryption.xml @@ -140,6 +140,28 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swAutoDecrypt" app:switchPadding="12dp" /> + +