From aab32b81b9b54e1a978006f33718a9525772ce53 Mon Sep 17 00:00:00 2001 From: Max Mertens Date: Wed, 18 Mar 2015 22:23:35 +0100 Subject: [PATCH] Added comments for server result sorting in key search --- .../keychain/keyimport/ImportKeysList.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 ed096e9dc..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,7 @@ public class ImportKeysList extends ArrayList { 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 @@ -79,6 +80,7 @@ public class ImportKeysList extends ArrayList { // 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; } } @@ -87,6 +89,10 @@ public class ImportKeysList extends ArrayList { ArrayList existingIDs = existing.getUserIds(); for (String incomingID : incomingIDs) { if (!existingIDs.contains(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 {