From a95c451f1e6ee69fbf3b0072d672c3609a4b1e7d Mon Sep 17 00:00:00 2001 From: Andreas Straub Date: Sun, 6 Sep 2015 15:08:42 +0200 Subject: Only show that have sessions in fingerprint list Doesn't access database directly anymore but goes through AxolotlService now to obtain list of fingerprints associated with an Account/Contact. This should prevent orphaned keys littering the UI which previously couldn't be removed through the Clear Devices function. Together with 1c79982da84964c1d81179a0927d9cd1eadf53de this fixes #1393 --- .../siacs/conversations/ui/TrustKeysActivity.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java') diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java index 0e685c3ee..ab3130748 100644 --- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java @@ -43,8 +43,8 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate private Button mSaveButton; private Button mCancelButton; - private final Map ownKeysToTrust = new HashMap<>(); - private final Map foreignKeysToTrust = new HashMap<>(); + private final Map ownKeysToTrust = new HashMap<>(); + private final Map foreignKeysToTrust = new HashMap<>(); private final OnClickListener mSaveButtonListener = new OnClickListener() { @Override @@ -120,28 +120,28 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate foreignKeys.removeAllViews(); boolean hasOwnKeys = false; boolean hasForeignKeys = false; - for(final IdentityKey identityKey : ownKeysToTrust.keySet()) { + for(final String fingerprint : ownKeysToTrust.keySet()) { hasOwnKeys = true; - addFingerprintRowWithListeners(ownKeys, contact.getAccount(), identityKey, false, - XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(identityKey)), false, + addFingerprintRowWithListeners(ownKeys, contact.getAccount(), fingerprint, false, + XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(fingerprint)), false, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - ownKeysToTrust.put(identityKey, isChecked); + ownKeysToTrust.put(fingerprint, isChecked); // own fingerprints have no impact on locked status. } }, null ); } - for(final IdentityKey identityKey : foreignKeysToTrust.keySet()) { + for(final String fingerprint : foreignKeysToTrust.keySet()) { hasForeignKeys = true; - addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), identityKey, false, - XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(identityKey)), false, + addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), fingerprint, false, + XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(fingerprint)), false, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - foreignKeysToTrust.put(identityKey, isChecked); + foreignKeysToTrust.put(fingerprint, isChecked); lockOrUnlockAsNeeded(); } }, @@ -181,12 +181,12 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate } for(final IdentityKey identityKey : ownKeysSet) { if(!ownKeysToTrust.containsKey(identityKey)) { - ownKeysToTrust.put(identityKey, false); + ownKeysToTrust.put(identityKey.getFingerprint().replaceAll("\\s", ""), false); } } for(final IdentityKey identityKey : foreignKeysSet) { if(!foreignKeysToTrust.containsKey(identityKey)) { - foreignKeysToTrust.put(identityKey, false); + foreignKeysToTrust.put(identityKey.getFingerprint().replaceAll("\\s", ""), false); } } } @@ -225,15 +225,15 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate } private void commitTrusts() { - for(IdentityKey identityKey:ownKeysToTrust.keySet()) { + for(final String fingerprint :ownKeysToTrust.keySet()) { contact.getAccount().getAxolotlService().setFingerprintTrust( - identityKey.getFingerprint().replaceAll("\\s", ""), - XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(identityKey))); + fingerprint, + XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(fingerprint))); } - for(IdentityKey identityKey:foreignKeysToTrust.keySet()) { + for(final String fingerprint:foreignKeysToTrust.keySet()) { contact.getAccount().getAxolotlService().setFingerprintTrust( - identityKey.getFingerprint().replaceAll("\\s", ""), - XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(identityKey))); + fingerprint, + XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(fingerprint))); } } -- cgit v1.2.3