diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-03-18 22:58:39 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-03-18 22:58:39 +0100 |
commit | d25cc08be4c75a1cf8d60198491019a4336c96cb (patch) | |
tree | 7701fa73b5bdf3fbaba9ad5e63b8215fb350c4d3 | |
parent | 53d7c1f5330a6b5e83d27196ae4145e364af2cd3 (diff) | |
parent | aab32b81b9b54e1a978006f33718a9525772ce53 (diff) | |
download | open-keychain-d25cc08be4c75a1cf8d60198491019a4336c96cb.tar.gz open-keychain-d25cc08be4c75a1cf8d60198491019a4336c96cb.tar.bz2 open-keychain-d25cc08be4c75a1cf8d60198491019a4336c96cb.zip |
Merge pull request #1160 from jellysheep/cloudsearch-show-main-email
Show HKP server results first in key cloud search. Fixes #1066
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java index 02cb502d0..03439228b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java @@ -70,6 +70,8 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> { modified = true; } + // keep track if this key result is from a HKP keyserver + boolean incomingFromHkpServer = true; // we’re going to want to try to fetch the key from everywhere we found it, so remember // all the origins for (String origin : incoming.getOrigins()) { @@ -78,13 +80,24 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> { // to work properly, Keybase-sourced entries need to pass along the extra if (KeybaseKeyserver.ORIGIN.equals(origin)) { existing.setExtraData(incoming.getExtraData()); + // one of the origins is not a HKP keyserver + incomingFromHkpServer = false; } } + ArrayList<String> incomingIDs = incoming.getUserIds(); ArrayList<String> existingIDs = existing.getUserIds(); for (String incomingID : incomingIDs) { if (!existingIDs.contains(incomingID)) { - existingIDs.add(incomingID); + // prepend HKP server results to the start of the list, + // so that the UI (for cloud key search, which is picking the first list item) + // shows the right main email address, as mail addresses returned by HKP servers + // are preferred over keybase.io IDs + if (incomingFromHkpServer) { + existingIDs.add(0, incomingID); + } else { + existingIDs.add(incomingID); + } modified = true; } } |