Added identity menu item to clear sign key

This commit is contained in:
M66B
2019-11-15 08:22:57 +01:00
parent f74c360b92
commit 9bb2b6bd14
3 changed files with 32 additions and 2 deletions

View File

@@ -168,7 +168,10 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
popupMenu.getMenu().add(Menu.NONE, R.string.title_enabled, 1, R.string.title_enabled)
.setCheckable(true).setChecked(identity.synchronize);
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 2, R.string.title_copy);
if (identity.sign_key != 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_copy, 3, R.string.title_copy);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@@ -178,6 +181,10 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
onActionSync(!item.isChecked());
return true;
case R.string.title_reset_sign_key:
onActionClearSignKey();
return true;
case R.string.title_copy:
onActionCopy();
return true;
@@ -213,6 +220,28 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
}.execute(context, owner, args, "identitty:enable");
}
private void onActionClearSignKey() {
Bundle args = new Bundle();
args.putLong("id", identity.id);
new SimpleTask<Boolean>() {
@Override
protected Boolean onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
db.identity().setIdentitySignKey(id, null);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "identitty:clear_sign_key");
}
private void onActionCopy() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(

View File

@@ -256,7 +256,7 @@ public class EntityIdentity {
Objects.equals(this.sender_extra_regex, other.sender_extra_regex) &&
Objects.equals(this.replyto, other.replyto) &&
Objects.equals(this.bcc, other.bcc) &&
this.encrypt.equals(other.encrypt) &&
Objects.equals(this.sign_key, other.sign_key) &&
Objects.equals(this.tbd, other.tbd) &&
Objects.equals(this.state, other.state) &&
Objects.equals(this.error, other.error) &&