Use getter and setter
This commit is contained in:
@@ -43,13 +43,12 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
protected List<ImportKeysListEntry> mData;
|
protected List<ImportKeysListEntry> mData;
|
||||||
|
|
||||||
static class ViewHolder {
|
static class ViewHolder {
|
||||||
private TextView mMainUserId;
|
private TextView mainUserId;
|
||||||
private TextView mMainUserIdRest;
|
private TextView mainUserIdRest;
|
||||||
private TextView mKeyId;
|
private TextView keyId;
|
||||||
private TextView mFingerprint;
|
private TextView fingerprint;
|
||||||
private TextView mAlgorithm;
|
private TextView algorithm;
|
||||||
private TextView mStatus;
|
private TextView status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImportKeysAdapter(Activity activity) {
|
public ImportKeysAdapter(Activity activity) {
|
||||||
@@ -100,12 +99,12 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
convertView = mInflater.inflate(R.layout.import_keys_list_entry, null);
|
convertView = mInflater.inflate(R.layout.import_keys_list_entry, null);
|
||||||
holder.mMainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
holder.mainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
||||||
holder.mMainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
holder.mainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
||||||
holder.mKeyId = (TextView) convertView.findViewById(R.id.keyId);
|
holder.keyId = (TextView) convertView.findViewById(R.id.keyId);
|
||||||
holder.mFingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
holder.fingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
||||||
holder.mAlgorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
||||||
holder.mStatus = (TextView) convertView.findViewById(R.id.status);
|
holder.status = (TextView) convertView.findViewById(R.id.status);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
@@ -119,36 +118,36 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
// 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.secretKey) {
|
||||||
userIdSplit[0] = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0];
|
userIdSplit[0] = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0];
|
||||||
holder.mMainUserId.setTextColor(Color.RED);
|
holder.mainUserId.setTextColor(Color.RED);
|
||||||
}
|
}
|
||||||
holder.mMainUserId.setText(userIdSplit[0]);
|
holder.mainUserId.setText(userIdSplit[0]);
|
||||||
} else {
|
} else {
|
||||||
holder.mMainUserId.setText(R.string.user_id_no_name);
|
holder.mainUserId.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// email
|
// email
|
||||||
if (userIdSplit[1] != null) {
|
if (userIdSplit[1] != null) {
|
||||||
holder.mMainUserIdRest.setText(userIdSplit[1]);
|
holder.mainUserIdRest.setText(userIdSplit[1]);
|
||||||
holder.mMainUserIdRest.setVisibility(View.VISIBLE);
|
holder.mainUserIdRest.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.mMainUserIdRest.setVisibility(View.GONE);
|
holder.mainUserIdRest.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.mKeyId.setText(entry.keyIdHex);
|
holder.keyId.setText(entry.keyIdHex);
|
||||||
|
|
||||||
if (entry.fingerPrintHex != null) {
|
if (entry.fingerPrintHex != null) {
|
||||||
holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex);
|
holder.fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex);
|
||||||
holder.mFingerprint.setVisibility(View.VISIBLE);
|
holder.fingerprint.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.mFingerprint.setVisibility(View.GONE);
|
holder.fingerprint.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.mAlgorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
holder.algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
||||||
|
|
||||||
if (entry.revoked) {
|
if (entry.revoked) {
|
||||||
holder.mStatus.setText(R.string.revoked);
|
holder.status.setText(R.string.revoked);
|
||||||
} else {
|
} else {
|
||||||
holder.mStatus.setVisibility(View.GONE);
|
holder.status.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
||||||
|
|||||||
@@ -36,11 +36,10 @@ 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;
|
|
||||||
|
|
||||||
|
public ArrayList<String> userIds;
|
||||||
public long keyId;
|
public long keyId;
|
||||||
public String keyIdHex;
|
public String keyIdHex;
|
||||||
|
|
||||||
public boolean revoked;
|
public boolean revoked;
|
||||||
public Date date; // TODO: not displayed
|
public Date date; // TODO: not displayed
|
||||||
public String fingerPrintHex;
|
public String fingerPrintHex;
|
||||||
@@ -131,6 +130,74 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
this.mSelected = selected;
|
this.mSelected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getKeyId() {
|
||||||
|
return keyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyId(long keyId) {
|
||||||
|
this.keyId = keyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyIdHex(String keyIdHex) {
|
||||||
|
this.keyIdHex = keyIdHex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRevoked() {
|
||||||
|
return revoked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRevoked(boolean revoked) {
|
||||||
|
this.revoked = revoked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFingerPrintHex() {
|
||||||
|
return fingerPrintHex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFingerPrintHex(String fingerPrintHex) {
|
||||||
|
this.fingerPrintHex = fingerPrintHex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBitStrength() {
|
||||||
|
return bitStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBitStrength(int bitStrength) {
|
||||||
|
this.bitStrength = bitStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlgorithm() {
|
||||||
|
return algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlgorithm(String algorithm) {
|
||||||
|
this.algorithm = algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSecretKey() {
|
||||||
|
return secretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecretKey(boolean secretKey) {
|
||||||
|
this.secretKey = secretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getUserIds() {
|
||||||
|
return userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIds(ArrayList<String> userIds) {
|
||||||
|
this.userIds = userIds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for later querying from keyserver
|
* Constructor for later querying from keyserver
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -239,32 +239,35 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
|
|
||||||
final Matcher matcher = PUB_KEY_LINE.matcher(data);
|
final Matcher matcher = PUB_KEY_LINE.matcher(data);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
final ImportKeysListEntry info = new ImportKeysListEntry();
|
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||||
info.bitStrength = Integer.parseInt(matcher.group(3));
|
|
||||||
|
entry.setBitStrength(Integer.parseInt(matcher.group(3)));
|
||||||
|
|
||||||
final int algorithmId = Integer.decode(matcher.group(2));
|
final int algorithmId = Integer.decode(matcher.group(2));
|
||||||
info.algorithm = getAlgorithmFromId(algorithmId);
|
entry.setAlgorithm(getAlgorithmFromId(algorithmId));
|
||||||
|
|
||||||
// group 1 contains the full fingerprint (v4) or the long key id if available
|
// group 1 contains the full fingerprint (v4) or the long key id if available
|
||||||
// see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff
|
// see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff
|
||||||
// and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176
|
// and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176
|
||||||
String fingerprintOrKeyId = matcher.group(1);
|
String fingerprintOrKeyId = matcher.group(1);
|
||||||
if (fingerprintOrKeyId.length() > 16) {
|
if (fingerprintOrKeyId.length() > 16) {
|
||||||
info.fingerPrintHex = "0x" + PgpKeyHelper.splitFingerprintHex(fingerprintOrKeyId);
|
entry.setFingerPrintHex(PgpKeyHelper.splitFingerprintHex(
|
||||||
info.keyIdHex = "0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length()
|
fingerprintOrKeyId.toLowerCase(Locale.US)));
|
||||||
- 16, fingerprintOrKeyId.length());
|
entry.setKeyIdHex("0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length()
|
||||||
|
- 16, fingerprintOrKeyId.length()));
|
||||||
} else {
|
} else {
|
||||||
// set key id only
|
// set key id only
|
||||||
info.keyIdHex = "0x" + fingerprintOrKeyId;
|
entry.setKeyIdHex("0x" + fingerprintOrKeyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final long creationDate = Long.parseLong(matcher.group(4));
|
final long creationDate = Long.parseLong(matcher.group(4));
|
||||||
final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
tmpGreg.setTimeInMillis(creationDate * 1000);
|
tmpGreg.setTimeInMillis(creationDate * 1000);
|
||||||
info.date = tmpGreg.getTime();
|
entry.setDate(tmpGreg.getTime());
|
||||||
|
|
||||||
info.revoked = matcher.group(6).contains("r");
|
entry.setRevoked(matcher.group(6).contains("r"));
|
||||||
info.userIds = new ArrayList<String>();
|
|
||||||
|
|
||||||
|
ArrayList<String> userIds = new ArrayList<String>();
|
||||||
final String uidLines = matcher.group(7);
|
final String uidLines = matcher.group(7);
|
||||||
final Matcher uidMatcher = UID_LINE.matcher(uidLines);
|
final Matcher uidMatcher = UID_LINE.matcher(uidLines);
|
||||||
while (uidMatcher.find()) {
|
while (uidMatcher.find()) {
|
||||||
@@ -277,9 +280,11 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
// will never happen, because "UTF8" is supported
|
// will never happen, because "UTF8" is supported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.userIds.add(tmp);
|
userIds.add(tmp);
|
||||||
}
|
}
|
||||||
results.add(info);
|
entry.setUserIds(userIds);
|
||||||
|
|
||||||
|
results.add(entry);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user