diff options
Diffstat (limited to 'src/eu/siacs/conversations/ui')
8 files changed, 56 insertions, 27 deletions
diff --git a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index ca3bb4a2..98bf70ed 100644 --- a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -201,7 +201,8 @@ public class ConferenceDetailsActivity extends XmppActivity { private void populateView() { mAccountJid.setText(getString(R.string.using_account, conversation .getAccount().getJid())); - mYourPhoto.setImageBitmap(conversation.getAccount().getImage(this, 48)); + mYourPhoto.setImageBitmap(xmppConnectionService.getAvatarService() + .getAvatar(conversation.getAccount(), getPixel(48))); setTitle(conversation.getName()); mFullJid.setText(conversation.getContactJid().split("/", 2)[0]); mYourNick.setText(conversation.getMucOptions().getActualNick()); @@ -248,21 +249,23 @@ public class ConferenceDetailsActivity extends XmppActivity { } Bitmap bm; if (user.getJid() != null) { - Contact contact = account.getRoster().getContact(user.getJid()); - if (contact.showInRoster()) { - bm = contact.getImage(48, this); + Contact contact = account.getRoster().getContactFromRoster( + user.getJid()); + if (contact != null) { + bm = xmppConnectionService.getAvatarService().getAvatar( + contact, getPixel(48)); name.setText(contact.getDisplayName()); role.setText(user.getName() + " \u2022 " + getReadableRole(user.getRole())); } else { - bm = UIHelper.getContactPicture(user.getName(), 48, this, - false); + bm = xmppConnectionService.getAvatarService().getAvatar( + user.getName(), getPixel(48)); name.setText(user.getName()); role.setText(getReadableRole(user.getRole())); } } else { - bm = UIHelper - .getContactPicture(user.getName(), 48, this, false); + bm = xmppConnectionService.getAvatarService().getAvatar( + user.getName(), getPixel(48)); name.setText(user.getName()); role.setText(getReadableRole(user.getRole())); } diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index 65bd5cbf..d43eee59 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -313,10 +313,7 @@ public class ContactDetailsActivity extends XmppActivity { } accountJidTv.setText(getString(R.string.using_account, contact .getAccount().getJid())); - - UIHelper.prepareContactBadge(this, badge, contact, - getApplicationContext()); - + prepareContactBadge(badge, contact); if (contact.getSystemAccount() == null) { badge.setOnClickListener(onBadgeClick); } @@ -383,6 +380,16 @@ public class ContactDetailsActivity extends XmppActivity { } } + private void prepareContactBadge(QuickContactBadge badge, Contact contact) { + if (contact.getSystemAccount() != null) { + String[] systemAccount = contact.getSystemAccount().split("#"); + long id = Long.parseLong(systemAccount[0]); + badge.assignContactUri(Contacts.getLookupUri(id, systemAccount[1])); + } + badge.setImageBitmap(xmppConnectionService.getAvatarService() + .getAvatar(contact, getPixel(72))); + } + protected void confirmToDeleteFingerprint(final String fingerprint) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.delete_fingerprint); diff --git a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index f46d92f9..24330361 100644 --- a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -158,8 +158,8 @@ public class PublishProfilePictureActivity extends XmppActivity { if (this.avatarUri == null) { if (this.account.getAvatar() != null || this.defaultUri == null) { - this.avatar.setImageBitmap(this.account.getImage( - getApplicationContext(), 384)); + // this.avatar.setImageBitmap(this.account.getImage(getApplicationContext(), + // 384)); if (this.defaultUri != null) { this.avatar .setOnLongClickListener(this.backToDefaultListener); diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java index cd77557c..ca1bf465 100644 --- a/src/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/eu/siacs/conversations/ui/XmppActivity.java @@ -526,6 +526,11 @@ public abstract class XmppActivity extends Activity { return this.mSecondaryBackgroundColor; } + public int getPixel(int dp) { + DisplayMetrics metrics = getResources().getDisplayMetrics(); + return ((int) (dp * metrics.density)); + } + class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> { private final WeakReference<ImageView> imageViewReference; private Message message = null; diff --git a/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java index 5c25bf34..40229953 100644 --- a/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java @@ -34,7 +34,8 @@ public class AccountAdapter extends ArrayAdapter<Account> { jid.setText(account.getJid()); TextView statusView = (TextView) view.findViewById(R.id.account_status); ImageView imageView = (ImageView) view.findViewById(R.id.account_image); - imageView.setImageBitmap(account.getImage(activity, 48)); + imageView.setImageBitmap(activity.xmppConnectionService + .getAvatarService().getAvatar(account, activity.getPixel(48))); switch (account.getStatus()) { case Account.STATUS_DISABLED: statusView.setText(getContext().getString( diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 20c7bee2..1fea8dcf 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -127,7 +127,9 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { ImageView profilePicture = (ImageView) view .findViewById(R.id.conversation_image); - profilePicture.setImageBitmap(conversation.getImage(activity, 56)); + profilePicture.setImageBitmap(activity.xmppConnectionService + .getAvatarService().getAvatar(conversation, + activity.getPixel(56))); return view; } diff --git a/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java b/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java index df67e566..64e077a3 100644 --- a/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java @@ -4,6 +4,7 @@ import java.util.List; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.ListItem; +import eu.siacs.conversations.ui.XmppActivity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; @@ -14,8 +15,11 @@ import android.widget.TextView; public class ListItemAdapter extends ArrayAdapter<ListItem> { - public ListItemAdapter(Context context, List<ListItem> objects) { - super(context, 0, objects); + protected XmppActivity activity; + + public ListItemAdapter(XmppActivity activity, List<ListItem> objects) { + super(activity, 0, objects); + this.activity = activity; } @Override @@ -32,7 +36,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { jid.setText(item.getJid()); name.setText(item.getDisplayName()); - picture.setImageBitmap(item.getImage(48, getContext())); + picture.setImageBitmap(activity.xmppConnectionService + .getAvatarService().getAvatar(item, activity.getPixel(48))); return view; } diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java index db783b7f..bc5b3387 100644 --- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -59,8 +59,10 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (this.accountBitmap == null) { if (getCount() > 0) { - this.accountBitmap = getItem(0).getConversation().getAccount() - .getImage(getContext(), 48); + this.accountBitmap = activity.xmppConnectionService + .getAvatarService().getAvatar( + getItem(0).getConversation().getAccount(), + activity.getPixel(48)); } } return this.accountBitmap; @@ -494,9 +496,12 @@ public class MessageAdapter extends ArrayAdapter<Message> { && d.getStatus() == Downloadable.STATUS_DELETED) { displayInfoMessage(viewHolder, R.string.image_file_deleted); } else if (d != null && d.getStatus() == Downloadable.STATUS_OFFER) { - displayDownloadableMessage(viewHolder, item,R.string.download_image); - } else if (d != null && d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) { - displayDownloadableMessage(viewHolder, item,R.string.check_image_filesize); + displayDownloadableMessage(viewHolder, item, + R.string.download_image); + } else if (d != null + && d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) { + displayDownloadableMessage(viewHolder, item, + R.string.check_image_filesize); } else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED) || (item.getEncryption() == Message.ENCRYPTION_NONE) || (item.getEncryption() == Message.ENCRYPTION_OTR)) { @@ -564,7 +569,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { public Bitmap get(Contact contact, Context context) { if (!contactBitmaps.containsKey(contact.getJid())) { contactBitmaps.put(contact.getJid(), - contact.getImage(48, context)); + activity.xmppConnectionService.getAvatarService() + .getAvatar(contact, activity.getPixel(48))); } return contactBitmaps.get(contact.getJid()); } @@ -573,8 +579,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (unknownBitmaps.containsKey(name)) { return unknownBitmaps.get(name); } else { - Bitmap bm = UIHelper - .getContactPicture(name, 48, context, false); + Bitmap bm = activity.xmppConnectionService.getAvatarService() + .getAvatar(name, activity.getPixel(48)); unknownBitmaps.put(name, bm); return bm; } |