diff options
author | Andreas Straub <andy@strb.org> | 2015-07-20 22:18:24 +0200 |
---|---|---|
committer | Andreas Straub <andy@strb.org> | 2015-07-20 22:18:24 +0200 |
commit | ab2d114bbc21a5c2d684f8760cb8e4cea54be5de (patch) | |
tree | 03755711067759016f0940986746506eb63b7630 /src/main/java/eu/siacs/conversations/ui/XmppActivity.java | |
parent | 0ee64124fe317f6959d1ff61cc9e70b272bf8eb5 (diff) |
Add purge axolotl key option
Can now long-press a key to permanently purge it.
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/XmppActivity.java | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 69357224d..197836278 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -601,11 +601,11 @@ public abstract class XmppActivity extends Activity { builder.create().show(); } - protected void addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey) { + protected boolean addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey) { final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", ""); final AxolotlService.SQLiteAxolotlStore.Trust trust = account.getAxolotlService() .getFingerprintTrust(fingerprint); - addFingerprintRowWithListeners(keys, account, identityKey, trust, true, + return addFingerprintRowWithListeners(keys, account, identityKey, trust, true, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -633,13 +633,16 @@ public abstract class XmppActivity extends Activity { ); } - protected void addFingerprintRowWithListeners(LinearLayout keys, final Account account, - IdentityKey identityKey, + protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account, + final IdentityKey identityKey, AxolotlService.SQLiteAxolotlStore.Trust trust, boolean showTag, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, View.OnClickListener onClickListener) { + if (trust == AxolotlService.SQLiteAxolotlStore.Trust.COMPROMISED) { + return false; + } View view = getLayoutInflater().inflate(R.layout.contact_key, keys, false); TextView key = (TextView) view.findViewById(R.id.key); TextView keyType = (TextView) view.findViewById(R.id.key_type); @@ -647,6 +650,13 @@ public abstract class XmppActivity extends Activity { trustToggle.setVisibility(View.VISIBLE); trustToggle.setOnCheckedChangeListener(onCheckedChangeListener); trustToggle.setOnClickListener(onClickListener); + view.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + showPurgeKeyDialog(account, identityKey); + return true; + } + }); switch (trust) { case UNTRUSTED: @@ -668,7 +678,26 @@ public abstract class XmppActivity extends Activity { key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint())); keys.addView(view); + return true; + } + public void showPurgeKeyDialog(final Account account, final IdentityKey identityKey) { + Builder builder = new Builder(this); + builder.setTitle(getString(R.string.purge_key)); + builder.setIconAttribute(android.R.attr.alertDialogIcon); + builder.setMessage(getString(R.string.purge_key_desc_part1) + + "\n\n" + CryptoHelper.prettifyFingerprint(identityKey.getFingerprint()) + + "\n\n" + getString(R.string.purge_key_desc_part2)); + builder.setNegativeButton(getString(R.string.cancel), null); + builder.setPositiveButton(getString(R.string.accept), + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + account.getAxolotlService().purgeKey(identityKey); + refreshUi(); + } + }); + builder.create().show(); } public void selectPresence(final Conversation conversation, |