mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-24 07:58:50 -05:00
Use getter and setter
This commit is contained in:
parent
2b77489932
commit
36815b9185
@ -43,13 +43,12 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
protected List<ImportKeysListEntry> mData;
|
||||
|
||||
static class ViewHolder {
|
||||
private TextView mMainUserId;
|
||||
private TextView mMainUserIdRest;
|
||||
private TextView mKeyId;
|
||||
private TextView mFingerprint;
|
||||
private TextView mAlgorithm;
|
||||
private TextView mStatus;
|
||||
|
||||
private TextView mainUserId;
|
||||
private TextView mainUserIdRest;
|
||||
private TextView keyId;
|
||||
private TextView fingerprint;
|
||||
private TextView algorithm;
|
||||
private TextView status;
|
||||
}
|
||||
|
||||
public ImportKeysAdapter(Activity activity) {
|
||||
@ -100,12 +99,12 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
if (convertView == null) {
|
||||
holder = new ViewHolder();
|
||||
convertView = mInflater.inflate(R.layout.import_keys_list_entry, null);
|
||||
holder.mMainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
||||
holder.mMainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
||||
holder.mKeyId = (TextView) convertView.findViewById(R.id.keyId);
|
||||
holder.mFingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
||||
holder.mAlgorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
||||
holder.mStatus = (TextView) convertView.findViewById(R.id.status);
|
||||
holder.mainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
||||
holder.mainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
||||
holder.keyId = (TextView) convertView.findViewById(R.id.keyId);
|
||||
holder.fingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
||||
holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
||||
holder.status = (TextView) convertView.findViewById(R.id.status);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
@ -119,36 +118,36 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
// show red user id if it is a secret key
|
||||
if (entry.secretKey) {
|
||||
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 {
|
||||
holder.mMainUserId.setText(R.string.user_id_no_name);
|
||||
holder.mainUserId.setText(R.string.user_id_no_name);
|
||||
}
|
||||
|
||||
// email
|
||||
if (userIdSplit[1] != null) {
|
||||
holder.mMainUserIdRest.setText(userIdSplit[1]);
|
||||
holder.mMainUserIdRest.setVisibility(View.VISIBLE);
|
||||
holder.mainUserIdRest.setText(userIdSplit[1]);
|
||||
holder.mainUserIdRest.setVisibility(View.VISIBLE);
|
||||
} 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) {
|
||||
holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex);
|
||||
holder.mFingerprint.setVisibility(View.VISIBLE);
|
||||
holder.fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex);
|
||||
holder.fingerprint.setVisibility(View.VISIBLE);
|
||||
} 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) {
|
||||
holder.mStatus.setText(R.string.revoked);
|
||||
holder.status.setText(R.string.revoked);
|
||||
} else {
|
||||
holder.mStatus.setVisibility(View.GONE);
|
||||
holder.status.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
||||
|
@ -36,11 +36,10 @@ import java.util.Date;
|
||||
|
||||
public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
private static final long serialVersionUID = -7797972103284992662L;
|
||||
public ArrayList<String> userIds;
|
||||
|
||||
public ArrayList<String> userIds;
|
||||
public long keyId;
|
||||
public String keyIdHex;
|
||||
|
||||
public boolean revoked;
|
||||
public Date date; // TODO: not displayed
|
||||
public String fingerPrintHex;
|
||||
@ -131,6 +130,74 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
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
|
||||
*/
|
||||
|
@ -239,32 +239,35 @@ public class HkpKeyServer extends KeyServer {
|
||||
|
||||
final Matcher matcher = PUB_KEY_LINE.matcher(data);
|
||||
while (matcher.find()) {
|
||||
final ImportKeysListEntry info = new ImportKeysListEntry();
|
||||
info.bitStrength = Integer.parseInt(matcher.group(3));
|
||||
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||
|
||||
entry.setBitStrength(Integer.parseInt(matcher.group(3)));
|
||||
|
||||
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
|
||||
// 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
|
||||
String fingerprintOrKeyId = matcher.group(1);
|
||||
if (fingerprintOrKeyId.length() > 16) {
|
||||
info.fingerPrintHex = "0x" + PgpKeyHelper.splitFingerprintHex(fingerprintOrKeyId);
|
||||
info.keyIdHex = "0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length()
|
||||
- 16, fingerprintOrKeyId.length());
|
||||
entry.setFingerPrintHex(PgpKeyHelper.splitFingerprintHex(
|
||||
fingerprintOrKeyId.toLowerCase(Locale.US)));
|
||||
entry.setKeyIdHex("0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length()
|
||||
- 16, fingerprintOrKeyId.length()));
|
||||
} else {
|
||||
// set key id only
|
||||
info.keyIdHex = "0x" + fingerprintOrKeyId;
|
||||
entry.setKeyIdHex("0x" + fingerprintOrKeyId);
|
||||
}
|
||||
|
||||
final long creationDate = Long.parseLong(matcher.group(4));
|
||||
final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||
tmpGreg.setTimeInMillis(creationDate * 1000);
|
||||
info.date = tmpGreg.getTime();
|
||||
entry.setDate(tmpGreg.getTime());
|
||||
|
||||
info.revoked = matcher.group(6).contains("r");
|
||||
info.userIds = new ArrayList<String>();
|
||||
entry.setRevoked(matcher.group(6).contains("r"));
|
||||
|
||||
ArrayList<String> userIds = new ArrayList<String>();
|
||||
final String uidLines = matcher.group(7);
|
||||
final Matcher uidMatcher = UID_LINE.matcher(uidLines);
|
||||
while (uidMatcher.find()) {
|
||||
@ -277,9 +280,11 @@ public class HkpKeyServer extends KeyServer {
|
||||
// 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user