aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-03-14 14:05:31 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2015-03-14 14:05:31 +0100
commitcd7f63122193cd9b3c62169381b4d8cef4a88bd2 (patch)
treeb5b7d6ddb0ed4da39eb1bae85d60136c4519465b /OpenKeychain/src/main/java/org/sufficientlysecure
parent23290b90138e1bb458e9d4ed9188716f148483e2 (diff)
downloadopen-keychain-cd7f63122193cd9b3c62169381b4d8cef4a88bd2.tar.gz
open-keychain-cd7f63122193cd9b3c62169381b4d8cef4a88bd2.tar.bz2
open-keychain-cd7f63122193cd9b3c62169381b4d8cef4a88bd2.zip
Show key name instead of key id in contacts, cleanup
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java27
1 files changed, 7 insertions, 20 deletions
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 c07d7a36b..d5078da3c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java
@@ -426,25 +426,14 @@ public class ContactHelper {
*/
public static void writeKeysToContacts(Context context) {
ContentResolver resolver = context.getContentResolver();
- Set<Long> deletedKeys = getRawContactMasterKeyIds(resolver);
-
- writeKeysToMainProfileContact(context);
if (Constants.DEBUG_SYNC_REMOVE_CONTACTS) {
debugDeleteRawContacts(resolver);
}
-// ContentProviderClient client = resolver.acquireContentProviderClient(ContactsContract.AUTHORITY_URI);
-// ContentValues values = new ContentValues();
-// Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
-// values.put(ContactsContract.Settings.ACCOUNT_NAME, account.name);
-// values.put(ContactsContract.Settings.ACCOUNT_TYPE, account.type);
-// values.put(ContactsContract.Settings.UNGROUPED_VISIBLE, true);
-// try {
-// client.insert(ContactsContract.Settings.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build(), values);
-// } catch (RemoteException e) {
-// e.printStackTrace();
-// }
+ writeKeysToMainProfileContact(context, resolver);
+
+ Set<Long> deletedKeys = getRawContactMasterKeyIds(resolver);
// Load all public Keys from OK
// TODO: figure out why using selectionArgs does not work in this case
@@ -457,7 +446,6 @@ public class ContactHelper {
while (cursor.moveToNext()) {
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
String[] userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
- String keyIdShort = KeyFormattingUtils.convertKeyIdToHexShort(cursor.getLong(INDEX_MASTER_KEY_ID));
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
@@ -487,7 +475,7 @@ public class ContactHelper {
Log.d(Constants.TAG, "Insert new raw contact with masterKeyId " + masterKeyId);
insertContact(ops, context, masterKeyId);
- writeContactKey(ops, context, rawContactId, masterKeyId, keyIdShort);
+ writeContactKey(ops, context, rawContactId, masterKeyId, userIdSplit[0]);
}
// We always update the display name (which is derived from primary user id)
@@ -517,8 +505,7 @@ public class ContactHelper {
*
* @param context
*/
- public static void writeKeysToMainProfileContact(Context context) {
- ContentResolver resolver = context.getContentResolver();
+ public static void writeKeysToMainProfileContact(Context context, ContentResolver resolver) {
Set<Long> keysToDelete = getMainProfileMasterKeyIds(resolver);
// get all keys which have associated secret keys
@@ -763,10 +750,10 @@ public class ContactHelper {
* This creates the link to OK in contact details
*/
private static void writeContactKey(ArrayList<ContentProviderOperation> ops, Context context, long rawContactId,
- long masterKeyId, String keyIdShort) {
+ long masterKeyId, String keyName) {
ops.add(referenceRawContact(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI), rawContactId)
.withValue(ContactsContract.Data.MIMETYPE, Constants.CUSTOM_CONTACT_DATA_MIME_TYPE)
- .withValue(ContactsContract.Data.DATA1, context.getString(R.string.contact_show_key, keyIdShort))
+ .withValue(ContactsContract.Data.DATA1, context.getString(R.string.contact_show_key, keyName))
.withValue(ContactsContract.Data.DATA2, masterKeyId)
.build());
}