use new colors in profile

This commit is contained in:
B. Petersen 2018-12-06 15:16:34 +01:00
parent ef0eb15034
commit ada9377a37
No known key found for this signature in database
GPG key ID: 3B88E92DEA8E9AFC
6 changed files with 14 additions and 38 deletions

View file

@ -195,9 +195,9 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
if (recipient.getContactPhoto(this) == null) this.avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
else this.avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
this.avatar.setBackgroundColor(recipient.getColor().toActionBarColor(this));
this.avatar.setBackgroundColor(recipient.getFallbackAvatarColor(this));
this.toolbarLayout.setTitle(recipient.toShortString());
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
this.toolbarLayout.setContentScrimColor(recipient.getFallbackAvatarColor(this));
}
@Override
@ -354,7 +354,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
if (aboutDivider != null) getPreferenceScreen().removePreference(aboutDivider);
} else {
colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity()));
colorPreference.setColor(recipient.getColor().toActionBarColor(getActivity()));
colorPreference.setColor(recipient.getFallbackAvatarColor(getActivity()));
aboutPreference.setTitle(formatAddress(recipient.getAddress()));
aboutPreference.setSummary(recipient.getCustomLabel());

View file

@ -79,34 +79,6 @@ public enum MaterialColor {
: conversationColorLight);
}
public int toActionBarColor(@NonNull Context context) {
return context.getResources().getColor(isDarkTheme(context) ? actionBarColorDark
: actionBarColorLight);
}
public int toStatusBarColor(@NonNull Context context) {
return context.getResources().getColor(isDarkTheme(context) ? statusBarColorDark
: statusBarColorLight);
}
public int toQuoteBarColorResource(@NonNull Context context, boolean outgoing) {
if (outgoing) {
return conversationColorDark;
}
return R.color.white;
}
public int toQuoteBackgroundColor(@NonNull Context context, boolean outgoing) {
if (outgoing) {
int color = toConversationColor(context);
int alpha = isDarkTheme(context) ? (int) (0.2 * 255) : (int) (0.4 * 255);
return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
}
return context.getResources().getColor(isDarkTheme(context) ? R.color.transparent_black_70
: R.color.transparent_white_aa);
}
public boolean represents(Context context, int colorValue) {
return context.getResources().getColor(conversationColorDark) == colorValue ||
context.getResources().getColor(conversationColorLight) == colorValue ||

View file

@ -49,8 +49,8 @@ public class AvatarImageView extends AppCompatImageView {
if (recipient != null) {
ContactPhoto contactPhoto = recipient.getContactPhoto(getContext());
requestManager.load(contactPhoto)
.fallback(recipient.getFallbackContactPhotoDrawable(getContext(), inverted))
.error(recipient.getFallbackContactPhotoDrawable(getContext(), inverted))
.fallback(recipient.getFallbackAvatarDrawable(getContext()))
.error(recipient.getFallbackAvatarDrawable(getContext()))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.circleCrop()
.into(this);

View file

@ -193,8 +193,8 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
: author.toShortString());
// We use the raw color resource because Android 4.x was struggling with tints here
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
rootView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
//quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
//rootView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
}
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {

View file

@ -331,7 +331,7 @@ public class Recipient implements RecipientModifiedListener {
return (getName() == null ? address.serialize() : getName());
}
public synchronized @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
public int getFallbackAvatarColor(Context context) {
int rgb = 0x00808080;
if(address.isDcContact()) {
rgb = DcHelper.getContext(context).getContact(address.getDcContactId()).getColor();
@ -340,7 +340,11 @@ public class Recipient implements RecipientModifiedListener {
rgb = DcHelper.getContext(context).getChat(address.getDcChatId()).getColor();
}
int argb = Color.argb(0xFF, Color.red(rgb), Color.green(rgb), Color.blue(rgb));
return getFallbackContactPhoto().asDrawable(context, argb, inverted);
return argb;
}
public synchronized @NonNull Drawable getFallbackAvatarDrawable(Context context) {
return getFallbackContactPhoto().asDrawable(context, getFallbackAvatarColor(context), false);
}
public synchronized @NonNull FallbackContactPhoto getFallbackContactPhoto() {

View file

@ -89,7 +89,7 @@ public class DirectShareService extends ChooserTargetService {
}
private Bitmap getFallbackDrawable(@NonNull Recipient recipient) {
return BitmapUtil.createFromDrawable(recipient.getFallbackContactPhotoDrawable(this, false),
return BitmapUtil.createFromDrawable(recipient.getFallbackAvatarDrawable(this),
getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height));
}