mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
use new colors in profile
This commit is contained in:
parent
ef0eb15034
commit
ada9377a37
6 changed files with 14 additions and 38 deletions
|
@ -195,9 +195,9 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||||
if (recipient.getContactPhoto(this) == null) this.avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
if (recipient.getContactPhoto(this) == null) this.avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||||
else this.avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
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.setTitle(recipient.toShortString());
|
||||||
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
|
this.toolbarLayout.setContentScrimColor(recipient.getFallbackAvatarColor(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -354,7 +354,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||||
if (aboutDivider != null) getPreferenceScreen().removePreference(aboutDivider);
|
if (aboutDivider != null) getPreferenceScreen().removePreference(aboutDivider);
|
||||||
} else {
|
} else {
|
||||||
colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity()));
|
colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity()));
|
||||||
colorPreference.setColor(recipient.getColor().toActionBarColor(getActivity()));
|
colorPreference.setColor(recipient.getFallbackAvatarColor(getActivity()));
|
||||||
|
|
||||||
aboutPreference.setTitle(formatAddress(recipient.getAddress()));
|
aboutPreference.setTitle(formatAddress(recipient.getAddress()));
|
||||||
aboutPreference.setSummary(recipient.getCustomLabel());
|
aboutPreference.setSummary(recipient.getCustomLabel());
|
||||||
|
|
|
@ -79,34 +79,6 @@ public enum MaterialColor {
|
||||||
: conversationColorLight);
|
: 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) {
|
public boolean represents(Context context, int colorValue) {
|
||||||
return context.getResources().getColor(conversationColorDark) == colorValue ||
|
return context.getResources().getColor(conversationColorDark) == colorValue ||
|
||||||
context.getResources().getColor(conversationColorLight) == colorValue ||
|
context.getResources().getColor(conversationColorLight) == colorValue ||
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class AvatarImageView extends AppCompatImageView {
|
||||||
if (recipient != null) {
|
if (recipient != null) {
|
||||||
ContactPhoto contactPhoto = recipient.getContactPhoto(getContext());
|
ContactPhoto contactPhoto = recipient.getContactPhoto(getContext());
|
||||||
requestManager.load(contactPhoto)
|
requestManager.load(contactPhoto)
|
||||||
.fallback(recipient.getFallbackContactPhotoDrawable(getContext(), inverted))
|
.fallback(recipient.getFallbackAvatarDrawable(getContext()))
|
||||||
.error(recipient.getFallbackContactPhotoDrawable(getContext(), inverted))
|
.error(recipient.getFallbackAvatarDrawable(getContext()))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.into(this);
|
.into(this);
|
||||||
|
|
|
@ -193,8 +193,8 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
|
||||||
: author.toShortString());
|
: author.toShortString());
|
||||||
|
|
||||||
// We use the raw color resource because Android 4.x was struggling with tints here
|
// We use the raw color resource because Android 4.x was struggling with tints here
|
||||||
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
|
//quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
|
||||||
rootView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
|
//rootView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {
|
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {
|
||||||
|
|
|
@ -331,7 +331,7 @@ public class Recipient implements RecipientModifiedListener {
|
||||||
return (getName() == null ? address.serialize() : getName());
|
return (getName() == null ? address.serialize() : getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
|
public int getFallbackAvatarColor(Context context) {
|
||||||
int rgb = 0x00808080;
|
int rgb = 0x00808080;
|
||||||
if(address.isDcContact()) {
|
if(address.isDcContact()) {
|
||||||
rgb = DcHelper.getContext(context).getContact(address.getDcContactId()).getColor();
|
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();
|
rgb = DcHelper.getContext(context).getChat(address.getDcChatId()).getColor();
|
||||||
}
|
}
|
||||||
int argb = Color.argb(0xFF, Color.red(rgb), Color.green(rgb), Color.blue(rgb));
|
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() {
|
public synchronized @NonNull FallbackContactPhoto getFallbackContactPhoto() {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class DirectShareService extends ChooserTargetService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap getFallbackDrawable(@NonNull Recipient recipient) {
|
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_width),
|
||||||
getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height));
|
getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue