More code cleanup

This commit is contained in:
Dominik Schürmann 2014-04-19 21:56:15 +02:00
parent 0383822585
commit 7017a01bdb
20 changed files with 131 additions and 107 deletions

View File

@ -392,15 +392,29 @@ public class PgpKeyHelper {
return isCertificationKey(key.getPublicKey()); return isCertificationKey(key.getPublicKey());
} }
public static String getAlgorithmInfo(PGPPublicKey key) { public static String getAlgorithmInfo(Context context, PGPPublicKey key) {
return getAlgorithmInfo(key.getAlgorithm(), key.getBitStrength()); return getAlgorithmInfo(context, key.getAlgorithm(), key.getBitStrength());
} }
public static String getAlgorithmInfo(PGPSecretKey key) { public static String getAlgorithmInfo(Context context, PGPSecretKey key) {
return getAlgorithmInfo(key.getPublicKey()); return getAlgorithmInfo(context, key.getPublicKey());
} }
public static String getAlgorithmInfo(int algorithm, int keySize) { /**
* TODO: Only used in HkpKeyServer. Get rid of this one!
*/
public static String getAlgorithmInfo(int algorithm) {
return getAlgorithmInfo(null, algorithm, 0);
}
public static String getAlgorithmInfo(Context context, int algorithm) {
return getAlgorithmInfo(context, algorithm, 0);
}
/**
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
*/
public static String getAlgorithmInfo(Context context, int algorithm, int keySize) {
String algorithmStr; String algorithmStr;
switch (algorithm) { switch (algorithm) {
@ -421,8 +435,19 @@ public class PgpKeyHelper {
break; break;
} }
case PGPPublicKey.ECDSA:
case PGPPublicKey.ECDH: {
algorithmStr = "ECC";
break;
}
default: { default: {
algorithmStr = "Unknown"; if (context != null) {
algorithmStr = context.getResources().getString(R.string.unknown_algorithm);
} else {
// TODO
algorithmStr = "unknown";
}
break; break;
} }
} }

View File

@ -71,7 +71,7 @@ public class EncryptActivity extends DrawerActivity implements
private static final int PAGER_CONTENT_MESSAGE = 0; private static final int PAGER_CONTENT_MESSAGE = 0;
private static final int PAGER_CONTENT_FILE = 1; private static final int PAGER_CONTENT_FILE = 1;
// model useb by message and file fragment // model used by message and file fragments
private long mEncryptionKeyIds[] = null; private long mEncryptionKeyIds[] = null;
private long mSigningKeyId = Constants.key.none; private long mSigningKeyId = Constants.key.none;
private String mPassphrase; private String mPassphrase;

View File

@ -17,7 +17,7 @@
package org.sufficientlysecure.keychain.ui; package org.sufficientlysecure.keychain.ui;
import android.annotation.SuppressLint; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
@ -25,6 +25,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.nfc.NdefMessage; import android.nfc.NdefMessage;
import android.nfc.NfcAdapter; import android.nfc.NfcAdapter;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
@ -211,7 +212,8 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
} else { } else {
Log.e(Constants.TAG, Log.e(Constants.TAG,
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " + "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " +
"'fingerprint' extra!"); "'fingerprint' extra!"
);
return; return;
} }
} else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) { } else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) {
@ -458,9 +460,13 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
// Check to see that the Activity started due to an Android Beam
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { // Check to see if the Activity started due to an Android Beam
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
handleActionNdefDiscovered(getIntent()); handleActionNdefDiscovered(getIntent());
} else {
Log.e(Constants.TAG, "Android Beam not supported by Android < 4.1");
} }
} }
@ -476,7 +482,7 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
/** /**
* NFC: Parses the NDEF Message from the intent and prints to the TextView * NFC: Parses the NDEF Message from the intent and prints to the TextView
*/ */
@SuppressLint("NewApi") @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
void handleActionNdefDiscovered(Intent intent) { void handleActionNdefDiscovered(Intent intent) {
Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
// only one message sent during the beam // only one message sent during the beam

View File

@ -176,7 +176,7 @@ public class ViewCertActivity extends ActionBarActivity
mStatus.setTextColor(getResources().getColor(R.color.black)); mStatus.setTextColor(getResources().getColor(R.color.black));
} }
String algorithmStr = PgpKeyHelper.getAlgorithmInfo(sig.getKeyAlgorithm(), 0); String algorithmStr = PgpKeyHelper.getAlgorithmInfo(this, sig.getKeyAlgorithm(), 0);
mAlgorithm.setText(algorithmStr); mAlgorithm.setText(algorithmStr);
mRowReason.setVisibility(View.GONE); mRowReason.setVisibility(View.GONE);

