aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-12-30 16:32:11 -0800
committerDominik Schürmann <dominik@dominikschuermann.de>2013-12-30 16:32:11 -0800
commit9ab0e6082ab7932a987cdc787bd81cb2b83f0207 (patch)
tree018396308101f2b306c535fc7ada0b68049ba096 /OpenPGP-Keychain
parent536c4db48f12287eaf1875e2d208c0ad07e31ee6 (diff)
parentf265cd4d68a4bb398467da1a8d19b6ca0b125602 (diff)
downloadopen-keychain-9ab0e6082ab7932a987cdc787bd81cb2b83f0207.tar.gz
open-keychain-9ab0e6082ab7932a987cdc787bd81cb2b83f0207.tar.bz2
open-keychain-9ab0e6082ab7932a987cdc787bd81cb2b83f0207.zip
Merge pull request #165 from kalkin/key-details
Key details
Diffstat (limited to 'OpenPGP-Keychain')
-rw-r--r--OpenPGP-Keychain/AndroidManifest.xml10
-rw-r--r--OpenPGP-Keychain/res/layout/key_view.xml110
-rw-r--r--OpenPGP-Keychain/res/values/strings.xml7
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java11
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyDetailsActivity.java90
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java15
6 files changed, 237 insertions, 6 deletions
diff --git a/OpenPGP-Keychain/AndroidManifest.xml b/OpenPGP-Keychain/AndroidManifest.xml
index 8027715af..4b843bc01 100644
--- a/OpenPGP-Keychain/AndroidManifest.xml
+++ b/OpenPGP-Keychain/AndroidManifest.xml
@@ -123,6 +123,16 @@
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="stateHidden" />
<activity
+ android:name=".ui.KeyDetailsActivity"
+ android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
+ android:label="@string/title_key_details"
+ android:parentActivityName=".ui.KeyListPublicActivity"
+ android:uiOptions="splitActionBarWhenNarrow" >
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".ui.KeyListPublicActivity" />
+ </activity>
+ <activity
android:name=".ui.SelectPublicKeyActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_select_recipients"
diff --git a/OpenPGP-Keychain/res/layout/key_view.xml b/OpenPGP-Keychain/res/layout/key_view.xml
new file mode 100644
index 000000000..5649fe338
--- /dev/null
+++ b/OpenPGP-Keychain/res/layout/key_view.xml
@@ -0,0 +1,110 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="?android:attr/scrollbarSize"
+ android:orientation="vertical"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp" >
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/section_master_key" />
+
+ <TableLayout
+ android:layout_width="wrap_content"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:stretchColumns="1" >
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/label_keyId"
+ 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/fingerprint"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip"
+ android:text="0000 0000"
+ 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_algorithm" />
+
+ <TextView
+ android:id="@+id/algorithm"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingRight="5dip"
+ android:text="Name" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/label_creation"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingRight="10dip"
+ android:text="@string/label_creation" />
+
+ <TextView
+ android:id="@+id/creation"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/label_expiry"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingRight="10dip"
+ android:text="@string/label_expiry" />
+
+ <TextView
+ android:id="@+id/expiry"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ </TableRow>
+ </TableLayout>
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/section_user_ids" />
+
+ <ListView android:id="@+id/user_ids"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"></ListView>
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/section_keys" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml
index 807daaeb4..c3736815c 100644
--- a/OpenPGP-Keychain/res/values/strings.xml
+++ b/OpenPGP-Keychain/res/values/strings.xml
@@ -44,6 +44,7 @@
<string name="title_send_key">Export to Key Server</string>
<string name="title_unknown_signature_key">Unknown Signature Key</string>
<string name="title_sign_key">Sign Key</string>
+ <string name="title_key_details">Key Details</string>
<string name="title_help">Help</string>
<string name="title_share_by_nfc">Share key with NFC</string>
@@ -53,6 +54,7 @@
<string name="section_general">General</string>
<string name="section_defaults">Defaults</string>
<string name="section_advanced">Advanced</string>
+ <string name="section_master_key">Master Key</string>
<!-- button -->
<string name="btn_sign_to_clipboard">Sign (Clipboard)</string>
@@ -142,6 +144,8 @@
<string name="n_key_servers">%s key server(s)</string>
<string name="fingerprint">Fingerprint:</string>
<string name="secret_key">Secret Key:</string>
+ <string name="notValid">not valid</string>
+ <string name="secretKeyring">Secret Keyring</string>
<!-- choice -->
<string name="choice_none">None</string>
@@ -343,5 +347,4 @@
<!-- Share -->
<string name="share_qr_code_dialog_start">Go through all QR Codes using \'Next\', and scan them one by one.</string>
<string name="share_qr_code_dialog_progress">QR Code %1$d of %2$d</string>
-
-</resources> \ No newline at end of file
+</resources>
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
index e2d89bfab..5a3d332c4 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
@@ -40,6 +40,17 @@ import android.content.Context;
public class PgpKeyHelper {
+ /**
+ * Returns the last 9 chars of a fingerprint
+ *
+ * @param fingerprint
+ * String containing short or long fingerprint
+ * @return
+ */
+ public static String shortifyFingerprint(String fingerprint) {
+ return fingerprint.substring(41);
+ }
+
public static Date getCreationDate(PGPPublicKey key) {
return key.getCreationTime();
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyDetailsActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyDetailsActivity.java
new file mode 100644
index 000000000..652b8a89b
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyDetailsActivity.java
@@ -0,0 +1,90 @@
+package org.sufficientlysecure.keychain.ui;
+
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.spongycastle.openpgp.PGPPublicKey;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
+import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
+import org.sufficientlysecure.keychain.provider.ProviderHelper;
+import org.sufficientlysecure.keychain.util.Log;
+
+import android.os.Bundle;
+import android.text.format.DateFormat;
+import android.widget.TextView;
+
+import com.actionbarsherlock.app.SherlockActivity;
+
+public class KeyDetailsActivity extends SherlockActivity {
+
+ private PGPPublicKey publicKey;
+ private TextView mAlgorithm;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Bundle extras = getIntent().getExtras();
+ setContentView(R.layout.key_view);
+ if (extras == null) {
+ return;
+ }
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setHomeButtonEnabled(true);
+
+ long key = extras.getLong("key");
+
+ KeyRings.buildPublicKeyRingsByMasterKeyIdUri(key + "");
+ String[] projection = new String[]{""};
+
+ this.publicKey = ProviderHelper.getPGPPublicKeyByKeyId(
+ getApplicationContext(), key);
+
+ TextView fingerprint = (TextView) this.findViewById(R.id.fingerprint);
+ fingerprint.setText(PgpKeyHelper.shortifyFingerprint(PgpKeyHelper.getFingerPrint(getApplicationContext(), key)));
+ String[] mainUserId = splitUserId("");
+
+ TextView expiry = (TextView) this.findViewById(R.id.expiry);
+ Date expiryDate = PgpKeyHelper.getExpiryDate(publicKey);
+ if (expiryDate == null) {
+ expiry.setText("");
+ } else {
+ expiry.setText(DateFormat.getDateFormat(getApplicationContext())
+ .format(expiryDate));
+ }
+
+ TextView creation = (TextView) this.findViewById(R.id.creation);
+ creation.setText(DateFormat.getDateFormat(getApplicationContext())
+ .format(PgpKeyHelper.getCreationDate(publicKey)));
+ mAlgorithm = (TextView) this.findViewById(R.id.algorithm);
+ mAlgorithm.setText(PgpKeyHelper.getAlgorithmInfo(publicKey));
+
+ }
+
+ private String[] splitUserId(String userId) {
+
+ String[] result = new String[]{"", "", ""};
+ Log.v("UserID", userId);
+
+ Pattern withComment = Pattern.compile("^(.*) [(](.*)[)] <(.*)>$");
+ Matcher matcher = withComment.matcher(userId);
+ if (matcher.matches()) {
+ result[0] = matcher.group(1);
+ result[1] = matcher.group(2);
+ result[2] = matcher.group(3);
+ return result;
+ }
+
+ Pattern withoutComment = Pattern.compile("^(.*) <(.*)>$");
+ matcher = withoutComment.matcher(userId);
+ if (matcher.matches()) {
+ result[0] = matcher.group(1);
+ result[1] = matcher.group(2);
+ return result;
+ }
+ return result;
+ }
+}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java
index 0fdcea809..790ec5ccf 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java
@@ -73,9 +73,10 @@ public class KeyListPublicFragment extends KeyListFragment implements
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
- menu.add(0, Id.menu.update, 1, R.string.menu_update_key);
- menu.add(0, Id.menu.signKey, 2, R.string.menu_sign_key);
- menu.add(0, Id.menu.exportToServer, 3, R.string.menu_export_key_to_server);
+ menu.add(0, 23, 1, R.string.title_key_details); // :TODO: Fix magic number
+ menu.add(0, Id.menu.update, 2, R.string.menu_update_key);
+ menu.add(0, Id.menu.signKey, 3, R.string.menu_sign_key);
+ menu.add(0, Id.menu.exportToServer, 4, R.string.menu_export_key_to_server);
menu.add(0, Id.menu.share, 6, R.string.menu_share);
menu.add(0, Id.menu.share_qr_code, 7, R.string.menu_share_qr_code);
menu.add(0, Id.menu.share_nfc, 8, R.string.menu_share_nfc);
@@ -112,7 +113,13 @@ public class KeyListPublicFragment extends KeyListFragment implements
startActivityForResult(queryIntent, Id.request.look_up_key_id);
return true;
-
+ case 23:
+
+ Intent detailsIntent = new Intent(mKeyListActivity, KeyDetailsActivity.class);
+ detailsIntent.putExtra("key", ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId));
+ startActivity(detailsIntent);
+ return true;
+
case Id.menu.exportToServer:
Intent uploadIntent = new Intent(mKeyListActivity, KeyServerUploadActivity.class);
uploadIntent.setAction(KeyServerUploadActivity.ACTION_EXPORT_KEY_TO_SERVER);