From 7de86a09bc3bae47c44b9dcb65bbda1298ccf843 Mon Sep 17 00:00:00 2001 From: Tim Bray Date: Sat, 13 Sep 2014 09:39:10 -0700 Subject: [PATCH] Change shuffle to rotate, and when merging ImportKeysList entries, if either side is revoked/expired, the merge reflects that --- .../keychain/keyimport/ImportKeysList.java | 12 ++++++++++-- .../keychain/keyimport/KeybaseKeyserver.java | 2 ++ .../keychain/ui/PreferencesKeyServerActivity.java | 6 +++--- .../src/main/res/layout/key_server_preference.xml | 4 ++-- 4 files changed, 17 insertions(+), 7 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 15de8cb8f..00bbca69c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java @@ -50,15 +50,23 @@ public class ImportKeysList extends ArrayList { private synchronized boolean addOrMerge(ImportKeysListEntry toAdd) { for (ImportKeysListEntry existing : this) { if (toAdd.hasSameKeyAs(existing)) { - return mergeIDs(toAdd, existing); + return mergeDupes(toAdd, existing); } } return super.add(toAdd); } // being a little anal about the ArrayList#addAll contract here - private boolean mergeIDs(ImportKeysListEntry incoming, ImportKeysListEntry existing) { + private boolean mergeDupes(ImportKeysListEntry incoming, ImportKeysListEntry existing) { boolean modified = false; + if (incoming.isRevoked()) { + existing.setRevoked(true); + modified = true; + } + if (incoming.isExpired()) { + existing.setExpired(true); + modified = true; + } ArrayList incomingIDs = incoming.getUserIds(); ArrayList existingIDs = existing.getUserIds(); for (String incomingID : incomingIDs) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java index cbd06da90..ff582e5ed 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java @@ -65,6 +65,8 @@ public class KeybaseKeyserver extends Keyserver { entry.setQuery(mQuery); entry.setOrigin(ORIGIN); + entry.setRevoked(false); // keybase doesn’t say anything about revoked keys + String username = match.getUsername(); String fullName = match.getFullName(); String fingerprint = match.getFingerprint(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java index b5e0e2ab5..520f0b6a5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java @@ -43,7 +43,7 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O private LayoutInflater mInflater; private ViewGroup mEditors; private View mAdd; - private View mShuffle; + private View mRotate; private TextView mTitle; private TextView mSummary; @@ -82,8 +82,8 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O mAdd = findViewById(R.id.add); mAdd.setOnClickListener(this); - mShuffle = findViewById(R.id.shuffle); - mShuffle.setOnClickListener(new OnClickListener() { + mRotate = findViewById(R.id.rotate); + mRotate.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Vector servers = serverList(); diff --git a/OpenKeychain/src/main/res/layout/key_server_preference.xml b/OpenKeychain/src/main/res/layout/key_server_preference.xml index 140b5e3d7..5bcb06831 100644 --- a/OpenKeychain/src/main/res/layout/key_server_preference.xml +++ b/OpenKeychain/src/main/res/layout/key_server_preference.xml @@ -39,13 +39,13 @@ android:textAppearance="?android:attr/textAppearanceSmall" />