mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 18:19:38 +00:00
Refactor colorization to support dark theme.
// FREEBIE
This commit is contained in:
@@ -10,6 +10,8 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.color.ThemeType;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -37,12 +39,14 @@ public class AvatarImageView extends ImageView {
|
||||
}
|
||||
|
||||
public void setAvatar(@Nullable Recipients recipients, boolean quickContactEnabled) {
|
||||
ThemeType themeType = ThemeType.getCurrent(getContext());
|
||||
|
||||
if (recipients != null) {
|
||||
int backgroundColor = recipients.getColor().or(ContactColors.UNKNOWN_COLOR);
|
||||
setImageDrawable(recipients.getContactPhoto().asDrawable(getContext(), backgroundColor, inverted));
|
||||
MaterialColor backgroundColor = recipients.getColor(getContext());
|
||||
setImageDrawable(recipients.getContactPhoto().asDrawable(getContext(), backgroundColor.toConversationColor(themeType), inverted));
|
||||
setAvatarClickHandler(recipients, quickContactEnabled);
|
||||
} else {
|
||||
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(null).asDrawable(getContext(), ContactColors.UNKNOWN_COLOR, inverted));
|
||||
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(null).asDrawable(getContext(), ContactColors.UNKNOWN_COLOR.toConversationColor(themeType), inverted));
|
||||
setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user