ImportKeys: Code style
This commit is contained in:
parent
781292e38b
commit
d87813a9e9
|
@ -29,7 +29,6 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -88,10 +87,6 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||||
return mKeyIdHex;
|
return mKeyIdHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getKeyId() {
|
|
||||||
return new BigInteger(mKeyIdHex.substring(2), 16).longValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeyIdHex(String keyIdHex) {
|
public void setKeyIdHex(String keyIdHex) {
|
||||||
mKeyIdHex = keyIdHex;
|
mKeyIdHex = keyIdHex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
||||||
|
@ -76,8 +77,9 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is only one key, get it automatically
|
// If there is only one key, get it automatically
|
||||||
if (mData.size() == 1)
|
if (mData.size() == 1) {
|
||||||
getKey(mData.get(0), true);
|
getKey(mData.get(0), true);
|
||||||
|
}
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -157,8 +159,9 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||||
b.extra.showKey.setOnClickListener(new OnClickListener() {
|
b.extra.showKey.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
long keyId = KeyFormattingUtils.convertKeyIdHexToKeyId(entry.getKeyIdHex());
|
||||||
Intent intent = new Intent(mActivity, ViewKeyActivity.class);
|
Intent intent = new Intent(mActivity, ViewKeyActivity.class);
|
||||||
intent.setData(KeyRings.buildGenericKeyRingUri(entry.getKeyId()));
|
intent.setData(KeyRings.buildGenericKeyRingUri(keyId));
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,13 +30,13 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.ViewAnimator;
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
|
||||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||||
import org.bouncycastle.asn1.nist.NISTNamedCurves;
|
import org.bouncycastle.asn1.nist.NISTNamedCurves;
|
||||||
import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
||||||
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
||||||
import org.bouncycastle.util.encoders.Hex;
|
import org.bouncycastle.util.encoders.Hex;
|
||||||
|
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||||
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
@ -46,6 +46,7 @@ import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Curve;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Curve;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.security.DigestException;
|
import java.security.DigestException;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
@ -272,6 +273,10 @@ public class KeyFormattingUtils {
|
||||||
return hexString;
|
return hexString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long convertKeyIdHexToKeyId(String hex) {
|
||||||
|
return new BigInteger(hex.substring(2), 16).longValue();
|
||||||
|
}
|
||||||
|
|
||||||
public static long convertFingerprintToKeyId(byte[] fingerprint) {
|
public static long convertFingerprintToKeyId(byte[] fingerprint) {
|
||||||
return ByteBuffer.wrap(fingerprint, 12, 8).getLong();
|
return ByteBuffer.wrap(fingerprint, 12, 8).getLong();
|
||||||
}
|
}
|
||||||
|
@ -434,14 +439,19 @@ public class KeyFormattingUtils {
|
||||||
|
|
||||||
public interface StatusHolder {
|
public interface StatusHolder {
|
||||||
ImageView getEncryptionStatusIcon();
|
ImageView getEncryptionStatusIcon();
|
||||||
|
|
||||||
TextView getEncryptionStatusText();
|
TextView getEncryptionStatusText();
|
||||||
|
|
||||||
ImageView getSignatureStatusIcon();
|
ImageView getSignatureStatusIcon();
|
||||||
|
|
||||||
TextView getSignatureStatusText();
|
TextView getSignatureStatusText();
|
||||||
|
|
||||||
View getSignatureLayout();
|
View getSignatureLayout();
|
||||||
|
|
||||||
TextView getSignatureUserName();
|
TextView getSignatureUserName();
|
||||||
|
|
||||||
TextView getSignatureUserEmail();
|
TextView getSignatureUserEmail();
|
||||||
|
|
||||||
ViewAnimator getSignatureAction();
|
ViewAnimator getSignatureAction();
|
||||||
|
|
||||||
boolean hasEncrypt();
|
boolean hasEncrypt();
|
||||||
|
@ -450,7 +460,7 @@ public class KeyFormattingUtils {
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") // context.getDrawable is api lvl 21, need to use deprecated
|
@SuppressWarnings("deprecation") // context.getDrawable is api lvl 21, need to use deprecated
|
||||||
public static void setStatus(Resources resources, StatusHolder holder, DecryptVerifyResult result,
|
public static void setStatus(Resources resources, StatusHolder holder, DecryptVerifyResult result,
|
||||||
boolean processingkeyLookup) {
|
boolean processingkeyLookup) {
|
||||||
|
|
||||||
if (holder.hasEncrypt()) {
|
if (holder.hasEncrypt()) {
|
||||||
OpenPgpDecryptionResult decryptionResult = result.getDecryptionResult();
|
OpenPgpDecryptionResult decryptionResult = result.getDecryptionResult();
|
||||||
|
|
Loading…
Reference in a new issue