Change shuffle to rotate, and when merging ImportKeysList entries, if either side is revoked/expired, the merge reflects that

This commit is contained in:
Tim Bray 2014-09-13 09:39:10 -07:00
parent e14cf32264
commit 7de86a09bc
4 changed files with 17 additions and 7 deletions

View File

@ -50,15 +50,23 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> {
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<String> incomingIDs = incoming.getUserIds();
ArrayList<String> existingIDs = existing.getUserIds();
for (String incomingID : incomingIDs) {

View File

@ -65,6 +65,8 @@ public class KeybaseKeyserver extends Keyserver {
entry.setQuery(mQuery);
entry.setOrigin(ORIGIN);
entry.setRevoked(false); // keybase doesnt say anything about revoked keys
String username = match.getUsername();
String fullName = match.getFullName();
String fingerprint = match.getFingerprint();

View File

@ -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<String> servers = serverList();

View File

@ -39,13 +39,13 @@
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<Button
android:id="@+id/shuffle"
android:id="@+id/rotate"
android:layout_width="wrap_content"
android:layout_height="31dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dip"
android:layout_marginRight="6dip"
android:text="shuffle"
android:text="rotate"
android:textColor="#ffffffff"
android:textStyle="bold"
android:paddingTop="2dp"