mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 16:38:50 -05:00
Merge pull request #646 from timbray/master
Clean up keyimport.ImportKeysListEntry
This commit is contained in:
commit
255462def4
@ -32,16 +32,16 @@ import java.util.Date;
|
|||||||
public class ImportKeysListEntry implements Serializable, Parcelable {
|
public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||||
private static final long serialVersionUID = -7797972103284992662L;
|
private static final long serialVersionUID = -7797972103284992662L;
|
||||||
|
|
||||||
public ArrayList<String> userIds;
|
private ArrayList<String> mUserIds;
|
||||||
public long keyId;
|
private long mKeyId;
|
||||||
public String keyIdHex;
|
private String mKeyIdHex;
|
||||||
public boolean revoked;
|
private boolean mRevoked;
|
||||||
public Date date; // TODO: not displayed
|
private Date mDate; // TODO: not displayed
|
||||||
public String fingerprintHex;
|
private String mFingerprintHex;
|
||||||
public int bitStrength;
|
private int mBitStrength;
|
||||||
public String algorithm;
|
private String mAlgorithm;
|
||||||
public boolean secretKey;
|
private boolean mSecretKey;
|
||||||
public String mPrimaryUserId;
|
private String mPrimaryUserId;
|
||||||
private String mExtraData;
|
private String mExtraData;
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
|
|
||||||
@ -54,15 +54,15 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(mPrimaryUserId);
|
dest.writeString(mPrimaryUserId);
|
||||||
dest.writeStringList(userIds);
|
dest.writeStringList(mUserIds);
|
||||||
dest.writeLong(keyId);
|
dest.writeLong(mKeyId);
|
||||||
dest.writeByte((byte) (revoked ? 1 : 0));
|
dest.writeByte((byte) (mRevoked ? 1 : 0));
|
||||||
dest.writeSerializable(date);
|
dest.writeSerializable(mDate);
|
||||||
dest.writeString(fingerprintHex);
|
dest.writeString(mFingerprintHex);
|
||||||
dest.writeString(keyIdHex);
|
dest.writeString(mKeyIdHex);
|
||||||
dest.writeInt(bitStrength);
|
dest.writeInt(mBitStrength);
|
||||||
dest.writeString(algorithm);
|
dest.writeString(mAlgorithm);
|
||||||
dest.writeByte((byte) (secretKey ? 1 : 0));
|
dest.writeByte((byte) (mSecretKey ? 1 : 0));
|
||||||
dest.writeByte((byte) (mSelected ? 1 : 0));
|
dest.writeByte((byte) (mSelected ? 1 : 0));
|
||||||
dest.writeString(mExtraData);
|
dest.writeString(mExtraData);
|
||||||
}
|
}
|
||||||
@ -71,16 +71,16 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
public ImportKeysListEntry createFromParcel(final Parcel source) {
|
public ImportKeysListEntry createFromParcel(final Parcel source) {
|
||||||
ImportKeysListEntry vr = new ImportKeysListEntry();
|
ImportKeysListEntry vr = new ImportKeysListEntry();
|
||||||
vr.mPrimaryUserId = source.readString();
|
vr.mPrimaryUserId = source.readString();
|
||||||
vr.userIds = new ArrayList<String>();
|
vr.mUserIds = new ArrayList<String>();
|
||||||
source.readStringList(vr.userIds);
|
source.readStringList(vr.mUserIds);
|
||||||
vr.keyId = source.readLong();
|
vr.mKeyId = source.readLong();
|
||||||
vr.revoked = source.readByte() == 1;
|
vr.mRevoked = source.readByte() == 1;
|
||||||
vr.date = (Date) source.readSerializable();
|
vr.mDate = (Date) source.readSerializable();
|
||||||
vr.fingerprintHex = source.readString();
|
vr.mFingerprintHex = source.readString();
|
||||||
vr.keyIdHex = source.readString();
|
vr.mKeyIdHex = source.readString();
|
||||||
vr.bitStrength = source.readInt();
|
vr.mBitStrength = source.readInt();
|
||||||
vr.algorithm = source.readString();
|
vr.mAlgorithm = source.readString();
|
||||||
vr.secretKey = source.readByte() == 1;
|
vr.mSecretKey = source.readByte() == 1;
|
||||||
vr.mSelected = source.readByte() == 1;
|
vr.mSelected = source.readByte() == 1;
|
||||||
vr.mExtraData = source.readString();
|
vr.mExtraData = source.readString();
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public String getKeyIdHex() {
|
public String getKeyIdHex() {
|
||||||
return keyIdHex;
|
return mKeyIdHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelected() {
|
public boolean isSelected() {
|
||||||
@ -105,71 +105,71 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getKeyId() {
|
public long getKeyId() {
|
||||||
return keyId;
|
return mKeyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyId(long keyId) {
|
public void setKeyId(long keyId) {
|
||||||
this.keyId = keyId;
|
this.mKeyId = keyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyIdHex(String keyIdHex) {
|
public void setKeyIdHex(String keyIdHex) {
|
||||||
this.keyIdHex = keyIdHex;
|
this.mKeyIdHex = keyIdHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRevoked() {
|
public boolean isRevoked() {
|
||||||
return revoked;
|
return mRevoked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRevoked(boolean revoked) {
|
public void setRevoked(boolean revoked) {
|
||||||
this.revoked = revoked;
|
this.mRevoked = revoked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return date;
|
return mDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDate(Date date) {
|
public void setDate(Date date) {
|
||||||
this.date = date;
|
this.mDate = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFingerprintHex() {
|
public String getFingerprintHex() {
|
||||||
return fingerprintHex;
|
return mFingerprintHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFingerprintHex(String fingerprintHex) {
|
public void setFingerprintHex(String fingerprintHex) {
|
||||||
this.fingerprintHex = fingerprintHex;
|
this.mFingerprintHex = fingerprintHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBitStrength() {
|
public int getBitStrength() {
|
||||||
return bitStrength;
|
return mBitStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBitStrength(int bitStrength) {
|
public void setBitStrength(int bitStrength) {
|
||||||
this.bitStrength = bitStrength;
|
this.mBitStrength = bitStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAlgorithm() {
|
public String getAlgorithm() {
|
||||||
return algorithm;
|
return mAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlgorithm(String algorithm) {
|
public void setAlgorithm(String algorithm) {
|
||||||
this.algorithm = algorithm;
|
this.mAlgorithm = algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSecretKey() {
|
public boolean isSecretKey() {
|
||||||
return secretKey;
|
return mSecretKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecretKey(boolean secretKey) {
|
public void setSecretKey(boolean secretKey) {
|
||||||
this.secretKey = secretKey;
|
this.mSecretKey = secretKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getUserIds() {
|
public ArrayList<String> getUserIds() {
|
||||||
return userIds;
|
return mUserIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserIds(ArrayList<String> userIds) {
|
public void setUserIds(ArrayList<String> userIds) {
|
||||||
this.userIds = userIds;
|
this.mUserIds = userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrimaryUserId() {
|
public String getPrimaryUserId() {
|
||||||
@ -201,10 +201,10 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
*/
|
*/
|
||||||
public ImportKeysListEntry() {
|
public ImportKeysListEntry() {
|
||||||
// keys from keyserver are always public keys; from keybase too
|
// keys from keyserver are always public keys; from keybase too
|
||||||
secretKey = false;
|
mSecretKey = false;
|
||||||
// do not select by default
|
// do not select by default
|
||||||
mSelected = false;
|
mSelected = false;
|
||||||
userIds = new ArrayList<String>();
|
mUserIds = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,24 +215,24 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
// selected is default
|
// selected is default
|
||||||
this.mSelected = true;
|
this.mSelected = true;
|
||||||
|
|
||||||
secretKey = ring.isSecret();
|
mSecretKey = ring.isSecret();
|
||||||
UncachedPublicKey key = ring.getPublicKey();
|
UncachedPublicKey key = ring.getPublicKey();
|
||||||
|
|
||||||
mPrimaryUserId = key.getPrimaryUserId();
|
mPrimaryUserId = key.getPrimaryUserId();
|
||||||
userIds = key.getUnorderedUserIds();
|
mUserIds = key.getUnorderedUserIds();
|
||||||
|
|
||||||
// if there was no user id flagged as primary, use the first one
|
// if there was no user id flagged as primary, use the first one
|
||||||
if (mPrimaryUserId == null) {
|
if (mPrimaryUserId == null) {
|
||||||
mPrimaryUserId = userIds.get(0);
|
mPrimaryUserId = mUserIds.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.keyId = key.getKeyId();
|
this.mKeyId = key.getKeyId();
|
||||||
this.keyIdHex = PgpKeyHelper.convertKeyIdToHex(keyId);
|
this.mKeyIdHex = PgpKeyHelper.convertKeyIdToHex(mKeyId);
|
||||||
|
|
||||||
this.revoked = key.maybeRevoked();
|
this.mRevoked = key.maybeRevoked();
|
||||||
this.fingerprintHex = PgpKeyHelper.convertFingerprintToHex(key.getFingerprint());
|
this.mFingerprintHex = PgpKeyHelper.convertFingerprintToHex(key.getFingerprint());
|
||||||
this.bitStrength = key.getBitStrength();
|
this.mBitStrength = key.getBitStrength();
|
||||||
final int algorithm = key.getAlgorithm();
|
final int algorithm = key.getAlgorithm();
|
||||||
this.algorithm = PgpKeyHelper.getAlgorithmInfo(context, algorithm);
|
this.mAlgorithm = PgpKeyHelper.getAlgorithmInfo(context, algorithm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import android.widget.TextView;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|
||||||
import org.sufficientlysecure.keychain.util.Highlighter;
|
import org.sufficientlysecure.keychain.util.Highlighter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -120,13 +119,13 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// main user id
|
// main user id
|
||||||
String userId = entry.userIds.get(0);
|
String userId = entry.getUserIds().get(0);
|
||||||
String[] userIdSplit = KeyRing.splitUserId(userId);
|
String[] userIdSplit = KeyRing.splitUserId(userId);
|
||||||
|
|
||||||
// name
|
// name
|
||||||
if (userIdSplit[0] != null) {
|
if (userIdSplit[0] != null) {
|
||||||
// show red user id if it is a secret key
|
// show red user id if it is a secret key
|
||||||
if (entry.secretKey) {
|
if (entry.isSecretKey()) {
|
||||||
holder.mainUserId.setText(mActivity.getString(R.string.secret_key)
|
holder.mainUserId.setText(mActivity.getString(R.string.secret_key)
|
||||||
+ " " + userIdSplit[0]);
|
+ " " + userIdSplit[0]);
|
||||||
holder.mainUserId.setTextColor(Color.RED);
|
holder.mainUserId.setTextColor(Color.RED);
|
||||||
@ -147,26 +146,26 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
holder.mainUserIdRest.setVisibility(View.GONE);
|
holder.mainUserIdRest.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.keyId.setText(entry.keyIdHex);
|
holder.keyId.setText(entry.getKeyIdHex());
|
||||||
|
|
||||||
// don't show full fingerprint on key import
|
// don't show full fingerprint on key import
|
||||||
holder.fingerprint.setVisibility(View.GONE);
|
holder.fingerprint.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (entry.bitStrength != 0 && entry.algorithm != null) {
|
if (entry.getBitStrength() != 0 && entry.getAlgorithm() != null) {
|
||||||
holder.algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
holder.algorithm.setText("" + entry.getBitStrength() + "/" + entry.getAlgorithm());
|
||||||
holder.algorithm.setVisibility(View.VISIBLE);
|
holder.algorithm.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.algorithm.setVisibility(View.INVISIBLE);
|
holder.algorithm.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.revoked) {
|
if (entry.isRevoked()) {
|
||||||
holder.status.setVisibility(View.VISIBLE);
|
holder.status.setVisibility(View.VISIBLE);
|
||||||
holder.status.setText(R.string.revoked);
|
holder.status.setText(R.string.revoked);
|
||||||
} else {
|
} else {
|
||||||
holder.status.setVisibility(View.GONE);
|
holder.status.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.userIds.size() == 1) {
|
if (entry.getUserIds().size() == 1) {
|
||||||
holder.userIdsList.setVisibility(View.GONE);
|
holder.userIdsList.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
holder.userIdsList.setVisibility(View.VISIBLE);
|
holder.userIdsList.setVisibility(View.VISIBLE);
|
||||||
@ -174,7 +173,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
// clear view from holder
|
// clear view from holder
|
||||||
holder.userIdsList.removeAllViews();
|
holder.userIdsList.removeAllViews();
|
||||||
|
|
||||||
Iterator<String> it = entry.userIds.iterator();
|
Iterator<String> it = entry.getUserIds().iterator();
|
||||||
// skip primary user id
|
// skip primary user id
|
||||||
it.next();
|
it.next();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user