Separate avatar colors from chat colors.

This commit is contained in:
Greyson Parrelli
2021-05-25 22:44:19 -04:00
parent bcc5d485ab
commit 6342a45b4e
29 changed files with 364 additions and 133 deletions

View File

@@ -65,12 +65,11 @@ public class InsightsRepository implements InsightsDashboardViewModel.Repository
@Override
public void getUserAvatar(@NonNull Consumer<InsightsUserAvatar> avatarConsumer) {
SimpleTask.run(() -> {
Recipient self = Recipient.self().resolve();
String name = Optional.fromNullable(self.getDisplayName(context)).or("");
ChatColors fallbackColor = self.getChatColors();
Recipient self = Recipient.self().resolve();
String name = Optional.fromNullable(self.getDisplayName(context)).or("");
return new InsightsUserAvatar(new ProfileContactPhoto(self, self.getProfileAvatar()),
fallbackColor,
self.getAvatarColor(),
new GeneratedContactPhoto(name, R.drawable.ic_profile_outline_40));
}, avatarConsumer::accept);
}

View File

@@ -10,22 +10,22 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto;
import org.thoughtcrime.securesms.conversation.colors.ChatColors;
import org.thoughtcrime.securesms.conversation.colors.AvatarColor;
import org.thoughtcrime.securesms.mms.GlideApp;
class InsightsUserAvatar {
private final ProfileContactPhoto profileContactPhoto;
private final ChatColors fallbackColor;
private final AvatarColor fallbackColor;
private final FallbackContactPhoto fallbackContactPhoto;
InsightsUserAvatar(@NonNull ProfileContactPhoto profileContactPhoto, @NonNull ChatColors fallbackColor, @NonNull FallbackContactPhoto fallbackContactPhoto) {
InsightsUserAvatar(@NonNull ProfileContactPhoto profileContactPhoto, @NonNull AvatarColor fallbackColor, @NonNull FallbackContactPhoto fallbackContactPhoto) {
this.profileContactPhoto = profileContactPhoto;
this.fallbackColor = fallbackColor;
this.fallbackContactPhoto = fallbackContactPhoto;
}
private Drawable fallbackDrawable(@NonNull Context context) {
return fallbackContactPhoto.asDrawable(context, fallbackColor);
return fallbackContactPhoto.asDrawable(context, fallbackColor.colorInt());
}
void load(ImageView into) {