use hashcode instead of keyid in import list (keyids may not be unique!)

This commit is contained in:
Vincent Breitmoser 2014-06-22 13:32:07 +02:00
parent a1525bffe2
commit 857b15cbd5
3 changed files with 12 additions and 2 deletions

View File

@ -46,6 +46,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
private String mExtraData;
private String mQuery;
private String mOrigin;
private Integer mHashCode = null;
private boolean mSelected;
@ -98,6 +99,13 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
}
};
public int hashCode() {
if (mHashCode != null) {
return mHashCode;
}
return super.hashCode();
}
public String getKeyIdHex() {
return mKeyIdHex;
}
@ -240,6 +248,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
mSecretKey = ring.isSecret();
UncachedPublicKey key = ring.getPublicKey();
mHashCode = key.hashCode();
mPrimaryUserId = key.getPrimaryUserId();
mUserIds = key.getUnorderedUserIds();

View File

@ -79,7 +79,7 @@ public class ImportKeysListFragment extends ListFragment implements
public ArrayList<ParcelableKeyRing> getSelectedData() {
ArrayList<ParcelableKeyRing> result = new ArrayList<ParcelableKeyRing>();
for (ImportKeysListEntry entry : getSelectedEntries()) {
result.add(mCachedKeyData.get(entry.getKeyId()));
result.add(mCachedKeyData.get(entry.hashCode()));
}
return result;
}

View File

@ -138,7 +138,7 @@ public class ImportKeysListLoader
for(UncachedKeyRing key : rings) {
ImportKeysListEntry item = new ImportKeysListEntry(getContext(), key);
mData.add(item);
mParcelableRings.put(key.getMasterKeyId(), new ParcelableKeyRing(key.getEncoded()));
mParcelableRings.put(item.hashCode(), new ParcelableKeyRing(key.getEncoded()));
isEmpty = false;
}
}