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.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -88,10 +87,6 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||
return mKeyIdHex;
|
||||
}
|
||||
|
||||
public long getKeyId() {
|
||||
return new BigInteger(mKeyIdHex.substring(2), 16).longValue();
|
||||
}
|
||||
|
||||
public void setKeyIdHex(String keyIdHex) {
|
||||
mKeyIdHex = keyIdHex;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
|||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
||||
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.util.Log;
|
||||
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 (mData.size() == 1)
|
||||
if (mData.size() == 1) {
|
||||
getKey(mData.get(0), true);
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
@ -157,8 +159,9 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||
b.extra.showKey.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
long keyId = KeyFormattingUtils.convertKeyIdHexToKeyId(entry.getKeyIdHex());
|
||||
Intent intent = new Intent(mActivity, ViewKeyActivity.class);
|
||||
intent.setData(KeyRings.buildGenericKeyRingUri(entry.getKeyId()));
|
||||
intent.setData(KeyRings.buildGenericKeyRingUri(keyId));
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -30,13 +30,13 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||
import org.bouncycastle.asn1.nist.NISTNamedCurves;
|
||||
import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
||||
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
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.util.Log;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.DigestException;
|
||||
import java.security.MessageDigest;
|
||||
|
@ -272,6 +273,10 @@ public class KeyFormattingUtils {
|
|||
return hexString;
|
||||
}
|
||||
|
||||
public static long convertKeyIdHexToKeyId(String hex) {
|
||||
return new BigInteger(hex.substring(2), 16).longValue();
|
||||
}
|
||||
|
||||
public static long convertFingerprintToKeyId(byte[] fingerprint) {
|
||||
return ByteBuffer.wrap(fingerprint, 12, 8).getLong();
|
||||
}
|
||||
|
@ -434,14 +439,19 @@ public class KeyFormattingUtils {
|
|||
|
||||
public interface StatusHolder {
|
||||
ImageView getEncryptionStatusIcon();
|
||||
|
||||
TextView getEncryptionStatusText();
|
||||
|
||||
ImageView getSignatureStatusIcon();
|
||||
|
||||
TextView getSignatureStatusText();
|
||||
|
||||
View getSignatureLayout();
|
||||
|
||||
TextView getSignatureUserName();
|
||||
|
||||
TextView getSignatureUserEmail();
|
||||
|
||||
ViewAnimator getSignatureAction();
|
||||
|
||||
boolean hasEncrypt();
|
||||
|
|
Loading…
Reference in a new issue