diff options
Diffstat (limited to 'OpenPGP-Keychain/src/main')
5 files changed, 58 insertions, 36 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index 28d54d818..0eff929f3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -273,6 +273,9 @@ public class KeychainContract { public static Uri buildCertsUri(String masterKeyId) { return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).build(); } + public static Uri buildCertsSpecificUri(String masterKeyId, String rank, String certifier) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).appendPath(rank).appendPath(certifier).build(); + } public static Uri buildCertsUri(Uri uri) { return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_CERTS).build(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 903c27859..f684006b0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -54,6 +54,7 @@ public class KeychainProvider extends ContentProvider { private static final int KEY_RING_PUBLIC = 203; private static final int KEY_RING_SECRET = 204; private static final int KEY_RING_CERTS = 205; + private static final int KEY_RING_CERTS_SPECIFIC = 206; private static final int API_APPS = 301; private static final int API_APPS_BY_PACKAGE_NAME = 303; @@ -63,8 +64,6 @@ public class KeychainProvider extends ContentProvider { private static final int KEY_RINGS_FIND_BY_EMAIL = 400; private static final int KEY_RINGS_FIND_BY_SUBKEY = 401; - private static final int CERTS_FIND_BY_CERTIFIER_ID = 501; - // private static final int DATA_STREAM = 501; protected UriMatcher mUriMatcher; @@ -119,6 +118,8 @@ public class KeychainProvider extends ContentProvider { * key_rings/_/user_ids * key_rings/_/public * key_rings/_/secret + * key_rings/_/certs + * key_rings/_/certs/_/_ * </pre> */ matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" @@ -139,6 +140,9 @@ public class KeychainProvider extends ContentProvider { matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + KeychainContract.PATH_CERTS, KEY_RING_CERTS); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + + KeychainContract.PATH_CERTS + "/*/*", + KEY_RING_CERTS_SPECIFIC); /** * API apps @@ -436,6 +440,7 @@ public class KeychainProvider extends ContentProvider { } case KEY_RING_CERTS: + case KEY_RING_CERTS_SPECIFIC: { HashMap<String, String> projectionMap = new HashMap<String, String>(); projectionMap.put(Certs._ID, Tables.CERTS + ".oid AS " + Certs._ID); projectionMap.put(Certs.MASTER_KEY_ID, Tables.CERTS + "." + Certs.MASTER_KEY_ID); @@ -443,6 +448,7 @@ public class KeychainProvider extends ContentProvider { projectionMap.put(Certs.VERIFIED, Tables.CERTS + "." + Certs.VERIFIED); projectionMap.put(Certs.TYPE, Tables.CERTS + "." + Certs.TYPE); projectionMap.put(Certs.CREATION, Tables.CERTS + "." + Certs.CREATION); + projectionMap.put(Certs.EXPIRY, Tables.CERTS + "." + Certs.EXPIRY); projectionMap.put(Certs.KEY_ID_CERTIFIER, Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER); projectionMap.put(Certs.USER_ID, Tables.USER_IDS + "." + UserIds.USER_ID); projectionMap.put(Certs.SIGNER_UID, "signer." + UserIds.USER_ID + " AS " + Certs.SIGNER_UID); @@ -450,7 +456,7 @@ public class KeychainProvider extends ContentProvider { qb.setTables(Tables.CERTS + " JOIN " + Tables.USER_IDS + " ON (" - + Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = " + + Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = " + Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " AND " + Tables.CERTS + "." + Certs.RANK + " = " @@ -465,10 +471,17 @@ public class KeychainProvider extends ContentProvider { groupBy = Tables.CERTS + "." + Certs.RANK + ", " + Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER; - qb.appendWhere(Tables.CERTS + "." + KeyRings.MASTER_KEY_ID + " = "); + qb.appendWhere(Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = "); qb.appendWhereEscapeString(uri.getPathSegments().get(1)); + if(match == KEY_RING_CERTS_SPECIFIC) { + qb.appendWhere(" AND " + Tables.CERTS + "." + Certs.RANK + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(3)); + qb.appendWhere(" AND " + Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER+ " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(4)); + } break; + } case API_APPS: qb.setTables(Tables.API_APPS); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java index e5f2fb173..4e525cff8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java @@ -59,16 +59,14 @@ public class ViewCertActivity extends ActionBarActivity Certs.EXPIRY, Certs.KEY_ID_CERTIFIER, Certs.SIGNER_UID, - Certs.TYPE }; - private static final int INDEX_MASTER_KEY_ID = 1; - private static final int INDEX_USER_ID = 2; - private static final int INDEX_TYPE = 3; - private static final int INDEX_CREATION = 4; - private static final int INDEX_EXPIRY = 5; - private static final int INDEX_KEY_ID_CERTIFIER = 6; - private static final int INDEX_UID_CERTIFIER = 7; - private static final int INDEX_KEY_TYPE = 8; + private static final int INDEX_MASTER_KEY_ID = 0; + private static final int INDEX_USER_ID = 1; + private static final int INDEX_TYPE = 2; + private static final int INDEX_CREATION = 3; + private static final int INDEX_EXPIRY = 4; + private static final int INDEX_KEY_ID_CERTIFIER = 5; + private static final int INDEX_SIGNER_UID = 6; private Uri mDataUri; @@ -130,7 +128,7 @@ public class ViewCertActivity extends ActionBarActivity String signerKey = "0x" + PgpKeyHelper.convertKeyIdToHex(mSignerKeyId); mSignerKey.setText(signerKey); - String signerUid = data.getString(INDEX_UID_CERTIFIER); + String signerUid = data.getString(INDEX_SIGNER_UID); if(signerUid != null) mSignerUid.setText(signerUid); else @@ -141,19 +139,21 @@ public class ViewCertActivity extends ActionBarActivity switch(data.getInt(INDEX_TYPE)) { case PGPSignature.DEFAULT_CERTIFICATION: - mType.setText(R.string.sig_type_default); break; + mType.setText(R.string.cert_default); break; case PGPSignature.NO_CERTIFICATION: - mType.setText(R.string.sig_type_none); break; + mType.setText(R.string.cert_none); break; case PGPSignature.CASUAL_CERTIFICATION: - mType.setText(R.string.sig_type_casual); break; + mType.setText(R.string.cert_casual); break; case PGPSignature.POSITIVE_CERTIFICATION: - mType.setText(R.string.sig_type_positive); break; + mType.setText(R.string.cert_positive); break; + case PGPSignature.CERTIFICATION_REVOCATION: + mType.setText(R.string.cert_revoke); break; } long expiry = data.getLong(INDEX_EXPIRY); - if(expiry == 0) - mExpiry.setText("never"); - else { + if(expiry == 0) { + mExpiry.setText(R.string.never); + } else { Date expiryDate = new Date(creationDate.getTime() + expiry * 1000); mExpiry.setText(DateFormat.getDateFormat(getApplicationContext()).format(expiryDate)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java index 325e9e179..a872443af 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java @@ -142,10 +142,16 @@ public class ViewKeyCertsFragment extends Fragment */ @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { - Intent viewIntent = null; - viewIntent = new Intent(getActivity(), ViewCertActivity.class); - viewIntent.setData(Certs.buildCertsUri(Long.toString(id))); - startActivity(viewIntent); + if(view.getTag(R.id.tag_mki) != null) { + long masterKeyId = (Long) view.getTag(R.id.tag_mki); + long rank = (Long) view.getTag(R.id.tag_rank); + long certifierId = (Long) view.getTag(R.id.tag_certifierId); + + Intent viewIntent = new Intent(getActivity(), ViewCertActivity.class); + viewIntent.setData(Certs.buildCertsSpecificUri( + Long.toString(masterKeyId), Long.toString(rank), Long.toString(certifierId))); + startActivity(viewIntent); + } } @Override @@ -161,8 +167,7 @@ public class ViewKeyCertsFragment extends Fragment */ private class CertListAdapter extends CursorAdapter implements StickyListHeadersAdapter { private LayoutInflater mInflater; - private int mIndexCertId; - private int mIndexUserId, mIndexRank; + private int mIndexMasterKeyId, mIndexUserId, mIndexRank; private int mIndexSignerKeyId, mIndexSignerUserId; private int mIndexVerified, mIndexType; @@ -189,7 +194,7 @@ public class ViewKeyCertsFragment extends Fragment private void initIndex(Cursor cursor) { if (cursor != null) { - mIndexCertId = cursor.getColumnIndexOrThrow(Certs.MASTER_KEY_ID); + mIndexMasterKeyId = cursor.getColumnIndexOrThrow(Certs.MASTER_KEY_ID); mIndexUserId = cursor.getColumnIndexOrThrow(Certs.USER_ID); mIndexRank = cursor.getColumnIndexOrThrow(Certs.RANK); mIndexType = cursor.getColumnIndexOrThrow(Certs.TYPE); @@ -231,6 +236,10 @@ public class ViewKeyCertsFragment extends Fragment wSignerUserId.setText(signerUserId); wSignerKeyId.setText(signerKeyId); + view.setTag(R.id.tag_mki, cursor.getLong(mIndexMasterKeyId)); + view.setTag(R.id.tag_rank, cursor.getLong(mIndexRank)); + view.setTag(R.id.tag_certifierId, cursor.getLong(mIndexSignerKeyId)); + } @Override diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index e678d8848..15693401f 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -486,14 +486,14 @@ <string name="secret_key_yes">available</string> <string name="secret_key_no">unavailable</string> + <!-- hints --> + <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> + <!-- unsorted --> <string name="show_unknown_signatures">Show unknown signatures</string> <string name="section_signer_id">Signer</string> <string name="section_cert">Certificate Details</string> - <string name="sig_type_default">default</string> - <string name="sig_type_none">none</string> - <string name="sig_type_casual">casual</string> - <string name="sig_type_positive">positive</string> <string name="label_user_id">User ID</string> <string name="label_subkey_rank">Subkey Rank</string> <string name="unknown_uid"><![CDATA[<unknown>]]></string> @@ -503,14 +503,11 @@ <string name="certs_list_known_secret">Show by known secret keys</string> <string name="certs_list_known">Show by known public keys</string> <string name="certs_list_all">Show all certificates</string> - - <!-- hints --> - <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="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="never">never</string> </resources> |