aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-10 02:56:44 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 22:23:27 +0200
commit3d339460889644c859d932eb3f2e324bd5696707 (patch)
treee78c64e213b8b8483063c1bb13600d8122a88c5d /src/main/java/eu/siacs
parent35714d3d08d287c5ded125c356835fb70ab342b7 (diff)
Add key trust toggle to ContactDetailsActivity
Can now toggle IdentityKey trust
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java49
1 files changed, 39 insertions, 10 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 4ff47f9e..ebc1ae83 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -35,6 +35,7 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
+import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.ListItem;
@@ -363,13 +364,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
View view = inflater.inflate(R.layout.contact_key, keys, false);
TextView key = (TextView) view.findViewById(R.id.key);
TextView keyType = (TextView) view.findViewById(R.id.key_type);
- ImageButton remove = (ImageButton) view
+ ImageButton removeButton = (ImageButton) view
.findViewById(R.id.button_remove);
- remove.setVisibility(View.VISIBLE);
+ removeButton.setVisibility(View.VISIBLE);
keyType.setText("OTR Fingerprint");
key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
keys.addView(view);
- remove.setOnClickListener(new OnClickListener() {
+ removeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -384,19 +385,47 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
TextView key = (TextView) view.findViewById(R.id.key);
TextView keyType = (TextView) view.findViewById(R.id.key_type);
TextView keyTrust = (TextView) view.findViewById(R.id.key_trust);
- ImageButton remove = (ImageButton) view
+ ImageButton removeButton = (ImageButton) view
.findViewById(R.id.button_remove);
- remove.setVisibility(View.VISIBLE);
- keyTrust.setVisibility(View.VISIBLE);
+ ImageButton trustButton = (ImageButton) view
+ .findViewById(R.id.button_trust);
+ final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
+ final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", "");
+ final Jid bareJid = contactJid.toBareJid();
+ AxolotlService.SQLiteAxolotlStore.Trust trust = contact.getAccount().getAxolotlService()
+ .getFingerprintTrust(bareJid.toString(), fingerprint);
+ switch (trust) {
+ case TRUSTED:
+ removeButton.setVisibility(View.VISIBLE);
+ //Log.d(Config.LOGTAG, AxolotlService.getLogprefix(contact.getAccount()) + "Setting remove button visible!");
+ break;
+ case UNDECIDED:
+ case UNTRUSTED:
+ //Log.d(Config.LOGTAG, AxolotlService.getLogprefix(contact.getAccount()) + "Setting trust button visible!");
+ trustButton.setVisibility(View.VISIBLE);
+ break;
+ }
keyType.setText("Axolotl Fingerprint");
key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint()));
- keyTrust.setText(contact.getAccount().getAxolotlService().getFingerprintTrust(contact.getJid().toBareJid().toString(), identityKey.getFingerprint().replaceAll("\\s","")).toString());
+ keyTrust.setText(trust.toString());
+ keyTrust.setVisibility(View.VISIBLE);
keys.addView(view);
- remove.setOnClickListener(new OnClickListener() {
-
+ removeButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ axolotlService.setFingerprintTrust(bareJid.toString(), fingerprint,
+ AxolotlService.SQLiteAxolotlStore.Trust.UNTRUSTED);
+ refreshUi();
+ xmppConnectionService.updateConversationUi();
+ }
+ });
+ trustButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- //confirmToDeleteFingerprint(otrFingerprint);
+ axolotlService.setFingerprintTrust(bareJid.toString(), fingerprint,
+ AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED);
+ refreshUi();
+ xmppConnectionService.updateConversationUi();
}
});
}