diff options
author | mar-v-in <github@rvin.mooo.com> | 2014-06-18 16:08:35 +0200 |
---|---|---|
committer | mar-v-in <github@rvin.mooo.com> | 2014-06-18 16:14:12 +0200 |
commit | 39a68c30f8d7059080bce06e86de9565a545ee96 (patch) | |
tree | dbdbde5536346973ef2b2f9b1764e292d1167ded /OpenKeychain/src | |
parent | 0bcf7a39bf44994dfcc8e4f8cc52084976b597b0 (diff) | |
download | open-keychain-39a68c30f8d7059080bce06e86de9565a545ee96.tar.gz open-keychain-39a68c30f8d7059080bce06e86de9565a545ee96.tar.bz2 open-keychain-39a68c30f8d7059080bce06e86de9565a545ee96.zip |
Code style
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java index 8e4505004..66d579e92 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java @@ -79,7 +79,8 @@ public class ContactHelper { } public static Uri dataUriFromContactUri(Context context, Uri contactUri) { - Cursor contactMasterKey = context.getContentResolver().query(contactUri, new String[]{ContactsContract.Data.DATA2}, null, null, null, null); + Cursor contactMasterKey = context.getContentResolver().query(contactUri, + new String[]{ContactsContract.Data.DATA2}, null, null, null, null); if (contactMasterKey != null) { if (contactMasterKey.moveToNext()) { return KeychainContract.KeyRings.buildGenericKeyRingUri(contactMasterKey.getLong(0)); @@ -89,7 +90,8 @@ public class ContactHelper { return null; } - private static ContentProviderOperation.Builder referenceRawContact(ContentProviderOperation.Builder builder, int rawContactId) { + private static ContentProviderOperation.Builder referenceRawContact(ContentProviderOperation.Builder builder, + int rawContactId) { return rawContactId == -1 ? builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) : builder.withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId); @@ -119,7 +121,8 @@ public class ContactHelper { ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); if (isExpired || isRevoked) { if (rawContactId != -1) { - resolver.delete(ContactsContract.RawContacts.CONTENT_URI, ContactsContract.RawContacts._ID + "=?", new String[]{Integer.toString(rawContactId)}); + resolver.delete(ContactsContract.RawContacts.CONTENT_URI, + ContactsContract.RawContacts._ID + "=?", new String[]{Integer.toString(rawContactId)}); } } else { if (rawContactId == -1) { @@ -147,7 +150,8 @@ public class ContactHelper { .build()); } - private static void writeContactKey(ArrayList<ContentProviderOperation> ops, Context context, int rawContactId, long masterKeyId, String keyIdShort) { + private static void writeContactKey(ArrayList<ContentProviderOperation> ops, Context context, int rawContactId, + long masterKeyId, String keyIdShort) { 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)) @@ -155,16 +159,20 @@ public class ContactHelper { .build()); } - private static void writeContactEmail(ArrayList<ContentProviderOperation> ops, ContentResolver resolver, int rawContactId, long masterKeyId) { + private static void writeContactEmail(ArrayList<ContentProviderOperation> ops, ContentResolver resolver, + int rawContactId, long masterKeyId) { ops.add(selectByRawContactAndItemType(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI), rawContactId, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE).build()); - Cursor ids = resolver.query(KeychainContract.UserIds.buildUserIdsUri(Long.toString(masterKeyId)), USER_IDS_PROJECTION, KeychainContract.UserIds.IS_REVOKED + "=0", null, null); + Cursor ids = resolver.query(KeychainContract.UserIds.buildUserIdsUri(Long.toString(masterKeyId)), + USER_IDS_PROJECTION, KeychainContract.UserIds.IS_REVOKED + "=0", null, null); if (ids != null) { while (ids.moveToNext()) { String[] userId = KeyRing.splitUserId(ids.getString(0)); if (userId[1] != null) { - ops.add(referenceRawContact(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI), rawContactId) - .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) + ops.add(referenceRawContact(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI), + rawContactId) + .withValue(ContactsContract.Data.MIMETYPE, + ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) .withValue(ContactsContract.CommonDataKinds.Email.DATA, userId[1]) .build()); } @@ -173,17 +181,21 @@ public class ContactHelper { } } - private static void writeContactDisplayName(ArrayList<ContentProviderOperation> ops, int rawContactId, String displayName) { + private static void writeContactDisplayName(ArrayList<ContentProviderOperation> ops, int rawContactId, + String displayName) { if (displayName != null) { - ops.add(insertOrUpdateForRawContact(ContactsContract.Data.CONTENT_URI, rawContactId, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) + ops.add(insertOrUpdateForRawContact(ContactsContract.Data.CONTENT_URI, rawContactId, + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, displayName) .build()); } } - private static ContentProviderOperation.Builder insertOrUpdateForRawContact(Uri uri, int rawContactId, String itemType) { + private static ContentProviderOperation.Builder insertOrUpdateForRawContact(Uri uri, int rawContactId, + String itemType) { if (rawContactId == -1) { - return referenceRawContact(ContentProviderOperation.newInsert(uri), rawContactId).withValue(ContactsContract.Data.MIMETYPE, itemType); + return referenceRawContact(ContentProviderOperation.newInsert(uri), rawContactId).withValue( + ContactsContract.Data.MIMETYPE, itemType); } else { return ContentProviderOperation.newUpdate(uri).withSelection( ContactsContract.Data.RAW_CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?", @@ -191,7 +203,8 @@ public class ContactHelper { } } - private static ContentProviderOperation.Builder selectByRawContactAndItemType(ContentProviderOperation.Builder builder, int rawContactId, String itemType) { + private static ContentProviderOperation.Builder selectByRawContactAndItemType( + ContentProviderOperation.Builder builder, int rawContactId, String itemType) { return builder.withSelection( ContactsContract.Data.RAW_CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?", new String[]{Integer.toString(rawContactId), itemType}); |