From 69865a6d574e2a81b6ba4fbd11254d90629c14aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 2 Mar 2015 15:44:34 +0100 Subject: Use index constants in ContactHelper --- .../keychain/util/ContactHelper.java | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'OpenKeychain/src/main') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java index 60bc846b2..3cf201ed7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java @@ -57,10 +57,20 @@ public class ContactHelper { KeychainContract.KeyRings.MASTER_KEY_ID, KeychainContract.KeyRings.EXPIRY, KeychainContract.KeyRings.IS_REVOKED}; + + public static final int INDEX_USER_ID = 0; + public static final int INDEX_FINGERPRINT = 1; + public static final int INDEX_KEY_ID = 2; + public static final int INDEX_MASTER_KEY_ID = 3; + public static final int INDEX_EXPIRY = 4; + public static final int INDEX_IS_REVOKED = 5; + public static final String[] USER_IDS_PROJECTION = new String[]{ UserPackets.USER_ID }; + public static final int INDEX_USER_IDS_USER_ID = 0; + public static final String NON_REVOKED_SELECTION = UserPackets.IS_REVOKED + "=0"; public static final String[] ID_PROJECTION = new String[]{ContactsContract.RawContacts._ID}; @@ -301,23 +311,26 @@ public class ContactHelper { null, null, null); if (cursor != null) { while (cursor.moveToNext()) { - String[] primaryUserId = KeyRing.splitUserId(cursor.getString(0)); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(cursor.getBlob(1)); + String[] primaryUserId = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID)); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(cursor.getBlob(INDEX_FINGERPRINT)); contactFingerprints.remove(fingerprint); - String keyIdShort = KeyFormattingUtils.convertKeyIdToHexShort(cursor.getLong(2)); - long masterKeyId = cursor.getLong(3); - boolean isExpired = !cursor.isNull(4) && new Date(cursor.getLong(4) * 1000).before(new Date()); - boolean isRevoked = cursor.getInt(5) > 0; + String keyIdShort = KeyFormattingUtils.convertKeyIdToHexShort(cursor.getLong(INDEX_KEY_ID)); + long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID); + boolean isExpired = !cursor.isNull(INDEX_EXPIRY) + && new Date(cursor.getLong(INDEX_EXPIRY) * 1000).before(new Date()); + boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; int rawContactId = findRawContactId(resolver, fingerprint); ArrayList ops = new ArrayList<>(); + Log.d(Constants.TAG, "raw contact id: "+rawContactId); + // Do not store expired or revoked keys in contact db - and remove them if they already exist if (isExpired || isRevoked) { if (rawContactId != -1) { resolver.delete(ContactsContract.RawContacts.CONTENT_URI, ID_SELECTION, new String[]{Integer.toString(rawContactId)}); } - } else { + } else if (primaryUserId[0] != null) { // Create a new rawcontact with corresponding key if it does not exist yet if (rawContactId == -1) { -- cgit v1.2.3 From 9514719719908f13ca730ca7ba89f2d91a49eb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 2 Mar 2015 16:29:40 +0100 Subject: Re-add black color --- OpenKeychain/src/main/res/values/colors.xml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenKeychain/src/main') diff --git a/OpenKeychain/src/main/res/values/colors.xml b/OpenKeychain/src/main/res/values/colors.xml index c49e06b4b..8c5358fd0 100644 --- a/OpenKeychain/src/main/res/values/colors.xml +++ b/OpenKeychain/src/main/res/values/colors.xml @@ -13,6 +13,8 @@ + #000000 + #C8E6C9 @color/accent #1976D2 -- cgit v1.2.3 From dae0873f5eabadc83b4eab3dfbbc2fd0c9336974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 2 Mar 2015 17:39:30 +0100 Subject: Search string simplified --- OpenKeychain/src/main/res/values/strings.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenKeychain/src/main') diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 2d599e984..ca6ce1f7d 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -359,8 +359,7 @@ "consolidate: reimporting…" - "Name/Email/Key ID…" - "Name/Email/Proof/Key…" + "Search via Name, Email…" "512" -- cgit v1.2.3