View File

@ -50,21 +50,23 @@ public class ViewKeyCertsFragment extends Fragment
implements LoaderManager.LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener { implements LoaderManager.LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener {
// These are the rows that we will retrieve. // These are the rows that we will retrieve.
static final String[] PROJECTION = new String[] { static final String[] PROJECTION = new String[]{
Certs._ID, Certs._ID,
Certs.MASTER_KEY_ID, Certs.MASTER_KEY_ID,
Certs.VERIFIED, Certs.VERIFIED,
Certs.TYPE, Certs.TYPE,
Certs.RANK, Certs.RANK,
Certs.KEY_ID_CERTIFIER, Certs.KEY_ID_CERTIFIER,
Certs.USER_ID, Certs.USER_ID,
Certs.SIGNER_UID Certs.SIGNER_UID
}; };
// sort by our user id, // sort by our user id,
static final String SORT_ORDER = static final String SORT_ORDER =
Tables.CERTS + "." + Certs.RANK + " ASC, " Tables.CERTS + "." + Certs.RANK + " ASC, "
+ Certs.VERIFIED + " DESC, " + Certs.TYPE + " DESC, " + Certs.SIGNER_UID + " ASC"; + Certs.VERIFIED + " DESC, "
+ Certs.TYPE + " DESC, "
+ Certs.SIGNER_UID + " ASC";
public static final String ARG_DATA_URI = "data_uri"; public static final String ARG_DATA_URI = "data_uri";
@ -106,10 +108,6 @@ public class ViewKeyCertsFragment extends Fragment
mStickyList.setEmptyView(getActivity().findViewById(R.id.empty)); mStickyList.setEmptyView(getActivity().findViewById(R.id.empty));
// TODO this view is made visible if no data is available
// mStickyList.setEmptyView(getActivity().findViewById(R.id.empty));
// Create an empty adapter we will use to display the loaded data. // Create an empty adapter we will use to display the loaded data.
mAdapter = new CertListAdapter(getActivity(), null); mAdapter = new CertListAdapter(getActivity(), null);
mStickyList.setAdapter(mAdapter); mStickyList.setAdapter(mAdapter);
@ -138,7 +136,7 @@ public class ViewKeyCertsFragment extends Fragment
*/ */
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
if(view.getTag(R.id.tag_mki) != null) { if (view.getTag(R.id.tag_mki) != null) {
long masterKeyId = (Long) view.getTag(R.id.tag_mki); long masterKeyId = (Long) view.getTag(R.id.tag_mki);
long rank = (Long) view.getTag(R.id.tag_rank); long rank = (Long) view.getTag(R.id.tag_rank);
long certifierId = (Long) view.getTag(R.id.tag_certifierId); long certifierId = (Long) view.getTag(R.id.tag_certifierId);
@ -215,17 +213,22 @@ public class ViewKeyCertsFragment extends Fragment
String signerKeyId = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexSignerKeyId)); String signerKeyId = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexSignerKeyId));
String signerUserId = cursor.getString(mIndexSignerUserId); String signerUserId = cursor.getString(mIndexSignerUserId);
switch(cursor.getInt(mIndexType)) { switch (cursor.getInt(mIndexType)) {
case PGPSignature.DEFAULT_CERTIFICATION: // 0x10 case PGPSignature.DEFAULT_CERTIFICATION: // 0x10
wSignStatus.setText(R.string.cert_default); break; wSignStatus.setText(R.string.cert_default);
break;
case PGPSignature.NO_CERTIFICATION: // 0x11 case PGPSignature.NO_CERTIFICATION: // 0x11
wSignStatus.setText(R.string.cert_none); break; wSignStatus.setText(R.string.cert_none);
break;
case PGPSignature.CASUAL_CERTIFICATION: // 0x12 case PGPSignature.CASUAL_CERTIFICATION: // 0x12
wSignStatus.setText(R.string.cert_casual); break; wSignStatus.setText(R.string.cert_casual);
break;
case PGPSignature.POSITIVE_CERTIFICATION: // 0x13 case PGPSignature.POSITIVE_CERTIFICATION: // 0x13
wSignStatus.setText(R.string.cert_positive); break; wSignStatus.setText(R.string.cert_positive);
break;
case PGPSignature.CERTIFICATION_REVOCATION: // 0x30 case PGPSignature.CERTIFICATION_REVOCATION: // 0x30
wSignStatus.setText(R.string.cert_revoke); break; wSignStatus.setText(R.string.cert_revoke);
break;
} }
wSignerUserId.setText(signerUserId); wSignerUserId.setText(signerUserId);

