object oriented split user id
This commit is contained in:
@@ -37,7 +37,6 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -447,7 +446,7 @@ public class ContactHelper {
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||
String[] userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
|
||||
@@ -470,19 +469,19 @@ public class ContactHelper {
|
||||
if (rawContactId != -1) {
|
||||
deleteRawContactById(resolver, rawContactId);
|
||||
}
|
||||
} else if (userIdSplit[0] != null) {
|
||||
} else if (userIdSplit.name != null) {
|
||||
|
||||
// Create a new rawcontact with corresponding key if it does not exist yet
|
||||
if (rawContactId == -1) {
|
||||
Log.d(Constants.TAG, "Insert new raw contact with masterKeyId " + masterKeyId);
|
||||
|
||||
insertContact(ops, context, masterKeyId);
|
||||
writeContactKey(ops, context, rawContactId, masterKeyId, userIdSplit[0]);
|
||||
writeContactKey(ops, context, rawContactId, masterKeyId, userIdSplit.name);
|
||||
}
|
||||
|
||||
// We always update the display name (which is derived from primary user id)
|
||||
// and email addresses from user id
|
||||
writeContactDisplayName(ops, rawContactId, userIdSplit[0]);
|
||||
writeContactDisplayName(ops, rawContactId, userIdSplit.name);
|
||||
writeContactEmail(ops, resolver, rawContactId, masterKeyId);
|
||||
try {
|
||||
resolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
||||
@@ -521,9 +520,9 @@ public class ContactHelper {
|
||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||
String[] userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
|
||||
if (!isExpired && !isRevoked && userIdSplit[0] != null) {
|
||||
if (!isExpired && !isRevoked && userIdSplit.name != null) {
|
||||
// if expired or revoked will not be removed from keysToDelete or inserted
|
||||
// into main profile ("me" contact)
|
||||
boolean existsInMainProfile = keysToDelete.remove(masterKeyId);
|
||||
@@ -534,7 +533,7 @@ public class ContactHelper {
|
||||
|
||||
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
||||
insertMainProfileRawContact(ops, masterKeyId);
|
||||
writeContactKey(ops, context, rawContactId, masterKeyId, userIdSplit[0]);
|
||||
writeContactKey(ops, context, rawContactId, masterKeyId, userIdSplit.name);
|
||||
|
||||
try {
|
||||
resolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
||||
@@ -776,14 +775,14 @@ public class ContactHelper {
|
||||
null, null);
|
||||
if (ids != null) {
|
||||
while (ids.moveToNext()) {
|
||||
String[] userId = KeyRing.splitUserId(ids.getString(0));
|
||||
if (userId[1] != null) {
|
||||
KeyRing.UserId userId = KeyRing.splitUserId(ids.getString(0));
|
||||
if (userId.email != null) {
|
||||
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])
|
||||
.withValue(ContactsContract.CommonDataKinds.Email.DATA, userId.email)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user