mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
Use key icons in import, prettify items
This commit is contained in:
parent
a77c217b82
commit
a454bfd701
@ -276,6 +276,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
mKeyIdHex = KeyFormattingUtils.convertKeyIdToHex(mKeyId);
|
mKeyIdHex = KeyFormattingUtils.convertKeyIdToHex(mKeyId);
|
||||||
|
|
||||||
mRevoked = key.isRevoked();
|
mRevoked = key.isRevoked();
|
||||||
|
mExpired = key.isExpired();
|
||||||
mFingerprintHex = KeyFormattingUtils.convertFingerprintToHex(key.getFingerprint());
|
mFingerprintHex = KeyFormattingUtils.convertFingerprintToHex(key.getFingerprint());
|
||||||
mBitStrength = key.getBitStrength();
|
mBitStrength = key.getBitStrength();
|
||||||
mCurveOid = key.getCurveOid();
|
mCurveOid = key.getCurveOid();
|
||||||
|
@ -31,6 +31,7 @@ import org.spongycastle.openpgp.PGPSignatureGenerator;
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBEKeyEncryptionMethodGenerator;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBEKeyEncryptionMethodGenerator;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder;
|
||||||
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
@ -569,6 +570,7 @@ public class PgpSignEncrypt {
|
|||||||
SignEncryptResult result =
|
SignEncryptResult result =
|
||||||
new SignEncryptResult(SignEncryptResult.RESULT_PENDING_NFC, log);
|
new SignEncryptResult(SignEncryptResult.RESULT_PENDING_NFC, log);
|
||||||
result.setNfcData(e.hashToSign, e.hashAlgo, e.creationTimestamp);
|
result.setNfcData(e.hashToSign, e.hashAlgo, e.creationTimestamp);
|
||||||
|
Log.d(Constants.TAG, "e.hashToSign"+ Hex.toHexString(e.hashToSign));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.openintents.openpgp.OpenPgpMetadata;
|
|||||||
import org.openintents.openpgp.OpenPgpError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.sufficientlysecure.keychain.nfc.NfcActivity;
|
import org.sufficientlysecure.keychain.nfc.NfcActivity;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
||||||
@ -244,10 +245,17 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
|
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
|
// carefully: only set if timestamp exists
|
||||||
Date nfcCreationDate = null;
|
Date nfcCreationDate = null;
|
||||||
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
|
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, -1);
|
||||||
if (nfcCreationTimestamp != 0) {
|
Log.d(Constants.TAG, "nfcCreationTimestamp: " + nfcCreationTimestamp);
|
||||||
|
if (nfcCreationTimestamp != -1) {
|
||||||
nfcCreationDate = new Date(nfcCreationTimestamp);
|
nfcCreationDate = new Date(nfcCreationTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,8 +414,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
|
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
|
||||||
// carefully: only set if timestamp exists
|
// carefully: only set if timestamp exists
|
||||||
Date nfcCreationDate = null;
|
Date nfcCreationDate = null;
|
||||||
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
|
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, -1);
|
||||||
if (nfcCreationTimestamp != 0) {
|
if (nfcCreationTimestamp != -1) {
|
||||||
nfcCreationDate = new Date(nfcCreationTimestamp);
|
nfcCreationDate = new Date(nfcCreationTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ public class SignEncryptResult extends OperationResult {
|
|||||||
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
|
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNfcData(byte[] sessionKey, int nfcAlgo, Date nfcTimestamp) {
|
public void setNfcData(byte[] nfcHash, int nfcAlgo, Date nfcTimestamp) {
|
||||||
mNfcHash = sessionKey;
|
mNfcHash = nfcHash;
|
||||||
mNfcAlgo = nfcAlgo;
|
mNfcAlgo = nfcAlgo;
|
||||||
mNfcTimestamp = nfcTimestamp;
|
mNfcTimestamp = nfcTimestamp;
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,14 @@ import android.annotation.TargetApi;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.media.Image;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -51,7 +54,8 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
public TextView keyId;
|
public TextView keyId;
|
||||||
public TextView fingerprint;
|
public TextView fingerprint;
|
||||||
public TextView algorithm;
|
public TextView algorithm;
|
||||||
public TextView status;
|
public ImageView status;
|
||||||
|
public View userIdsDivider;
|
||||||
public LinearLayout userIdsList;
|
public LinearLayout userIdsList;
|
||||||
public CheckBox checkBox;
|
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.keyId = (TextView) convertView.findViewById(R.id.subkey_item_key_id);
|
||||||
holder.fingerprint = (TextView) convertView.findViewById(R.id.view_key_fingerprint);
|
holder.fingerprint = (TextView) convertView.findViewById(R.id.view_key_fingerprint);
|
||||||
holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
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.userIdsList = (LinearLayout) convertView.findViewById(R.id.user_ids_list);
|
||||||
holder.checkBox = (CheckBox) convertView.findViewById(R.id.selected);
|
holder.checkBox = (CheckBox) convertView.findViewById(R.id.selected);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
@ -159,20 +164,30 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
holder.algorithm.setText(entry.getAlgorithm());
|
holder.algorithm.setText(entry.getAlgorithm());
|
||||||
holder.algorithm.setVisibility(View.VISIBLE);
|
holder.algorithm.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.algorithm.setVisibility(View.INVISIBLE);
|
holder.algorithm.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.isRevoked()) {
|
if (entry.isRevoked()) {
|
||||||
holder.status.setVisibility(View.VISIBLE);
|
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 {
|
} else {
|
||||||
holder.status.setVisibility(View.GONE);
|
holder.status.setVisibility(View.GONE);
|
||||||
|
holder.algorithm.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getUserIds().size() == 1) {
|
if (entry.getUserIds().size() == 1) {
|
||||||
holder.userIdsList.setVisibility(View.GONE);
|
holder.userIdsList.setVisibility(View.GONE);
|
||||||
|
holder.userIdsDivider.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
holder.userIdsList.setVisibility(View.VISIBLE);
|
holder.userIdsList.setVisibility(View.VISIBLE);
|
||||||
|
holder.userIdsDivider.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
// destroyLoader view from holder
|
// destroyLoader view from holder
|
||||||
holder.userIdsList.removeAllViews();
|
holder.userIdsList.removeAllViews();
|
||||||
|
@ -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"
|
<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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
@ -67,6 +52,14 @@
|
|||||||
android:text="alice@example.com"
|
android:text="alice@example.com"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
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>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -76,24 +69,32 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="4dp">
|
android:paddingLeft="4dp">
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/status"
|
android:id="@+id/status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="status"
|
android:layout_gravity="center"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:src="@drawable/status_signature_revoked_cutout"
|
||||||
android:textColor="#e00" />
|
android:padding="16dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/algorithm"
|
android:id="@+id/algorithm"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="RSA"
|
android:text="RSA"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
android:layout_gravity="right" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</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
|
<LinearLayout
|
||||||
android:id="@+id/user_ids_list"
|
android:id="@+id/user_ids_list"
|
||||||
@ -101,14 +102,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" />
|
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
|
<TextView
|
||||||
android:id="@+id/view_key_fingerprint"
|
android:id="@+id/view_key_fingerprint"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -116,6 +109,7 @@
|
|||||||
android:text="0000 0000 0000 0000 0000\n0000 0000 0000 0000 0000"
|
android:text="0000 0000 0000 0000 0000\n0000 0000 0000 0000 0000"
|
||||||
android:typeface="monospace"
|
android:typeface="monospace"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user