From 759009ddb4ac11f4065ecfa14e17ed330bd01989 Mon Sep 17 00:00:00 2001 From: Adithya Abraham Philip Date: Fri, 13 Mar 2015 04:04:11 +0530 Subject: added own profile support in linekd system contact --- .../keychain/ui/ViewKeyFragment.java | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index eae283269..68da3b58c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -44,6 +44,8 @@ import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; import org.sufficientlysecure.keychain.util.ContactHelper; import org.sufficientlysecure.keychain.util.Log; +import java.util.List; + public class ViewKeyFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks { @@ -126,19 +128,35 @@ public class ViewKeyFragment extends LoaderFragment implements final Context context = mSystemContactName.getContext(); final ContentResolver resolver = context.getContentResolver(); - final long contactId = ContactHelper.findContactId(resolver, masterKeyId); - final String contactName = ContactHelper.getContactName(resolver, contactId); + long contactId; + String contactName = null; + + if(mIsSecret) { + contactId = ContactHelper.getMainProfileContactId(resolver); + List mainProfileNames = ContactHelper.getMainProfileContactName(context); + if(mainProfileNames!=null) contactName = mainProfileNames.get(0); + + } else { + contactId = ContactHelper.findContactId(resolver, masterKeyId); + contactName = ContactHelper.getContactName(resolver, contactId); + } if (contactName != null) {//contact name exists for given master key mSystemContactName.setText(contactName); - Bitmap picture = ContactHelper.loadPhotoByMasterKeyId(resolver, masterKeyId, true); + Bitmap picture; + if(mIsSecret) { + picture = ContactHelper.loadMainProfilePhoto(resolver, false); + } else { + picture = ContactHelper.loadPhotoByMasterKeyId(resolver,masterKeyId,false); + } if (picture != null) mSystemContactPicture.setImageBitmap(picture); + final long finalContactId = contactId; mSystemContactLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - launchContactActivity(contactId, context); + launchContactActivity(finalContactId, context); } }); mSystemContactLoaded = true; @@ -239,14 +257,14 @@ public class ViewKeyFragment extends LoaderFragment implements switch (loader.getId()) { case LOADER_ID_UNIFIED: { if (data.moveToFirst()) { + + mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; + //TODO system to allow immediate refreshing of system contact on verification if (!mSystemContactLoaded) {//ensure we load linked system contact only once long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID); loadLinkedSystemContact(masterKeyId); } - - mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; - // load user ids after we know if it's a secret key mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0, !mIsSecret, null); mUserIds.setAdapter(mUserIdsAdapter); -- cgit v1.2.3