aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-09-18 22:05:27 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-09-18 22:05:27 +0200
commita454bfd7012993fe85b7d0bc57fbe8fea94b45e8 (patch)
tree7891e5e30ff9e53d98ef8809e20bb4d171897c7b
parenta77c217b82a567a71ff22a419772fce861c9df95 (diff)
downloadopen-keychain-a454bfd7012993fe85b7d0bc57fbe8fea94b45e8.tar.gz
open-keychain-a454bfd7012993fe85b7d0bc57fbe8fea94b45e8.tar.bz2
open-keychain-a454bfd7012993fe85b7d0bc57fbe8fea94b45e8.zip
Use key icons in import, prettify items
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java1
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java16
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java23
-rw-r--r--OpenKeychain/src/main/res/layout/import_keys_list_entry.xml54
6 files changed, 60 insertions, 40 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
index b49442ec0..ff2a08c8e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
@@ -276,6 +276,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
mKeyIdHex = KeyFormattingUtils.convertKeyIdToHex(mKeyId);
mRevoked = key.isRevoked();
+ mExpired = key.isExpired();
mFingerprintHex = KeyFormattingUtils.convertFingerprintToHex(key.getFingerprint());
mBitStrength = key.getBitStrength();
mCurveOid = key.getCurveOid();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
index 2c26c2da0..2e4620813 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
@@ -31,6 +31,7 @@ import org.spongycastle.openpgp.PGPSignatureGenerator;
import org.spongycastle.openpgp.operator.jcajce.JcePBEKeyEncryptionMethodGenerator;
import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
import org.spongycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder;
+import org.spongycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
@@ -569,6 +570,7 @@ public class PgpSignEncrypt {
SignEncryptResult result =
new SignEncryptResult(SignEncryptResult.RESULT_PENDING_NFC, log);
result.setNfcData(e.hashToSign, e.hashAlgo, e.creationTimestamp);
+ Log.d(Constants.TAG, "e.hashToSign"+ Hex.toHexString(e.hashToSign));
return result;
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index 31427cce2..55354cdec 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -30,6 +30,7 @@ import org.openintents.openpgp.OpenPgpMetadata;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
+import org.spongycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.nfc.NfcActivity;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
@@ -244,10 +245,17 @@ public class OpenPgpService extends RemoteService {
}
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
+ if (nfcSignedHash != null) {
+ Log.d(Constants.TAG, "nfcSignedHash:" + Hex.toHexString(nfcSignedHash));
+ } else {
+ Log.d(Constants.TAG, "nfcSignedHash: null");
+ }
+
// carefully: only set if timestamp exists
Date nfcCreationDate = null;
- long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
- if (nfcCreationTimestamp != 0) {
+ long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, -1);
+ Log.d(Constants.TAG, "nfcCreationTimestamp: " + nfcCreationTimestamp);
+ if (nfcCreationTimestamp != -1) {
nfcCreationDate = new Date(nfcCreationTimestamp);
}
@@ -406,8 +414,8 @@ public class OpenPgpService extends RemoteService {
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
// carefully: only set if timestamp exists
Date nfcCreationDate = null;
- long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
- if (nfcCreationTimestamp != 0) {
+ long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, -1);
+ if (nfcCreationTimestamp != -1) {
nfcCreationDate = new Date(nfcCreationTimestamp);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java
index 167404b36..84eb29a62 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java
@@ -44,8 +44,8 @@ public class SignEncryptResult extends OperationResult {
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
}
- public void setNfcData(byte[] sessionKey, int nfcAlgo, Date nfcTimestamp) {
- mNfcHash = sessionKey;
+ public void setNfcData(byte[] nfcHash, int nfcAlgo, Date nfcTimestamp) {
+ mNfcHash = nfcHash;
mNfcAlgo = nfcAlgo;
mNfcTimestamp = nfcTimestamp;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java
index 5abbdcc05..1c929e508 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java
@@ -21,12 +21,14 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
+import android.media.Image;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -34,6 +36,7 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.ui.util.Highlighter;
+import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import java.util.ArrayList;
import java.util.Iterator;
@@ -51,7 +54,8 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
public TextView keyId;
public TextView fingerprint;
public TextView algorithm;
- public TextView status;
+ public ImageView status;
+ public View userIdsDivider;
public LinearLayout userIdsList;
public CheckBox checkBox;
}
@@ -114,7 +118,8 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
holder.keyId = (TextView) convertView.findViewById(R.id.subkey_item_key_id);
holder.fingerprint = (TextView) convertView.findViewById(R.id.view_key_fingerprint);
holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm);
- holder.status = (TextView) convertView.findViewById(R.id.status);
+ holder.status = (ImageView) convertView.findViewById(R.id.status);
+ holder.userIdsDivider = convertView.findViewById(R.id.user_ids_divider);
holder.userIdsList = (LinearLayout) convertView.findViewById(R.id.user_ids_list);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.selected);
convertView.setTag(holder);
@@ -159,20 +164,30 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
holder.algorithm.setText(entry.getAlgorithm());
holder.algorithm.setVisibility(View.VISIBLE);
} else {
- holder.algorithm.setVisibility(View.INVISIBLE);
+ holder.algorithm.setVisibility(View.GONE);
}
if (entry.isRevoked()) {
holder.status.setVisibility(View.VISIBLE);
- holder.status.setText(R.string.revoked);
+ KeyFormattingUtils.setStatusImage(getContext(), holder.status, KeyFormattingUtils.STATE_REVOKED);
+ // no more space for algorithm display
+ holder.algorithm.setVisibility(View.GONE);
+ } else if (entry.isExpired()) {
+ holder.status.setVisibility(View.VISIBLE);
+ KeyFormattingUtils.setStatusImage(getContext(), holder.status, KeyFormattingUtils.STATE_EXPIRED);
+ // no more space for algorithm display
+ holder.algorithm.setVisibility(View.GONE);
} else {
holder.status.setVisibility(View.GONE);
+ holder.algorithm.setVisibility(View.VISIBLE);
}
if (entry.getUserIds().size() == 1) {
holder.userIdsList.setVisibility(View.GONE);
+ holder.userIdsDivider.setVisibility(View.GONE);
} else {
holder.userIdsList.setVisibility(View.VISIBLE);
+ holder.userIdsDivider.setVisibility(View.VISIBLE);
// destroyLoader view from holder
holder.userIdsList.removeAllViews();
diff --git a/OpenKeychain/src/main/res/layout/import_keys_list_entry.xml b/OpenKeychain/src/main/res/layout/import_keys_list_entry.xml
index 74de77172..ddf3d1bb4 100644
--- a/OpenKeychain/src/main/res/layout/import_keys_list_entry.xml
+++ b/OpenKeychain/src/main/res/layout/import_keys_list_entry.xml
@@ -1,20 +1,5 @@
-<!--
- Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
--->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
@@ -67,6 +52,14 @@
android:text="alice@example.com"
android:textAppearance="?android:attr/textAppearanceSmall" />
+ <TextView
+ android:id="@+id/subkey_item_key_id"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="0xBBBBBBBBBBBBBBBB"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:typeface="monospace" />
+
</LinearLayout>
<LinearLayout
@@ -76,24 +69,32 @@
android:orientation="vertical"
android:paddingLeft="4dp">
- <TextView
+ <ImageView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="status"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#e00" />
+ android:layout_gravity="center"
+ android:src="@drawable/status_signature_revoked_cutout"
+ android:padding="16dp" />
<TextView
android:id="@+id/algorithm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RSA"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_gravity="right" />
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
</LinearLayout>
</LinearLayout>
+ <View
+ android:id="@+id/user_ids_divider"
+ android:layout_width="match_parent"
+ android:layout_height="1dip"
+ android:gravity="right"
+ android:layout_marginBottom="2dp"
+ android:layout_marginTop="2dp"
+ android:background="?android:attr/listDivider" />
<LinearLayout
android:id="@+id/user_ids_list"
@@ -102,20 +103,13 @@
android:orientation="vertical" />
<TextView
- android:id="@+id/subkey_item_key_id"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="0xBBBBBBBBBBBBBBBB"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:typeface="monospace" />
-
- <TextView
android:id="@+id/view_key_fingerprint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0000 0000 0000 0000 0000\n0000 0000 0000 0000 0000"
android:typeface="monospace"
android:textAppearance="?android:attr/textAppearanceSmall" />
+
</LinearLayout>
</LinearLayout>