public static String getMessageDisplayName(final Message message) { if (message.getStatus() == Message.STATUS_RECEIVED) { final Contact contact = message.getContact(); if (message.getConversation().getMode() == Conversation.MODE_MULTI) { if (contact != null) { return contact.getDisplayName(); } else { return getDisplayedMucCounterpart(message.getCounterpart()); } } else { return contact != null ? contact.getDisplayName() : ""; } } else { if (message.getConversation().getMode() == Conversation.MODE_MULTI) { return getDisplayedMucCounterpart(message.getConversation().getJid()); } else { final Jid jid = message.getConversation().getAccount().getJid(); return jid.hasLocalpart() ? jid.getLocalpart() : jid.toDomainJid().toString(); } } }
public Bitmap get(Contact contact, int size) { final String KEY = key(contact, size); Bitmap avatar = this.mXmppConnectionService.getBitmapCache().get(KEY); if (avatar != null) { return avatar; } if (contact.getProfilePhoto() != null) { avatar = mXmppConnectionService .getFileBackend() .cropCenterSquare(Uri.parse(contact.getProfilePhoto()), size); } if (avatar == null && contact.getAvatar() != null) { avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatar(), size); } if (avatar == null) { avatar = get(contact.getDisplayName(), size); } this.mXmppConnectionService.getBitmapCache().put(KEY, avatar); return avatar; }
private void populateView() { mAccountJid.setText(getString(R.string.using_account, conversation.getAccount().getJid())); mYourPhoto.setImageBitmap(avatarService().get(conversation.getAccount(), getPixel(48))); setTitle(conversation.getName()); mFullJid.setText(conversation.getContactJid().split("/", 2)[0]); mYourNick.setText(conversation.getMucOptions().getActualNick()); mRoleAffiliaton = (TextView) findViewById(R.id.muc_role); if (conversation.getMucOptions().online()) { mMoreDetails.setVisibility(View.VISIBLE); User self = conversation.getMucOptions().getSelf(); switch (self.getAffiliation()) { case User.AFFILIATION_ADMIN: mRoleAffiliaton.setText( getReadableRole(self.getRole()) + " (" + getString(R.string.admin) + ")"); break; case User.AFFILIATION_OWNER: mRoleAffiliaton.setText( getReadableRole(self.getRole()) + " (" + getString(R.string.owner) + ")"); break; default: mRoleAffiliaton.setText(getReadableRole(self.getRole())); break; } } this.users.clear(); this.users.addAll(conversation.getMucOptions().getUsers()); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); membersView.removeAllViews(); for (final User user : conversation.getMucOptions().getUsers()) { View view = inflater.inflate(R.layout.contact, membersView, false); TextView name = (TextView) view.findViewById(R.id.contact_display_name); TextView key = (TextView) view.findViewById(R.id.key); TextView role = (TextView) view.findViewById(R.id.contact_jid); if (user.getPgpKeyId() != 0) { key.setVisibility(View.VISIBLE); key.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { viewPgpKey(user); } }); key.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId())); } Bitmap bm; Contact contact = user.getContact(); if (contact != null) { bm = avatarService().get(contact, getPixel(48)); name.setText(contact.getDisplayName()); role.setText(user.getName() + " \u2022 " + getReadableRole(user.getRole())); } else { bm = avatarService().get(user.getName(), getPixel(48)); name.setText(user.getName()); role.setText(getReadableRole(user.getRole())); } ImageView iv = (ImageView) view.findViewById(R.id.contact_photo); iv.setImageBitmap(bm); membersView.addView(view); } }