mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
parent
ed0e1c07b9
commit
4feedab02c
@ -102,7 +102,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
}
|
||||
|
||||
setBatchState(batchMode);
|
||||
this.contactPhotoImage.setAvatar(recipients.getPrimaryRecipient(), true);
|
||||
this.contactPhotoImage.setAvatar(recipients, true);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
@ -132,7 +132,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
@Override
|
||||
public void run() {
|
||||
fromView.setText(recipients, read);
|
||||
contactPhotoImage.setAvatar(recipients.getPrimaryRecipient(), true);
|
||||
contactPhotoImage.setAvatar(recipients, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
}
|
||||
|
||||
private void setHeader(Recipients recipients) {
|
||||
this.avatar.setAvatar(recipients.getPrimaryRecipient(), true);
|
||||
this.avatar.setAvatar(recipients, true);
|
||||
this.title.setText(recipients.toShortString());
|
||||
|
||||
if (recipients.isBlocked()) this.blockedIndicator.setVisibility(View.VISIBLE);
|
||||
|
@ -72,7 +72,7 @@ public class ShareListItem extends RelativeLayout
|
||||
this.fromView.setText(recipients);
|
||||
|
||||
setBackground();
|
||||
this.contactPhotoImage.setAvatar(this.recipients.getPrimaryRecipient(), false);
|
||||
this.contactPhotoImage.setAvatar(this.recipients, false);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
@ -106,7 +106,7 @@ public class ShareListItem extends RelativeLayout
|
||||
@Override
|
||||
public void run() {
|
||||
fromView.setText(recipients);
|
||||
contactPhotoImage.setAvatar(recipients.getPrimaryRecipient(), false);
|
||||
contactPhotoImage.setAvatar(recipients, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import android.widget.ImageView;
|
||||
|
||||
import org.thoughtcrime.securesms.contacts.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
|
||||
public class AvatarImageView extends ImageView {
|
||||
|
||||
@ -23,24 +25,30 @@ public class AvatarImageView extends ImageView {
|
||||
setScaleType(ScaleType.CENTER_CROP);
|
||||
}
|
||||
|
||||
public void setAvatar(@Nullable Recipient recipient, boolean quickContactEnabled) {
|
||||
if (recipient != null) {
|
||||
setImageDrawable(recipient.getContactPhoto());
|
||||
setAvatarClickHandler(recipient, quickContactEnabled);
|
||||
public void setAvatar(@Nullable Recipients recipients, boolean quickContactEnabled) {
|
||||
if (recipients != null) {
|
||||
setImageDrawable(recipients.getContactPhoto(getContext()));
|
||||
setAvatarClickHandler(recipients, quickContactEnabled);
|
||||
} else {
|
||||
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(getContext(), null));
|
||||
setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAvatarClickHandler(final Recipient recipient, boolean quickContactEnabled) {
|
||||
if (!recipient.isGroupRecipient() && quickContactEnabled) {
|
||||
public void setAvatar(@Nullable Recipient recipient, boolean quickContactEnabled) {
|
||||
setAvatar(RecipientFactory.getRecipientsFor(getContext(), recipient, true), quickContactEnabled);
|
||||
}
|
||||
|
||||
private void setAvatarClickHandler(final Recipients recipients, boolean quickContactEnabled) {
|
||||
if (!recipients.isGroupRecipient() && quickContactEnabled) {
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (recipient.getContactUri() != null) {
|
||||
Recipient recipient = recipients.getPrimaryRecipient();
|
||||
|
||||
if (recipient != null && recipient.getContactUri() != null) {
|
||||
ContactsContract.QuickContact.showQuickContact(getContext(), AvatarImageView.this, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null);
|
||||
} else {
|
||||
} else if (recipient != null) {
|
||||
final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipient.getNumber());
|
||||
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
||||
|
@ -43,7 +43,7 @@ public class BlockedContactListItem extends RelativeLayout implements Recipients
|
||||
|
||||
@Override
|
||||
public void onModified(Recipients recipients) {
|
||||
this.contactPhotoImage.setAvatar(recipients.getPrimaryRecipient(), false);
|
||||
this.contactPhotoImage.setAvatar(recipients, false);
|
||||
this.nameView.setText(recipients.toShortString());
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,14 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms.recipients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
|
||||
import org.thoughtcrime.securesms.contacts.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient.RecipientModifiedListener;
|
||||
@ -146,6 +149,11 @@ public class Recipients implements Iterable<Recipient>, RecipientModifiedListene
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
public Drawable getContactPhoto(Context context) {
|
||||
if (recipients.size() == 1) return recipients.get(0).getContactPhoto();
|
||||
else return ContactPhotoFactory.getDefaultGroupPhoto(context);
|
||||
}
|
||||
|
||||
public synchronized void addListener(RecipientsModifiedListener listener) {
|
||||
if (listeners.isEmpty()) {
|
||||
for (Recipient recipient : recipients) {
|
||||
|
Loading…
Reference in New Issue
Block a user