mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 18:29:11 +00:00
Fully colorize conversations.
1. Switch from 300 to 500 colors. 2. Colorize incoming conversation bubbles. 3. Colorize recipeint preference activity toolbar. 4. Support inverted colors in avatars. 5. Make status bar icons tint according to secondary color. // FREEBIE
This commit is contained in:
@@ -2,12 +2,14 @@ package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -16,6 +18,8 @@ import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
|
||||
public class AvatarImageView extends ImageView {
|
||||
|
||||
private boolean inverted;
|
||||
|
||||
public AvatarImageView(Context context) {
|
||||
super(context);
|
||||
setScaleType(ScaleType.CENTER_CROP);
|
||||
@@ -24,15 +28,21 @@ public class AvatarImageView extends ImageView {
|
||||
public AvatarImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setScaleType(ScaleType.CENTER_CROP);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AvatarImageView, 0, 0);
|
||||
inverted = typedArray.getBoolean(0, false);
|
||||
typedArray.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAvatar(@Nullable Recipients recipients, boolean quickContactEnabled) {
|
||||
if (recipients != null) {
|
||||
int backgroundColor = recipients.getColor().or(ContactColors.UNKNOWN_COLOR);
|
||||
setImageDrawable(recipients.getContactPhoto().asDrawable(getContext(), backgroundColor));
|
||||
setImageDrawable(recipients.getContactPhoto().asDrawable(getContext(), backgroundColor, inverted));
|
||||
setAvatarClickHandler(recipients, quickContactEnabled);
|
||||
} else {
|
||||
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(null).asDrawable(getContext(), ContactColors.UNKNOWN_COLOR));
|
||||
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(null).asDrawable(getContext(), ContactColors.UNKNOWN_COLOR, inverted));
|
||||
setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user