Refactor UIHelper to use getContactPicture

Normalize the interface, reduce code duplication
This commit is contained in:
andy 2014-04-11 22:30:50 +02:00
parent 259bb446ca
commit 3d6f03e859
2 changed files with 4 additions and 14 deletions

View File

@ -230,7 +230,7 @@ public class ContactDetailsActivity extends XmppActivity {
contactJid.setText(contact.getJid()); contactJid.setText(contact.getJid());
accountJid.setText(contact.getAccount().getJid()); accountJid.setText(contact.getAccount().getJid());
UIHelper.prepareContactBadge(this, badge, contact); UIHelper.prepareContactBadge(this, badge, contact, getApplicationContext());
if (contact.getSystemAccount() == null) { if (contact.getSystemAccount() == null) {
badge.setOnClickListener(onBadgeClick); badge.setOnClickListener(onBadgeClick);

View File

@ -260,7 +260,7 @@ public class UIHelper {
if (notify) { if (notify) {
if (vibrate) { if (vibrate) {
int dat = 70; int dat = 70;
long[] pattern = {0,3*dat,dat,dat,dat,3*dat,dat,dat}; long[] pattern = {0,3*dat,dat,dat};
mBuilder.setVibrate(pattern); mBuilder.setVibrate(pattern);
} }
mBuilder.setLights(0xffffffff, 2000, 4000); mBuilder.setLights(0xffffffff, 2000, 4000);
@ -307,23 +307,13 @@ public class UIHelper {
} }
public static void prepareContactBadge(final Activity activity, public static void prepareContactBadge(final Activity activity,
QuickContactBadge badge, final Contact contact) { QuickContactBadge badge, final Contact contact, Context context) {
if (contact.getSystemAccount() != null) { if (contact.getSystemAccount() != null) {
String[] systemAccount = contact.getSystemAccount().split("#"); String[] systemAccount = contact.getSystemAccount().split("#");
long id = Long.parseLong(systemAccount[0]); long id = Long.parseLong(systemAccount[0]);
badge.assignContactUri(Contacts.getLookupUri(id, systemAccount[1])); badge.assignContactUri(Contacts.getLookupUri(id, systemAccount[1]));
if (contact.getProfilePhoto() != null) {
badge.setImageURI(Uri.parse(contact.getProfilePhoto()));
} else {
badge.setImageBitmap(UIHelper.getUnknownContactPicture(
contact.getDisplayName(), 400));
} }
} else { badge.setImageBitmap(UIHelper.getContactPicture(contact, "", 400, context));
badge.setImageBitmap(UIHelper.getUnknownContactPicture(
contact.getDisplayName(), 400));
}
} }
public static AlertDialog getVerifyFingerprintDialog( public static AlertDialog getVerifyFingerprintDialog(