View File

@ -278,7 +278,10 @@ public class ViewKeyMainFragment extends Fragment implements
} }
String algorithmStr = PgpKeyHelper.getAlgorithmInfo( String algorithmStr = PgpKeyHelper.getAlgorithmInfo(
data.getInt(INDEX_UNIFIED_ALGORITHM), data.getInt(INDEX_UNIFIED_KEY_SIZE)); getActivity(),
data.getInt(INDEX_UNIFIED_ALGORITHM),
data.getInt(INDEX_UNIFIED_KEY_SIZE)
);
mAlgorithm.setText(algorithmStr); mAlgorithm.setText(algorithmStr);
byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT);

View File

@ -17,7 +17,7 @@
package org.sufficientlysecure.keychain.ui.adapter; package org.sufficientlysecure.keychain.ui.adapter;
import android.annotation.SuppressLint; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
@ -61,14 +61,14 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
@SuppressLint("NewApi") @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setData(List<ImportKeysListEntry> data) { public void setData(List<ImportKeysListEntry> data) {
clear(); clear();
if (data != null) { if (data != null) {
this.mData = data; this.mData = data;
// add data to extended ArrayAdapter // add data to extended ArrayAdapter
if (Build.VERSION.SDK_INT >= 11) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
addAll(data); addAll(data);
} else { } else {
for (ImportKeysListEntry entry : data) { for (ImportKeysListEntry entry : data) {

View File

@ -17,6 +17,7 @@
package org.sufficientlysecure.keychain.ui.adapter; package org.sufficientlysecure.keychain.ui.adapter;
import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.SparseArray; import android.util.SparseArray;
@ -213,7 +214,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
* Constructor based on key object, used for import from NFC, QR Codes, files * Constructor based on key object, used for import from NFC, QR Codes, files
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public ImportKeysListEntry(PGPKeyRing pgpKeyRing) { public ImportKeysListEntry(Context context, PGPKeyRing pgpKeyRing) {
// save actual key object into entry, used to import it later // save actual key object into entry, used to import it later
try { try {
this.mBytes = pgpKeyRing.getEncoded(); this.mBytes = pgpKeyRing.getEncoded();
@ -263,32 +264,6 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
this.fingerPrintHex = PgpKeyHelper.convertFingerprintToHex(key.getFingerprint()); this.fingerPrintHex = PgpKeyHelper.convertFingerprintToHex(key.getFingerprint());
this.bitStrength = key.getBitStrength(); this.bitStrength = key.getBitStrength();
final int algorithm = key.getAlgorithm(); final int algorithm = key.getAlgorithm();
this.algorithm = getAlgorithmFromId(algorithm); this.algorithm = PgpKeyHelper.getAlgorithmInfo(context, algorithm);
}
/**
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
*/
private static final SparseArray<String> ALGORITHM_IDS = new SparseArray<String>() {{
put(-1, "unknown"); // TODO: with resources
put(0, "unencrypted");
put(PGPPublicKey.RSA_GENERAL, "RSA");
put(PGPPublicKey.RSA_ENCRYPT, "RSA");
put(PGPPublicKey.RSA_SIGN, "RSA");
put(PGPPublicKey.ELGAMAL_ENCRYPT, "ElGamal");
put(PGPPublicKey.ELGAMAL_GENERAL, "ElGamal");
put(PGPPublicKey.DSA, "DSA");
put(PGPPublicKey.EC, "ECC");
put(PGPPublicKey.ECDSA, "ECC");
put(PGPPublicKey.ECDH, "ECC");
}};
/**
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
*/
public static String getAlgorithmFromId(int algorithmId) {
return (ALGORITHM_IDS.get(algorithmId) != null ?
ALGORITHM_IDS.get(algorithmId) :
ALGORITHM_IDS.get(-1));
} }
} }

View File

@ -165,7 +165,7 @@ public class ImportKeysListLoader
} }
private void addToData(PGPKeyRing keyring) { private void addToData(PGPKeyRing keyring) {
ImportKeysListEntry item = new ImportKeysListEntry(keyring); ImportKeysListEntry item = new ImportKeysListEntry(getContext(), keyring);
mData.add(item); mData.add(item);
} }

View File

@ -101,7 +101,7 @@ public class ImportKeysListServerLoader
String fingerprint = query.substring(2); String fingerprint = query.substring(2);
Log.d(Constants.TAG, "fingerprint: " + fingerprint); Log.d(Constants.TAG, "fingerprint: " + fingerprint);
// query must return only one result! // query must return only one result!
if (searchResult.size() > 0) { if (searchResult.size() == 1) {
ImportKeysListEntry uniqueEntry = searchResult.get(0); ImportKeysListEntry uniqueEntry = searchResult.get(0);
/* /*
* set fingerprint explicitly after query * set fingerprint explicitly after query

View File

@ -39,7 +39,8 @@ public class KeyValueSpinnerAdapter extends ArrayAdapter<String> {
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) { public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
return e1.getValue().compareTo(e2.getValue()); return e1.getValue().compareTo(e2.getValue());
} }
}); }
);
sortedEntries.addAll(map.entrySet()); sortedEntries.addAll(map.entrySet());
return sortedEntries; return sortedEntries;
} }

View File

@ -65,8 +65,8 @@ abstract public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter
if (cursor != null) { if (cursor != null) {
mIndexUserId = cursor.getColumnIndexOrThrow(KeyRings.USER_ID); mIndexUserId = cursor.getColumnIndexOrThrow(KeyRings.USER_ID);
mIndexMasterKeyId = cursor.getColumnIndexOrThrow(KeyRings.MASTER_KEY_ID); mIndexMasterKeyId = cursor.getColumnIndexOrThrow(KeyRings.MASTER_KEY_ID);
mIndexExpiry= cursor.getColumnIndexOrThrow(KeyRings.EXPIRY); mIndexExpiry = cursor.getColumnIndexOrThrow(KeyRings.EXPIRY);
mIndexRevoked= cursor.getColumnIndexOrThrow(KeyRings.IS_REVOKED); mIndexRevoked = cursor.getColumnIndexOrThrow(KeyRings.IS_REVOKED);
} }
} }
@ -122,7 +122,7 @@ abstract public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter
h.keyId.setText(PgpKeyHelper.convertKeyIdToHex(masterKeyId)); h.keyId.setText(PgpKeyHelper.convertKeyIdToHex(masterKeyId));
boolean enabled = true; boolean enabled = true;
if(cursor.getInt(mIndexRevoked) != 0) { if (cursor.getInt(mIndexRevoked) != 0) {
h.status.setText(R.string.revoked); h.status.setText(R.string.revoked);
enabled = false; enabled = false;
} else if (!cursor.isNull(mIndexExpiry) } else if (!cursor.isNull(mIndexExpiry)
@ -134,7 +134,6 @@ abstract public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter
} }
h.status.setTag(enabled); h.status.setTag(enabled);
} }
@Override @Override

View File

@ -73,7 +73,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
hasAnySecret = true; hasAnySecret = true;
break; break;
} }
} while(newCursor.moveToNext()); } while (newCursor.moveToNext());
} }
return super.swapCursor(newCursor); return super.swapCursor(newCursor);
@ -112,8 +112,11 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey); ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey);
String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)); String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId));
String algorithmStr = PgpKeyHelper.getAlgorithmInfo(cursor.getInt(mIndexAlgorithm), String algorithmStr = PgpKeyHelper.getAlgorithmInfo(
cursor.getInt(mIndexKeySize)); context,
cursor.getInt(mIndexAlgorithm),
cursor.getInt(mIndexKeySize)
);
keyId.setText(keyIdStr); keyId.setText(keyIdStr);
// may be set with additional "stripped" later on // may be set with additional "stripped" later on
@ -173,6 +176,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
} else { } else {
keyExpiry.setVisibility(View.GONE); keyExpiry.setVisibility(View.GONE);
} }
// if key is expired or revoked, strike through text // if key is expired or revoked, strike through text
if (!valid) { if (!valid) {
keyId.setText(OtherHelper.strikeOutText(keyId.getText())); keyId.setText(OtherHelper.strikeOutText(keyId.getText()));

View File

@ -46,8 +46,12 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView.
private final ArrayList<Boolean> mCheckStates; private final ArrayList<Boolean> mCheckStates;
public static final String[] USER_IDS_PROJECTION = new String[]{ public static final String[] USER_IDS_PROJECTION = new String[]{
UserIds._ID, UserIds.USER_ID, UserIds.RANK, UserIds._ID,
UserIds.VERIFIED, UserIds.IS_PRIMARY, UserIds.IS_REVOKED UserIds.USER_ID,
UserIds.RANK,
UserIds.VERIFIED,
UserIds.IS_PRIMARY,
UserIds.IS_REVOKED
}; };
public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) {
@ -102,7 +106,6 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView.
@Override @Override
public void bindView(View view, Context context, Cursor cursor) { public void bindView(View view, Context context, Cursor cursor) {
TextView vRank = (TextView) view.findViewById(R.id.rank); TextView vRank = (TextView) view.findViewById(R.id.rank);
TextView vUserId = (TextView) view.findViewById(R.id.userId); TextView vUserId = (TextView) view.findViewById(R.id.userId);
TextView vAddress = (TextView) view.findViewById(R.id.address); TextView vAddress = (TextView) view.findViewById(R.id.address);
@ -137,12 +140,16 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView.
int verified = cursor.getInt(mVerifiedId); int verified = cursor.getInt(mVerifiedId);
// TODO introduce own resources for this :) // TODO introduce own resources for this :)
if (verified == Certs.VERIFIED_SECRET) { switch (verified) {
vVerified.setImageResource(R.drawable.key_certify_ok_depth0); case Certs.VERIFIED_SECRET:
} else if (verified == Certs.VERIFIED_SELF) { vVerified.setImageResource(R.drawable.key_certify_ok_depth0);
vVerified.setImageResource(R.drawable.key_certify_ok_self); break;
} else { case Certs.VERIFIED_SELF:
vVerified.setImageResource(R.drawable.key_certify_error); vVerified.setImageResource(R.drawable.key_certify_ok_self);
break;
default:
vVerified.setImageResource(R.drawable.key_certify_error);
break;
} }
} }

View File

@ -68,7 +68,6 @@ public class DeleteKeyDialogFragment extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
final FragmentActivity activity = getActivity(); final FragmentActivity activity = getActivity();
mMessenger = getArguments().getParcelable(ARG_MESSENGER); mMessenger = getArguments().getParcelable(ARG_MESSENGER);

View File

@ -88,13 +88,11 @@ public class ShareNfcDialogFragment extends DialogFragment {
Settings.ACTION_NFCSHARING_SETTINGS); Settings.ACTION_NFCSHARING_SETTINGS);
startActivity(intentSettings); startActivity(intentSettings);
} }
}); }
);
} }
} }
// no flickering when clicking textview for Android < 4
// aboutTextView.setTextColor(getResources().getColor(android.R.color.black));
return alert.create(); return alert.create();
} }
} }

View File

@ -92,7 +92,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
mText = (TextView) view.findViewById(R.id.share_qr_code_dialog_text); mText = (TextView) view.findViewById(R.id.share_qr_code_dialog_text);
ProviderHelper providerHelper = new ProviderHelper(getActivity()); ProviderHelper providerHelper = new ProviderHelper(getActivity());
String content = null; String content;
try { try {
if (mFingerprintOnly) { if (mFingerprintOnly) {
alert.setPositiveButton(R.string.btn_okay, null); alert.setPositiveButton(R.string.btn_okay, null);

View File

@ -216,7 +216,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
mDeleteButton.setVisibility(View.INVISIBLE); mDeleteButton.setVisibility(View.INVISIBLE);
} }
mAlgorithm.setText(PgpKeyHelper.getAlgorithmInfo(key)); mAlgorithm.setText(PgpKeyHelper.getAlgorithmInfo(getContext(), key));
String keyIdStr = PgpKeyHelper.convertKeyIdToHex(key.getKeyID()); String keyIdStr = PgpKeyHelper.convertKeyIdToHex(key.getKeyID());
mKeyId.setText(keyIdStr); mKeyId.setText(keyIdStr);

View File

@ -31,6 +31,7 @@ import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -256,7 +257,7 @@ public class HkpKeyServer extends KeyServer {
entry.setBitStrength(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));
entry.setAlgorithm(ImportKeysListEntry.getAlgorithmFromId(algorithmId)); entry.setAlgorithm(PgpKeyHelper.getAlgorithmInfo(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 http://bit.ly/1d4bxbk and http://bit.ly/1gD1wwr // see http://bit.ly/1d4bxbk and http://bit.ly/1gD1wwr

View File

@ -140,6 +140,8 @@
<string name="no_key">&lt;no key&gt;</string> <string name="no_key">&lt;no key&gt;</string>
<string name="can_encrypt">can encrypt</string> <string name="can_encrypt">can encrypt</string>
<string name="can_sign">can sign</string> <string name="can_sign">can sign</string>
<string name="can_certify">can certify</string>
<string name="can_certify_not">cannot certify</string>
<string name="expired">expired</string> <string name="expired">expired</string>
<string name="revoked">revoked</string> <string name="revoked">revoked</string>
@ -368,6 +370,7 @@
<!-- Help --> <!-- Help -->
<string name="help_tab_start">Start</string> <string name="help_tab_start">Start</string>
<string name="help_tab_faq">FAQ</string> <string name="help_tab_faq">FAQ</string>
<string name="help_tab_wot">Web of Trust</string>
<string name="help_tab_nfc_beam">NFC Beam</string> <string name="help_tab_nfc_beam">NFC Beam</string>
<string name="help_tab_changelog">Changelog</string> <string name="help_tab_changelog">Changelog</string>
<string name="help_tab_about">About</string> <string name="help_tab_about">About</string>
@ -468,6 +471,17 @@
<string name="encrypt_content_edit_text_hint">Write message here to encrypt and/or sign…</string> <string name="encrypt_content_edit_text_hint">Write message here to encrypt and/or sign…</string>
<string name="decrypt_content_edit_text_hint">Enter ciphertext here to decrypt and/or verify…</string> <string name="decrypt_content_edit_text_hint">Enter ciphertext here to decrypt and/or verify…</string>
<!-- certifications -->
<string name="cert_default">default</string>
<string name="cert_none">none</string>
<string name="cert_casual">casual</string>
<string name="cert_positive">positive</string>
<string name="cert_revoke">revoke</string>
<string name="cert_verify_ok">ok</string>
<string name="cert_verify_failed">failed!</string>
<string name="cert_verify_error">error!</string>
<string name="cert_verify_unavailable">key unavailable</string>
<!-- unsorted --> <!-- unsorted -->
<string name="section_signer_id">Signer</string> <string name="section_signer_id">Signer</string>
<string name="section_cert">Certificate Details</string> <string name="section_cert">Certificate Details</string>
@ -475,26 +489,15 @@
<string name="unknown_uid">&lt;unknown&gt;</string> <string name="unknown_uid">&lt;unknown&gt;</string>
<string name="empty_certs">No certificates for this key</string> <string name="empty_certs">No certificates for this key</string>
<string name="section_uids_to_sign">User IDs to sign</string> <string name="section_uids_to_sign">User IDs to sign</string>
<string name="cert_default">default</string>
<string name="cert_none">none</string>
<string name="cert_casual">casual</string>
<string name="cert_positive">positive</string>
<string name="cert_revoke">revoke</string>
<string name="help_tab_wot">Web of Trust</string>
<string name="cert_verify_ok">ok</string>
<string name="cert_verify_failed">failed!</string>
<string name="cert_verify_error">error!</string>
<string name="cert_verify_unavailable">key unavailable</string>
<string name="label_revocation">Revocation Reason</string> <string name="label_revocation">Revocation Reason</string>
<string name="label_verify_status">Verification Status</string> <string name="label_verify_status">Verification Status</string>
<string name="label_cert_type">Type</string> <string name="label_cert_type">Type</string>
<string name="can_certify">can certify</string>
<string name="can_certify_not">cannot certify</string>
<string name="error_key_not_found">Key not found!</string> <string name="error_key_not_found">Key not found!</string>
<string name="error_key_processing">Error processing key!</string> <string name="error_key_processing">Error processing key!</string>
<string name="no_subkey">subkey unavailable</string> <string name="no_subkey">subkey unavailable</string>
<string name="key_stripped">stripped</string> <string name="key_stripped">stripped</string>
<string name="secret_cannot_multiple">Secret keys can only be deleted individually!</string> <string name="secret_cannot_multiple">Secret keys can only be deleted individually!</string>
<string name="title_view_cert">View Certificate Details</string> <string name="title_view_cert">View Certificate Details</string>
<string name="unknown_algorithm">unknown</string>
</resources> </resources>