aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP-Keychain/src/main')
-rw-r--r--OpenPGP-Keychain/src/main/AndroidManifest.xml9
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java24
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java6
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java40
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java22
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java108
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java98
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java16
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java199
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java14
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java278
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java27
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java5
-rw-r--r--OpenPGP-Keychain/src/main/res/layout/view_cert_activity.xml207
-rw-r--r--OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml54
-rw-r--r--OpenPGP-Keychain/src/main/res/layout/view_key_certs_header.xml30
-rw-r--r--OpenPGP-Keychain/src/main/res/layout/view_key_certs_item.xml46
-rw-r--r--OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml11
-rw-r--r--OpenPGP-Keychain/src/main/res/menu/view_cert.xml13
-rw-r--r--OpenPGP-Keychain/src/main/res/values/strings.xml11
20 files changed, 1130 insertions, 88 deletions
diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml
index b1fbcf555..bd45def24 100644
--- a/OpenPGP-Keychain/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml
@@ -95,6 +95,15 @@
android:value=".ui.KeyListActivity" />
</activity>
<activity
+ android:name=".ui.ViewCertActivity"
+ android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
+ android:label="View Certificate Details"
+ android:parentActivityName=".ui.ViewKeyActivity">
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".ui.ViewKeyActivity" />
+ </activity>
+ <activity
android:name=".ui.SelectPublicKeyActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_select_recipients"
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java
index a30e0718f..b268de3a6 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java
@@ -26,6 +26,8 @@ import org.spongycastle.openpgp.PGPKeyRing;
import org.spongycastle.openpgp.PGPObjectFactory;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
+import org.spongycastle.openpgp.PGPSignature;
+import org.spongycastle.openpgp.PGPSignatureList;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.util.Log;
@@ -104,6 +106,28 @@ public class PgpConversionHelper {
}
/**
+ * Convert from byte[] to PGPSignature
+ *
+ * @param sigBytes
+ * @return
+ */
+ public static PGPSignature BytesToPGPSignature(byte[] sigBytes) {
+ PGPObjectFactory factory = new PGPObjectFactory(sigBytes);
+ PGPSignatureList signatures = null;
+ try {
+ if ((signatures = (PGPSignatureList) factory.nextObject()) == null || signatures.isEmpty()) {
+ Log.e(Constants.TAG, "No signatures given!");
+ return null;
+ }
+ } catch (IOException e) {
+ Log.e(Constants.TAG, "Error while converting to PGPSignature!", e);
+ return null;
+ }
+
+ return signatures.get(0);
+ }
+
+ /**
* Convert from ArrayList<PGPSecretKey> to byte[]
*
* @param keys
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
index 71c921c33..902dd8da9 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
@@ -422,7 +422,6 @@ public class PgpKeyHelper {
algorithmStr = "RSA";
break;
}
-
case PGPPublicKey.DSA: {
algorithmStr = "DSA";
break;
@@ -439,7 +438,10 @@ public class PgpKeyHelper {
break;
}
}
- return algorithmStr + ", " + keySize + " bit";
+ if(keySize > 0)
+ return algorithmStr + ", " + keySize + " bit";
+ else
+ return algorithmStr;
}
public static String getFingerPrint(Context context, long keyId) {
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 706b30d05..f9439e338 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
@@ -54,6 +54,16 @@ public class KeychainContract {
String RANK = "rank";
}
+ interface CertsColumns {
+ String KEY_RING_ROW_ID = "key_ring_row_id"; // verified id, foreign key to key_rings._ID
+ String RANK = "rank"; // rank of verified key
+ String KEY_ID = "key_id"; // verified id, not a database id
+ String KEY_ID_CERTIFIER = "key_id_certifier"; // verifying id, not a database id
+ String CREATION = "creation";
+ String VERIFIED = "verified";
+ String KEY_DATA = "key_data"; // certification blob
+ }
+
interface ApiAppsColumns {
String PACKAGE_NAME = "package_name";
String PACKAGE_SIGNATURE = "package_signature";
@@ -82,6 +92,8 @@ public class KeychainContract {
public static final String PATH_BY_MASTER_KEY_ID = "master_key_id";
public static final String PATH_BY_KEY_ID = "key_id";
+ public static final String PATH_BY_KEY_ROW_ID = "key_row_id";
+ public static final String PATH_BY_CERTIFIER_ID = "certifier_id";
public static final String PATH_BY_EMAILS = "emails";
public static final String PATH_BY_LIKE_EMAIL = "like_email";
@@ -91,6 +103,8 @@ public class KeychainContract {
public static final String BASE_API_APPS = "api_apps";
public static final String PATH_BY_PACKAGE_NAME = "package_name";
+ public static final String BASE_CERTS = "certs";
+
public static class KeyRings implements KeyRingsColumns, BaseColumns {
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
.appendPath(BASE_KEY_RINGS).build();
@@ -260,6 +274,32 @@ public class KeychainContract {
}
}
+ public static class Certs implements CertsColumns, BaseColumns {
+ public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
+ .appendPath(BASE_CERTS).build();
+
+ // do we even need this one...? just using it as default for database insert notifications~
+ public static Uri buildCertsUri(String rowId) {
+ return CONTENT_URI.buildUpon().appendPath(rowId).build();
+ }
+
+ public static Uri buildCertsByKeyRowIdUri(String keyRingRowId) {
+ return CONTENT_URI.buildUpon().appendPath(PATH_BY_KEY_ROW_ID)
+ .appendPath(keyRingRowId).build();
+ }
+
+ public static Uri buildCertsByKeyIdUri(String keyId) {
+ return CONTENT_URI.buildUpon().appendPath(PATH_BY_KEY_ID).appendPath(keyId)
+ .build();
+ }
+
+ public static Uri buildCertsByCertifierKeyIdUri(String keyId) {
+ return CONTENT_URI.buildUpon().appendPath(PATH_BY_CERTIFIER_ID).appendPath(keyId)
+ .build();
+ }
+
+ }
+
public static class DataStream {
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
.appendPath(BASE_DATA).build();
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
index 5f18ed6f9..1a2853dbe 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
@@ -22,6 +22,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns;
+import org.sufficientlysecure.keychain.provider.KeychainContract.CertsColumns;
import org.sufficientlysecure.keychain.util.Log;
import android.content.Context;
@@ -31,13 +32,14 @@ import android.provider.BaseColumns;
public class KeychainDatabase extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "apg.db";
- private static final int DATABASE_VERSION = 7;
+ private static final int DATABASE_VERSION = 8;
public interface Tables {
String KEY_RINGS = "key_rings";
String KEYS = "keys";
String USER_IDS = "user_ids";
String API_APPS = "api_apps";
+ String CERTS = "certs";
}
private static final String CREATE_KEY_RINGS = "CREATE TABLE IF NOT EXISTS " + Tables.KEY_RINGS
@@ -83,6 +85,18 @@ public class KeychainDatabase extends SQLiteOpenHelper {
+ ApiAppsColumns.HASH_ALORITHM + " INTEGER, "
+ ApiAppsColumns.COMPRESSION + " INTEGER)";
+ private static final String CREATE_CERTS = "CREATE TABLE IF NOT EXISTS " + Tables.CERTS
+ + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ + CertsColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL "
+ + " REFERENCES " + Tables.KEY_RINGS + "(" + BaseColumns._ID + ") ON DELETE CASCADE, "
+ + CertsColumns.KEY_ID + " INTEGER, " // certified key
+ + CertsColumns.RANK + " INTEGER, " // key rank of certified uid
+ + CertsColumns.KEY_ID_CERTIFIER + " INTEGER, " // certifying key
+ + CertsColumns.CREATION + " INTEGER, "
+ + CertsColumns.VERIFIED + " INTEGER, "
+ + CertsColumns.KEY_DATA+ " BLOB)";
+
+
KeychainDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@@ -95,6 +109,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
db.execSQL(CREATE_KEYS);
db.execSQL(CREATE_USER_IDS);
db.execSQL(CREATE_API_APPS);
+ db.execSQL(CREATE_CERTS);
}
@Override
@@ -134,6 +149,11 @@ public class KeychainDatabase extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + Tables.KEYS + " ADD COLUMN " + KeysColumns.FINGERPRINT
+ " BLOB;");
break;
+ case 7:
+ // new table: certs
+ db.execSQL(CREATE_CERTS);
+
+ break;
default:
break;
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 8b0efdbbd..f072e13be 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
@@ -29,6 +29,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns;
+import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
import org.sufficientlysecure.keychain.util.Log;
@@ -83,6 +84,13 @@ public class KeychainProvider extends ContentProvider {
private static final int UNIFIED_KEY_RING = 401;
+ private static final int CERTS = 401;
+ private static final int CERTS_BY_KEY_ID = 402;
+ private static final int CERTS_BY_ROW_ID = 403;
+ private static final int CERTS_BY_KEY_ROW_ID = 404;
+ private static final int CERTS_BY_KEY_ROW_ID_ALL = 405;
+ private static final int CERTS_BY_CERTIFIER_ID = 406;
+
// private static final int DATA_STREAM = 401;
protected UriMatcher mUriMatcher;
@@ -239,6 +247,24 @@ public class KeychainProvider extends ContentProvider {
+ KeychainContract.PATH_UNIFIED, UNIFIED_KEY_RING);
/**
+ * certifications
+ * <pre>
+ *
+ * key_rings/unified
+ *
+ */
+ matcher.addURI(authority, KeychainContract.BASE_CERTS, CERTS);
+ matcher.addURI(authority, KeychainContract.BASE_CERTS + "/#", CERTS_BY_ROW_ID);
+ matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ + KeychainContract.PATH_BY_KEY_ROW_ID + "/#", CERTS_BY_KEY_ROW_ID);
+ matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ + KeychainContract.PATH_BY_KEY_ROW_ID + "/#/all", CERTS_BY_KEY_ROW_ID_ALL);
+ matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ + KeychainContract.PATH_BY_KEY_ID + "/#", CERTS_BY_KEY_ID);
+ matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ + KeychainContract.PATH_BY_CERTIFIER_ID + "/#", CERTS_BY_CERTIFIER_ID);
+
+ /**
* data stream
*
* <pre>
@@ -465,6 +491,8 @@ public class KeychainProvider extends ContentProvider {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
SQLiteDatabase db = mApgDatabase.getReadableDatabase();
+ String groupBy = null;
+
int match = mUriMatcher.match(uri);
// screw that switch
@@ -530,6 +558,7 @@ public class KeychainProvider extends ContentProvider {
return c;
}
+ boolean all = false;
switch (match) {
case PUBLIC_KEY_RING:
case SECRET_KEY_RING:
@@ -657,8 +686,25 @@ public class KeychainProvider extends ContentProvider {
case PUBLIC_KEY_RING_USER_ID:
case SECRET_KEY_RING_USER_ID:
- qb.setTables(Tables.USER_IDS);
- qb.appendWhere(UserIdsColumns.KEY_RING_ROW_ID + " = ");
+ qb.setTables(Tables.USER_IDS
+ + " LEFT JOIN " + Tables.CERTS
+ + " ON ("
+ + Tables.USER_IDS + "." + UserIds.KEY_RING_ROW_ID + " = "
+ + Tables.CERTS + "." + Certs.KEY_RING_ROW_ID
+ + " AND " + Tables.USER_IDS + "." + UserIds.RANK + " = "
+ + Tables.CERTS + "." + Certs.RANK
+ + ")");
+
+ groupBy = Tables.USER_IDS + "." + UserIds.RANK;
+
+ HashMap<String, String> pmap = new HashMap<String, String>();
+ pmap.put(UserIds._ID, Tables.USER_IDS + "." + UserIds._ID);
+ pmap.put(UserIds.USER_ID, Tables.USER_IDS + "." + UserIds.USER_ID);
+ pmap.put(UserIds.RANK, Tables.USER_IDS + "." + UserIds.RANK);
+ pmap.put("verified", "COUNT(" + Tables.CERTS + "." + Certs._ID + ") AS verified");
+ qb.setProjectionMap(pmap);
+
+ qb.appendWhere(Tables.USER_IDS + "." + UserIdsColumns.KEY_RING_ROW_ID + " = ");
qb.appendWhereEscapeString(uri.getPathSegments().get(2));
break;
@@ -674,6 +720,56 @@ public class KeychainProvider extends ContentProvider {
break;
+ case CERTS_BY_ROW_ID:
+ case CERTS_BY_KEY_ROW_ID_ALL:
+ all = true;
+ case CERTS_BY_KEY_ROW_ID:
+ qb.setTables(Tables.CERTS
+ + " JOIN " + Tables.USER_IDS + " ON ("
+ + Tables.CERTS + "." + Certs.KEY_RING_ROW_ID + " = "
+ + Tables.USER_IDS + "." + UserIds.KEY_RING_ROW_ID
+ + " AND "
+ + Tables.CERTS + "." + Certs.RANK + " = "
+ + Tables.USER_IDS + "." + UserIds.RANK
+ // noooooooot sure about this~ database design
+ + ")" + (all ? " LEFT" : "")
+ + " JOIN " + Tables.KEYS + " ON ("
+ + Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER + " = "
+ + Tables.KEYS + "." + Keys.KEY_ID
+ + ") LEFT JOIN " + Tables.USER_IDS + " AS signer ON ("
+ + Tables.KEYS + "." + Keys.KEY_RING_ROW_ID + " = "
+ + "signer." + UserIds.KEY_RING_ROW_ID
+ + " AND "
+ + Tables.KEYS + "." + Keys.RANK + " = "
+ + "signer." + UserIds.RANK
+ + ")");
+
+ // groupBy = Tables.USER_IDS + "." + UserIds.RANK;
+
+ HashMap<String, String> pmap2 = new HashMap<String, String>();
+ pmap2.put(Certs._ID, Tables.CERTS + "." + Certs._ID);
+ pmap2.put(Certs.KEY_ID, Tables.CERTS + "." + Certs.KEY_ID);
+ pmap2.put(Certs.RANK, Tables.CERTS + "." + Certs.RANK);
+ pmap2.put(Certs.CREATION, Tables.CERTS + "." + Certs.CREATION);
+ pmap2.put(Certs.KEY_ID_CERTIFIER, Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER);
+ pmap2.put(Certs.KEY_DATA, Tables.CERTS + "." + Certs.KEY_DATA);
+ pmap2.put(Certs.VERIFIED, Tables.CERTS + "." + Certs.VERIFIED);
+ // verified key data
+ pmap2.put(UserIds.USER_ID, Tables.USER_IDS + "." + UserIds.USER_ID);
+ // verifying key data
+ pmap2.put("signer_uid", "signer." + UserIds.USER_ID + " AS signer_uid");
+ qb.setProjectionMap(pmap2);
+
+ if(match == CERTS_BY_ROW_ID) {
+ qb.appendWhere(Tables.CERTS + "." + Certs._ID + " = ");
+ qb.appendWhereEscapeString(uri.getPathSegments().get(1));
+ } else {
+ qb.appendWhere(Tables.CERTS + "." + Certs.KEY_RING_ROW_ID + " = ");
+ qb.appendWhereEscapeString(uri.getPathSegments().get(2));
+ }
+
+ break;
+
case API_APPS:
qb.setTables(Tables.API_APPS);
@@ -705,7 +801,7 @@ public class KeychainProvider extends ContentProvider {
orderBy = sortOrder;
}
- Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
+ Cursor c = qb.query(db, projection, selection, selectionArgs, groupBy, null, orderBy);
// Tell the cursor what uri to watch, so it knows when its source data changes
c.setNotificationUri(getContext().getContentResolver(), uri);
@@ -784,6 +880,12 @@ public class KeychainProvider extends ContentProvider {
rowUri = ApiApps.buildIdUri(Long.toString(rowId));
break;
+ case CERTS_BY_ROW_ID:
+ rowId = db.insertOrThrow(Tables.CERTS, null, values);
+ // kinda useless.. should this be buildCertsByKeyRowIdUri?
+ rowUri = Certs.buildCertsUri(Long.toString(rowId));
+
+ break;
default:
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
index 1c05344d6..f740e1c7c 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -19,16 +19,23 @@ package org.sufficientlysecure.keychain.provider;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.security.SignatureException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Date;
import org.spongycastle.bcpg.ArmoredOutputStream;
+import org.spongycastle.bcpg.UserAttributePacket;
+import org.spongycastle.bcpg.UserAttributeSubpacket;
+import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPKeyRing;
import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.spongycastle.openpgp.PGPSignature;
+import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
@@ -37,6 +44,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
+import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
import org.sufficientlysecure.keychain.service.remote.AppSettings;
import org.sufficientlysecure.keychain.util.IterableIterator;
@@ -57,25 +65,30 @@ public class ProviderHelper {
/**
* Private helper method to get PGPKeyRing from database
*/
- public static PGPKeyRing getPGPKeyRing(Context context, Uri queryUri) {
+ public static Map<Long, PGPKeyRing> getPGPKeyRings(Context context, Uri queryUri) {
Cursor cursor = context.getContentResolver().query(queryUri,
- new String[]{KeyRings._ID, KeyRings.KEY_RING_DATA}, null, null, null);
+ new String[]{KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.KEY_RING_DATA}, null, null, null);
- PGPKeyRing keyRing = null;
- if (cursor != null && cursor.moveToFirst()) {
+ Map<Long, PGPKeyRing> result = new HashMap<Long, PGPKeyRing>(cursor.getCount());
+ if (cursor != null && cursor.moveToFirst()) do {
int keyRingDataCol = cursor.getColumnIndex(KeyRings.KEY_RING_DATA);
+ int masterKeyIdCol = cursor.getColumnIndex(KeyRings.MASTER_KEY_ID);
byte[] data = cursor.getBlob(keyRingDataCol);
if (data != null) {
- keyRing = PgpConversionHelper.BytesToPGPKeyRing(data);
+ result.put(cursor.getLong(masterKeyIdCol), PgpConversionHelper.BytesToPGPKeyRing(data));
}
- }
+
+ } while(cursor.moveToNext());
if (cursor != null) {
cursor.close();
}
- return keyRing;
+ return result;
+ }
+ public static PGPKeyRing getPGPKeyRing(Context context, Uri queryUri) {
+ return getPGPKeyRings(context, queryUri).values().iterator().next();
}
/**
@@ -199,18 +212,51 @@ public class ProviderHelper {
++rank;
}
+ // get a list of owned secret keys, for verification filtering
+ Map<Long, PGPKeyRing> allKeyRings = getPGPKeyRings(context, KeyRings.buildPublicKeyRingsUri());
+
int userIdRank = 0;
for (String userId : new IterableIterator<String>(masterKey.getUserIDs())) {
operations.add(buildPublicUserIdOperations(context, keyRingRowId, userId, userIdRank));
- ++userIdRank;
- }
- for (PGPSignature certification : new IterableIterator<PGPSignature>(masterKey.getSignaturesOfType(PGPSignature.POSITIVE_CERTIFICATION))) {
- //TODO: how to do this?? we need to verify the signatures again and again when they are displayed...
-// if (certification.verify
-// operations.add(buildPublicKeyOperations(context, keyRingRowId, key, rank));
- }
+ // look through signatures for this specific key
+ for (PGPSignature cert : new IterableIterator<PGPSignature>(
+ masterKey.getSignaturesForID(userId))) {
+ long certId = cert.getKeyID();
+ boolean verified = false;
+ // only care for signatures from our own private keys
+ if(allKeyRings.containsKey(certId)) try {
+ // mark them as verified
+ cert.init(new JcaPGPContentVerifierBuilderProvider().setProvider("SC"), allKeyRings.get(certId).getPublicKey());
+ verified = cert.verifyCertification(userId, masterKey);
+ // TODO: at this point, we only save signatures from available secret keys.
+ // should we save all? those are quite a lot of rows for info we don't really
+ // use. I left it out for now - it is available from key servers, so we can
+ // always get it later.
+ Log.d(Constants.TAG, "sig for " + userId + " " + verified + " from "
+ + PgpKeyHelper.convertKeyIdToHex(cert.getKeyID())
+ );
+ operations.add(buildPublicCertOperations(
+ context, keyRingRowId, userIdRank, masterKey.getKeyID(), cert, verified));
+ } catch(SignatureException e) {
+ Log.e(Constants.TAG, "Signature verification failed.", e);
+ } catch(PGPException e) {
+ Log.e(Constants.TAG, "Signature verification failed.", e);
+ } else {
+ Log.d(Constants.TAG, "ignored sig for "
+ + PgpKeyHelper.convertKeyIdToHex(masterKey.getKeyID())
+ + " from "
+ + PgpKeyHelper.convertKeyIdToHex(cert.getKeyID())
+ );
+ operations.add(buildPublicCertOperations(
+ context, keyRingRowId, userIdRank, masterKey.getKeyID(), cert, false));
+ }
+ // if we wanted to save all, not just our own verifications
+ // buildPublicCertOperations(context, keyRingRowId, rank, cert, verified);
+ }
+ ++userIdRank;
+ }
try {
context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY, operations);
@@ -314,6 +360,30 @@ public class ProviderHelper {
}
/**
+ * Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
+ */
+ private static ContentProviderOperation buildPublicCertOperations(Context context,
+ long keyRingRowId,
+ int rank,
+ long keyId,
+ PGPSignature cert,
+ boolean verified)
+ throws IOException {
+ ContentValues values = new ContentValues();
+ values.put(Certs.KEY_RING_ROW_ID, keyRingRowId);
+ values.put(Certs.RANK, rank);
+ values.put(Certs.KEY_ID, keyId);
+ values.put(Certs.KEY_ID_CERTIFIER, cert.getKeyID());
+ values.put(Certs.CREATION, cert.getCreationTime().getTime() / 1000);
+ values.put(Certs.VERIFIED, verified);
+ values.put(Certs.KEY_DATA, cert.getEncoded());
+
+ Uri uri = Certs.buildCertsUri(Long.toString(keyRingRowId));
+
+ return ContentProviderOperation.newInsert(uri).withValues(values).build();
+ }
+
+ /**
* Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing
*/
private static ContentProviderOperation buildPublicUserIdOperations(Context context,
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
index 5b57132d4..c4a694bba 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
@@ -310,7 +310,9 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
} else {
viewIntent = new Intent(getActivity(), ViewKeyActivityJB.class);
}
- viewIntent.setData(KeychainContract.KeyRings.buildPublicKeyRingsByMasterKeyIdUri(Long.toString(mAdapter.getMasterKeyId(position))));
+ viewIntent.setData(KeychainContract.KeyRings.buildPublicKeyRingsByMasterKeyIdUri(
+ Long.toString(mAdapter.getMasterKeyId(position)))
+ );
startActivity(viewIntent);
}
@@ -492,8 +494,8 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
/**
* Bind cursor data to the item list view
* <p/>
- * NOTE: CursorAdapter already implements the ViewHolder pattern in its getView() method. Thus
- * no ViewHolder is required here.
+ * NOTE: CursorAdapter already implements the ViewHolder pattern in its getView() method.
+ * Thus no ViewHolder is required here.
*/
@Override
public void bindView(View view, Context context, Cursor cursor) {
@@ -530,7 +532,11 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
button.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
Intent editIntent = new Intent(getActivity(), EditKeyActivity.class);
- editIntent.setData(KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(id)));
+ editIntent.setData(
+ KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(
+ Long.toString(id)
+ )
+ );
editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY);
startActivityForResult(editIntent, 0);
}
@@ -617,7 +623,7 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
String userId = mCursor.getString(KeyListFragment.INDEX_UID);
String headerText = convertView.getResources().getString(R.string.user_id_no_name);
if (userId != null && userId.length() > 0) {
- headerText = "" + mCursor.getString(KeyListFragment.INDEX_UID).subSequence(0, 1).charAt(0);
+ headerText = "" + userId.subSequence(0, 1).charAt(0);
}
holder.text.setText(headerText);
holder.count.setVisibility(View.GONE);
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
new file mode 100644
index 000000000..c0ecc5001
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2011 Senecaso
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.sufficientlysecure.keychain.ui;
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
+import android.text.format.DateFormat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.TextView;
+
+import org.spongycastle.openpgp.PGPSignature;
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
+import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
+import org.sufficientlysecure.keychain.provider.KeychainContract;
+import org.sufficientlysecure.keychain.util.Log;
+
+import java.util.Date;
+
+/**
+ * Swag
+ */
+public class ViewCertActivity extends ActionBarActivity
+ implements LoaderManager.LoaderCallbacks<Cursor> {
+
+ // These are the rows that we will retrieve.
+ static final String[] PROJECTION = new String[] {
+ KeychainContract.Certs._ID,
+ KeychainContract.Certs.KEY_ID,
+ KeychainContract.UserIds.USER_ID,
+ KeychainContract.Certs.RANK,
+ KeychainContract.Certs.CREATION,
+ KeychainContract.Certs.KEY_ID_CERTIFIER,
+ "signer_uid",
+ KeychainContract.Certs.KEY_DATA
+ };
+
+ private Uri mDataUri;
+
+ private long mSignerKeyId;
+
+ private TextView mSigneeKey, mSigneeUid, mRank, mAlgorithm, mType, mCreation, mExpiry;
+ private TextView mSignerKey, mSignerUid;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ setContentView(R.layout.view_cert_activity);
+
+ mSigneeKey = (TextView) findViewById(R.id.signee_key);
+ mSigneeUid = (TextView) findViewById(R.id.signee_uid);
+ mRank = (TextView) findViewById(R.id.subkey_rank);
+ mAlgorithm = (TextView) findViewById(R.id.algorithm);
+ mType = (TextView) findViewById(R.id.signature_type);
+ mCreation = (TextView) findViewById(R.id.creation);
+ mExpiry = (TextView) findViewById(R.id.expiry);
+
+ mSignerKey = (TextView) findViewById(R.id.signer_key_id);
+ mSignerUid = (TextView) findViewById(R.id.signer_uid);
+
+ mDataUri = getIntent().getData();
+ if (mDataUri == null) {
+ Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!");
+ finish();
+ return;
+ }
+
+ getSupportLoaderManager().initLoader(0, null, this);
+
+ }
+
+ @Override
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ // Now create and return a CursorLoader that will take care of
+ // creating a Cursor for the data being displayed.
+ return new CursorLoader(this, mDataUri, PROJECTION, null, null, null);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ if(data.moveToFirst()) {
+ String signeeKey = "0x" + PgpKeyHelper.convertKeyIdToHex(data.getLong(1));
+ mSigneeKey.setText(signeeKey);
+
+ String signeeUid = data.getString(2);
+ mSigneeUid.setText(signeeUid);
+
+ String subkey_rank = Integer.toString(data.getInt(3));
+ mRank.setText(subkey_rank);
+
+ Date creationDate = new Date(data.getLong(4) * 1000);
+ mCreation.setText(DateFormat.getDateFormat(getApplicationContext()).format(creationDate));
+
+ mSignerKeyId = data.getLong(5);
+ String signerKey = "0x" + PgpKeyHelper.convertKeyIdToHex(mSignerKeyId);
+ mSignerKey.setText(signerKey);
+
+ String signerUid = data.getString(6);
+ if(signerUid != null)
+ mSignerUid.setText(signerUid);
+ else
+ mSignerUid.setText(R.string.unknown_uid);
+
+ byte[] sigData = data.getBlob(7);
+ PGPSignature sig = PgpConversionHelper.BytesToPGPSignature(sigData);
+ if(sig != null) {
+ String algorithmStr = PgpKeyHelper.getAlgorithmInfo(sig.getKeyAlgorithm(), 0);
+ mAlgorithm.setText(algorithmStr);
+
+ switch(sig.getSignatureType()) {
+ case PGPSignature.DEFAULT_CERTIFICATION:
+ mType.setText(R.string.sig_type_default); break;
+ case PGPSignature.NO_CERTIFICATION:
+ mType.setText(R.string.sig_type_none); break;
+ case PGPSignature.CASUAL_CERTIFICATION:
+ mType.setText(R.string.sig_type_casual); break;
+ case PGPSignature.POSITIVE_CERTIFICATION:
+ mType.setText(R.string.sig_type_positive); break;
+ }
+
+ long expiry = sig.getHashedSubPackets().getSignatureExpirationTime();
+ if(expiry == 0)
+ mExpiry.setText("never");
+ else {
+ Date expiryDate = new Date(creationDate.getTime() + expiry * 1000);
+ mExpiry.setText(DateFormat.getDateFormat(getApplicationContext()).format(expiryDate));
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ getMenuInflater().inflate(R.menu.view_cert, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_view_cert_verify:
+ // TODO verification routine
+ return true;
+ case R.id.menu_view_cert_view_signer:
+ // can't do this before the data is initialized
+ // TODO notify user of this, maybe offer download?
+ if(mSignerKeyId == 0)
+ return true;
+ Intent viewIntent = null;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ viewIntent = new Intent(this, ViewKeyActivity.class);
+ } else {
+ viewIntent = new Intent(this, ViewKeyActivityJB.class);
+ }
+ viewIntent.setData(KeychainContract.KeyRings.buildPublicKeyRingsByMasterKeyIdUri(
+ Long.toString(mSignerKeyId))
+ );
+ startActivity(viewIntent);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
index 581d14a22..01a2740b1 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -84,13 +84,11 @@ public class ViewKeyActivity extends ActionBarActivity {
selectedTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB);
}
- {
- // normalize mDataUri to a "by row id" query, to ensure it works with any
- // given valid /public/ query
- long rowId = ProviderHelper.getRowId(this, getIntent().getData());
- // TODO: handle (rowId == 0) with something else than a crash
- mDataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)) ;
- }
+ // normalize mDataUri to a "by row id" query, to ensure it works with any
+ // given valid /public/ query
+ long rowId = ProviderHelper.getRowId(this, getIntent().getData());
+ // TODO: handle (rowId == 0) with something else than a crash
+ mDataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)) ;
Bundle mainBundle = new Bundle();
mainBundle.putParcelable(ViewKeyMainFragment.ARG_DATA_URI, mDataUri);
@@ -98,7 +96,7 @@ public class ViewKeyActivity extends ActionBarActivity {
ViewKeyMainFragment.class, mainBundle, (selectedTab == 0));
Bundle certBundle = new Bundle();
- certBundle.putParcelable(ViewKeyCertsFragment.ARG_DATA_URI, mDataUri);
+ certBundle.putLong(ViewKeyCertsFragment.ARG_KEYRING_ROW_ID, rowId);
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.key_view_tab_certs)),
ViewKeyCertsFragment.class, certBundle, (selectedTab == 1));
}
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 36d3e6ace..e12c93d2f 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
@@ -17,76 +17,300 @@
package org.sufficientlysecure.keychain.ui;
+import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-
-import com.beardedhen.androidbootstrap.BootstrapButton;
+import android.widget.AdapterView;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
+import org.sufficientlysecure.keychain.provider.KeychainContract;
+import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.util.Log;
+import se.emilsjolander.stickylistheaders.ApiLevelTooLowException;
+import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
+import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
+
+
+public class ViewKeyCertsFragment extends Fragment
+ implements LoaderManager.LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener {
+
+ // These are the rows that we will retrieve.
+ static final String[] PROJECTION = new String[] {
+ KeychainContract.Certs._ID,
+ KeychainContract.Certs.VERIFIED,
+ KeychainContract.Certs.RANK,
+ KeychainContract.Certs.KEY_ID_CERTIFIER,
+ KeychainContract.UserIds.USER_ID,
+ "signer_uid"
+ };
+
+ // sort by our user id,
+ static final String SORT_ORDER =
+ KeychainDatabase.Tables.USER_IDS + "." + KeychainContract.UserIds.USER_ID + " ASC, "
+ + KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.VERIFIED + " DESC, "
+ + "signer_uid ASC";
-public class ViewKeyCertsFragment extends Fragment {
+ public static final String ARG_KEYRING_ROW_ID = "row_id";
- public static final String ARG_DATA_URI = "uri";
+ private StickyListHeadersListView mStickyList;
+ private CheckBox mShowUnknown;
- private BootstrapButton mActionCertify;
+ private CertListAdapter mAdapter;
+ private boolean mUnknownShown = false;
- private Uri mDataUri;
+ private Uri mBaseUri, mDataUri;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.view_key_certs_fragment, container, false);
- mActionCertify = (BootstrapButton) view.findViewById(R.id.action_certify);
-
return view;
}
+ private void toggleShowUnknown(boolean shown) {
+ if(shown)
+ mDataUri = mBaseUri.buildUpon().appendPath("all").build();
+ else
+ mDataUri = mBaseUri;
+ getLoaderManager().restartLoader(0, null, this);
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- Uri dataUri = getArguments().getParcelable(ARG_DATA_URI);
- if (dataUri == null) {
+ mShowUnknown = (CheckBox) getActivity().findViewById(R.id.showUnknown);
+ mShowUnknown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ toggleShowUnknown(b);
+ }
+ });
+
+ mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list);
+
+ if (!getArguments().containsKey(ARG_KEYRING_ROW_ID)) {
Log.e(Constants.TAG, "Data missing. Should be Uri of key!");
getActivity().finish();
return;
}
- loadData(dataUri);
+ long rowId = getArguments().getLong(ARG_KEYRING_ROW_ID);
+ mBaseUri = KeychainContract.Certs.buildCertsByKeyRowIdUri(Long.toString(rowId));
+
+ mStickyList.setAreHeadersSticky(true);
+ mStickyList.setDrawingListUnderStickyHeader(false);
+ mStickyList.setFastScrollEnabled(true);
+ mStickyList.setOnItemClickListener(this);
+
+ try {
+ mStickyList.setFastScrollAlwaysVisible(true);
+ } catch (ApiLevelTooLowException e) {
+ }
+
+ 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.
+ mAdapter = new CertListAdapter(getActivity(), null);
+ mStickyList.setAdapter(mAdapter);
+
+ // Prepare the loader. Either re-connect with an existing one,
+ // or start a new one.
+ mDataUri = mBaseUri;
+ getLoaderManager().initLoader(0, null, this);
+
}
- private void loadData(Uri dataUri) {
- if (dataUri.equals(mDataUri)) {
- Log.d(Constants.TAG, "Same URI, no need to load the data again!");
- return;
+ @Override
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ // Now create and return a CursorLoader that will take care of
+ // creating a Cursor for the data being displayed.
+ return new CursorLoader(getActivity(), mDataUri, PROJECTION, null, null, SORT_ORDER);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ // Swap the new cursor in. (The framework will take care of closing the
+ // old cursor once we return.)
+ mAdapter.swapCursor(data);
+
+ mStickyList.setAdapter(mAdapter);
+ }
+
+ /**
+ * On click on item, start key view activity
+ */
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
+ Intent viewIntent = null;
+ viewIntent = new Intent(getActivity(), ViewCertActivity.class);
+ viewIntent.setData(KeychainContract.Certs.buildCertsUri(Long.toString(id)));
+ startActivity(viewIntent);
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {
+ // This is called when the last Cursor provided to onLoadFinished()
+ // above is about to be closed. We need to make sure we are no
+ // longer using it.
+ mAdapter.swapCursor(null);
+ }
+
+ /**
+ * Implements StickyListHeadersAdapter from library
+ */
+ private class CertListAdapter extends CursorAdapter implements StickyListHeadersAdapter {
+ private LayoutInflater mInflater;
+ private int mIndexCertId;
+ private int mIndexUserId, mIndexRank;
+ private int mIndexSignerKeyId, mIndexSignerUserId;
+ private int mIndexVerified;
+
+ public CertListAdapter(Context context, Cursor c) {
+ super(context, c, 0);
+
+ mInflater = LayoutInflater.from(context);
+ initIndex(c);
}
- mDataUri = dataUri;
+ @Override
+ public Cursor swapCursor(Cursor newCursor) {
+ initIndex(newCursor);
- Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
+ return super.swapCursor(newCursor);
+ }
- mActionCertify.setOnClickListener(new View.OnClickListener() {
+ /**
+ * Get column indexes for performance reasons just once in constructor and swapCursor. For a
+ * performance comparison see http://stackoverflow.com/a/17999582
+ *
+ * @param cursor
+ */
+ private void initIndex(Cursor cursor) {
+ if (cursor != null) {
- @Override
- public void onClick(View v) {
- certifyKey(mDataUri);
+ mIndexCertId = cursor.getColumnIndexOrThrow(KeychainContract.Certs._ID);
+ mIndexUserId = cursor.getColumnIndexOrThrow(KeychainContract.UserIds.USER_ID);
+ mIndexRank = cursor.getColumnIndexOrThrow(KeychainContract.UserIds.RANK);
+ mIndexVerified = cursor.getColumnIndexOrThrow(KeychainContract.Certs.VERIFIED);
+ mIndexSignerKeyId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.KEY_ID_CERTIFIER);
+ mIndexSignerUserId = cursor.getColumnIndexOrThrow("signer_uid");
}
- });
+ }
- }
+ /**
+ * Bind cursor data to the item list view
+ * <p/>
+ * NOTE: CursorAdapter already implements the ViewHolder pattern in its getView() method.
+ * Thus no ViewHolder is required here.
+ */
+ @Override
+ public void bindView(View view, Context context, Cursor cursor) {
+
+ // set name and stuff, common to both key types
+ TextView wSignerKeyId = (TextView) view.findViewById(R.id.signerKeyId);
+ TextView wSignerUserId = (TextView) view.findViewById(R.id.signerUserId);
+ TextView wSignStatus = (TextView) view.findViewById(R.id.signStatus);
+
+ String signerKeyId = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexSignerKeyId));
+ String signerUserId = cursor.getString(mIndexSignerUserId);
+ String signStatus = cursor.getInt(mIndexVerified) > 0 ? "ok" : "unknown";
+
+ wSignerUserId.setText(signerUserId);
+ wSignerKeyId.setText(signerKeyId);
+ wSignStatus.setText(signStatus);
+
+ }
+
+ @Override
+ public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ return mInflater.inflate(R.layout.view_key_certs_item, parent, false);
+ }
+
+ /**
+ * Creates a new header view and binds the section headers to it. It uses the ViewHolder
+ * pattern. Most functionality is similar to getView() from Android's CursorAdapter.
+ * <p/>
+ * NOTE: The variables mDataValid and mCursor are available due to the super class
+ * CursorAdapter.
+ */
+ @Override
+ public View getHeaderView(int position, View convertView, ViewGroup parent) {
+ HeaderViewHolder holder;
+ if (convertView == null) {
+ holder = new HeaderViewHolder();
+ convertView = mInflater.inflate(R.layout.view_key_certs_header, parent, false);
+ holder.text = (TextView) convertView.findViewById(R.id.stickylist_header_text);
+ holder.count = (TextView) convertView.findViewById(R.id.certs_num);
+ convertView.setTag(holder);
+ } else {
+ holder = (HeaderViewHolder) convertView.getTag();
+ }
+
+ if (!mDataValid) {
+ // no data available at this point
+ Log.d(Constants.TAG, "getHeaderView: No data available at this point!");
+ return convertView;
+ }
+
+ if (!mCursor.moveToPosition(position)) {
+ throw new IllegalStateException("couldn't move cursor to position " + position);
+ }
+
+ // set header text as first char in user id
+ String userId = mCursor.getString(mIndexUserId);
+ holder.text.setText(userId);
+ holder.count.setVisibility(View.GONE);
+ return convertView;
+ }
+
+ /**
+ * Header IDs should be static, position=1 should always return the same Id that is.
+ */
+ @Override
+ public long getHeaderId(int position) {
+ if (!mDataValid) {
+ // no data available at this point
+ Log.d(Constants.TAG, "getHeaderView: No data available at this point!");
+ return -1;
+ }
+
+ if (!mCursor.moveToPosition(position)) {
+ throw new IllegalStateException("couldn't move cursor to position " + position);
+ }
+
+ // otherwise, return the first character of the name as ID
+ return mCursor.getInt(mIndexRank);
+
+ // sort by the first four characters (should be enough I guess?)
+ // return ByteBuffer.wrap(userId.getBytes()).asLongBuffer().get(0);
+ }
+
+ class HeaderViewHolder {
+ TextView text;
+ TextView count;
+ }
- private void certifyKey(Uri dataUri) {
- Intent signIntent = new Intent(getActivity(), CertifyKeyActivity.class);
- signIntent.setData(dataUri);
- startActivity(signIntent);
}
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java
index 4950126dd..c898a06ea 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java
@@ -42,6 +42,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract;
+import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter;
import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter;
@@ -50,7 +51,7 @@ import org.sufficientlysecure.keychain.util.Log;
import java.util.Date;
-public class ViewKeyMainFragment extends Fragment implements
+public class ViewKeyMainFragment extends Fragment implements
LoaderManager.LoaderCallbacks<Cursor>{
public static final String ARG_DATA_URI = "uri";
@@ -66,6 +67,7 @@ public class ViewKeyMainFragment extends Fragment implements
private TextView mSecretKey;
private BootstrapButton mActionEdit;
private BootstrapButton mActionEncrypt;
+ private BootstrapButton mActionCertify;
private ListView mUserIds;
private ListView mKeys;
@@ -96,6 +98,7 @@ public class ViewKeyMainFragment extends Fragment implements
mKeys = (ListView) view.findViewById(R.id.keys);
mActionEdit = (BootstrapButton) view.findViewById(R.id.action_edit);
mActionEncrypt = (BootstrapButton) view.findViewById(R.id.action_encrypt);
+ mActionCertify = (BootstrapButton) view.findViewById(R.id.action_certify);
return view;
}
@@ -132,6 +135,9 @@ public class ViewKeyMainFragment extends Fragment implements
mSecretKey.setTextColor(getResources().getColor(R.color.emphasis));
mSecretKey.setText(R.string.secret_key_yes);
+ // certify button
+ mActionCertify.setVisibility(View.GONE);
+
// edit button
mActionEdit.setVisibility(View.VISIBLE);
mActionEdit.setOnClickListener(new View.OnClickListener() {
@@ -145,6 +151,18 @@ public class ViewKeyMainFragment extends Fragment implements
} else {
mSecretKey.setTextColor(Color.BLACK);
mSecretKey.setText(getResources().getString(R.string.secret_key_no));
+
+ // certify button
+ mActionCertify.setVisibility(View.VISIBLE);
+ mActionCertify.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View view) {
+ certifyKey(KeychainContract.KeyRings.buildPublicKeyRingsByMasterKeyIdUri(
+ Long.toString(masterKeyId)
+ ));
+ }
+ });
+
+ // edit button
mActionEdit.setVisibility(View.GONE);
}
}
@@ -176,10 +194,10 @@ public class ViewKeyMainFragment extends Fragment implements
static final int KEYRING_INDEX_MASTER_KEY_ID = 1;
static final int KEYRING_INDEX_USER_ID = 2;
- static final String[] USER_IDS_PROJECTION = new String[]{KeychainContract.UserIds._ID, KeychainContract.UserIds.USER_ID,
- KeychainContract.UserIds.RANK,};
+ static final String[] USER_IDS_PROJECTION = new String[]{ KeychainContract.UserIds._ID, KeychainContract.UserIds.USER_ID,
+ KeychainContract.UserIds.RANK, "verified" };
// not the main user id
- static final String USER_IDS_SELECTION = KeychainContract.UserIds.RANK + " > 0 ";
+ static final String USER_IDS_SELECTION = KeychainDatabase.Tables.USER_IDS + "." + KeychainContract.UserIds.RANK + " > 0 ";
static final String USER_IDS_SORT_ORDER = KeychainContract.UserIds.USER_ID + " COLLATE LOCALIZED ASC";
static final String[] KEYS_PROJECTION = new String[]{KeychainContract.Keys._ID, KeychainContract.Keys.KEY_ID,
@@ -342,7 +360,6 @@ public class ViewKeyMainFragment extends Fragment implements
}
}
-
private void encryptToContact(Uri dataUri) {
long keyId = ProviderHelper.getMasterKeyId(getActivity(), dataUri);
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java
index cf8699417..5a991ce11 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java
@@ -32,6 +32,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
private LayoutInflater mInflater;
private int mIndexUserId;
+ private int mVerifiedId;
public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
@@ -57,15 +58,17 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
private void initIndex(Cursor cursor) {
if (cursor != null) {
mIndexUserId = cursor.getColumnIndexOrThrow(UserIds.USER_ID);
+ mVerifiedId = cursor.getColumnIndexOrThrow("verified");
}
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
String userIdStr = cursor.getString(mIndexUserId);
+ int verified = cursor.getInt(mVerifiedId);
TextView userId = (TextView) view.findViewById(R.id.userId);
- userId.setText(userIdStr);
+ userId.setText(userIdStr + (verified > 0 ? " (ok)" : "(nope)"));
}
@Override
diff --git a/OpenPGP-Keychain/src/main/res/layout/view_cert_activity.xml b/OpenPGP-Keychain/src/main/res/layout/view_cert_activity.xml
new file mode 100644
index 000000000..c21362beb
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/layout/view_cert_activity.xml
@@ -0,0 +1,207 @@
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:descendantFocusability="beforeDescendants"
+ android:orientation="vertical"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp">
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="14dp"
+ android:text="@string/section_cert" />
+
+ <TableLayout
+ android:layout_width="wrap_content"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:stretchColumns="1">
+
+ <TableRow>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="@string/label_key_id" />
+
+ <TextView
+ android:id="@+id/signee_key"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="@string/label_user_id" />
+
+ <TextView
+ android:id="@+id/signee_uid"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="@string/label_subkey_rank" />
+
+ <TextView
+ android:id="@+id/subkey_rank"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="@string/label_algorithm" />
+
+ <TextView
+ android:id="@+id/algorithm"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="Type" />
+
+ <TextView
+ android:id="@+id/signature_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="Creation" />
+
+ <TextView
+ android:id="@+id/creation"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:paddingRight="10dip"
+ android:text="Expires" />
+
+ <TextView
+ android:id="@+id/expiry"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip" />
+ </TableRow>
+
+ </TableLayout>
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="14dp"
+ android:text="@string/section_signer_id" />
+
+ <TableLayout
+ android:layout_width="wrap_content"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:stretchColumns="1">
+
+ <TableRow>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingRight="10dip"
+ android:text="@string/label_key_id" />
+
+ <TextView
+ android:id="@+id/signer_key_id"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip"
+ android:text=""
+ android:typeface="monospace" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/label_algorithm"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingRight="10dip"
+ android:text="@string/label_email" />
+
+ <TextView
+ android:id="@+id/signer_uid"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip"
+ android:text="" />
+ </TableRow>
+
+ </TableLayout>
+
+ </LinearLayout>
+
+</ScrollView>
diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml
index 299471c66..60f071bd4 100644
--- a/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml
+++ b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml
@@ -1,38 +1,48 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:fillViewport="true">
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingLeft="16dp"
- android:paddingRight="16dp">
+ android:orientation="vertical">
- <TextView
+ <view
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ class="se.emilsjolander.stickylistheaders.StickyListHeadersListView"
+ android:id="@+id/list"
+ android:layout_alignParentTop="true"
+ android:layout_above="@+id/showUnknown"
+ android:paddingRight="32dp"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:paddingLeft="16dp" />
+
+ <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:layout_marginTop="14dp"
- android:text="Display of existing certifications is a planned feature for a later release of OpenPGP Keychain. Stay tuned for updates!" />
+ android:text="@string/show_unknown_signatures"
+ android:id="@+id/showUnknown"
+ android:enabled="true"
+ android:layout_alignParentBottom="true"
+ android:layout_alignEnd="@+id/list"
+ android:singleLine="false"
+ android:layout_alignParentRight="true"
+ android:layout_marginRight="16dp" />
<TextView
- style="@style/SectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:layout_marginTop="14dp"
- android:text="@string/section_actions" />
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/empty_certs"
+ android:id="@+id/empty"
+ android:visibility="gone"
+ android:layout_centerInParent="true"
+ android:paddingBottom="32dp" />
- <com.beardedhen.androidbootstrap.BootstrapButton
- android:id="@+id/action_certify"
- android:layout_width="match_parent"
- android:layout_height="60dp"
- android:padding="4dp"
- android:text="@string/key_view_action_certify"
- bootstrapbutton:bb_icon_left="fa-pencil"
- bootstrapbutton:bb_type="info" />
- </LinearLayout>
+ </RelativeLayout>
</ScrollView> \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_certs_header.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_header.xml
new file mode 100644
index 000000000..de481c1cc
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_header.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <org.sufficientlysecure.keychain.ui.widget.UnderlineTextView
+ android:id="@+id/stickylist_header_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start|left"
+ android:padding="8dp"
+ android:textColor="@color/emphasis"
+ android:textSize="17sp"
+ android:textStyle="bold"
+ android:text="header text" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="certification count"
+ android:id="@+id/certs_num"
+ android:layout_centerVertical="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
+ android:layout_marginRight="10px"
+ android:visibility="visible"
+ android:textColor="@android:color/darker_gray" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_certs_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_item.xml
new file mode 100644
index 000000000..de7570818
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_item.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical"
+ android:paddingLeft="8dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:singleLine="true"
+ android:descendantFocusability="blocksDescendants"
+ android:focusable="false">
+
+ <TextView
+ android:id="@+id/signerKeyId"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="signer key id"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true" />
+
+ <TextView
+ android:id="@+id/signerUserId"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="&lt;user@example.com>"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:layout_below="@+id/signerKeyId"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true" />
+
+ <TextView
+ android:id="@+id/signStatus"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="status"
+ android:visibility="visible"
+ android:layout_above="@+id/signerUserId"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
+ android:layout_marginRight="10dp" />
+
+</RelativeLayout>
diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml
index 3c8a4270b..6ef3f3072 100644
--- a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml
+++ b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml
@@ -251,6 +251,17 @@
bootstrapbutton:bb_icon_left="fa-lock"
bootstrapbutton:bb_type="info" />
+
+ <com.beardedhen.androidbootstrap.BootstrapButton
+ android:id="@+id/action_certify"
+ android:layout_width="match_parent"
+ android:layout_height="60dp"
+ android:padding="4dp"
+ android:layout_marginBottom="10dp"
+ android:text="@string/key_view_action_certify"
+ bootstrapbutton:bb_icon_left="fa-pencil"
+ bootstrapbutton:bb_type="info" />
+
</LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/main/res/menu/view_cert.xml b/OpenPGP-Keychain/src/main/res/menu/view_cert.xml
new file mode 100644
index 000000000..dbdb2bfbe
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/menu/view_cert.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/menu_view_cert_verify"
+ app:showAsAction="never"
+ android:title="Verify signature" />
+ <item
+ android:id="@+id/menu_view_cert_view_signer"
+ app:showAsAction="never"
+ android:title="View signing key" />
+</menu> \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml
index ca54db266..d2e02efcb 100644
--- a/OpenPGP-Keychain/src/main/res/values/strings.xml
+++ b/OpenPGP-Keychain/src/main/res/values/strings.xml
@@ -463,5 +463,16 @@
<string name="label_secret_key">Secret Key</string>
<string name="secret_key_yes">available</string>
<string name="secret_key_no">unavailable</string>
+ <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>
+ <string name="empty_certs">No certificates for this key</string>
</resources>