mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Implement ability to view badges and modify whether they appear.
Note: this is available in staging only.
This commit is contained in:
@@ -15,6 +15,7 @@ import com.annimon.stream.Stream;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.badges.models.Badge;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
||||
@@ -124,6 +125,7 @@ public class Recipient {
|
||||
private final String systemContactName;
|
||||
private final Optional<Extras> extras;
|
||||
private final boolean hasGroupsInCommon;
|
||||
private final List<Badge> badges;
|
||||
|
||||
/**
|
||||
* Returns a {@link LiveRecipient}, which contains a {@link Recipient} that may or may not be
|
||||
@@ -376,6 +378,7 @@ public class Recipient {
|
||||
this.systemContactName = null;
|
||||
this.extras = Optional.absent();
|
||||
this.hasGroupsInCommon = false;
|
||||
this.badges = Collections.emptyList();
|
||||
}
|
||||
|
||||
public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) {
|
||||
@@ -429,6 +432,7 @@ public class Recipient {
|
||||
this.systemContactName = details.systemContactName;
|
||||
this.extras = details.extras;
|
||||
this.hasGroupsInCommon = details.hasGroupsInCommon;
|
||||
this.badges = details.badges;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getId() {
|
||||
@@ -1023,6 +1027,10 @@ public class Recipient {
|
||||
return aboutEmoji;
|
||||
}
|
||||
|
||||
public @NonNull List<Badge> getBadges() {
|
||||
return badges;
|
||||
}
|
||||
|
||||
public @Nullable String getCombinedAboutAndEmoji() {
|
||||
if (!Util.isEmpty(aboutEmoji)) {
|
||||
if (!Util.isEmpty(about)) {
|
||||
@@ -1202,7 +1210,8 @@ public class Recipient {
|
||||
Objects.equals(about, other.about) &&
|
||||
Objects.equals(aboutEmoji, other.aboutEmoji) &&
|
||||
Objects.equals(extras, other.extras) &&
|
||||
hasGroupsInCommon == other.hasGroupsInCommon;
|
||||
hasGroupsInCommon == other.hasGroupsInCommon &&
|
||||
Objects.equals(badges, other.badges);
|
||||
}
|
||||
|
||||
private static boolean allContentsAreTheSame(@NonNull List<Recipient> a, @NonNull List<Recipient> b) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
||||
import org.thoughtcrime.securesms.badges.models.Badge;
|
||||
import org.thoughtcrime.securesms.conversation.colors.AvatarColor;
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.InsightsBannerTier;
|
||||
@@ -22,6 +23,7 @@ import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -77,6 +79,7 @@ public class RecipientDetails {
|
||||
final ProfileName systemProfileName;
|
||||
final Optional<Recipient.Extras> extras;
|
||||
final boolean hasGroupsInCommon;
|
||||
final List<Badge> badges;
|
||||
|
||||
public RecipientDetails(@Nullable String groupName,
|
||||
@Nullable String systemContactName,
|
||||
@@ -136,6 +139,7 @@ public class RecipientDetails {
|
||||
this.systemContactName = systemContactName;
|
||||
this.extras = Optional.fromNullable(settings.getExtras());
|
||||
this.hasGroupsInCommon = settings.hasGroupsInCommon();
|
||||
this.badges = settings.getBadges();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,6 +195,7 @@ public class RecipientDetails {
|
||||
this.systemContactName = null;
|
||||
this.extras = Optional.absent();
|
||||
this.hasGroupsInCommon = false;
|
||||
this.badges = Collections.emptyList();
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientSettings settings) {
|
||||
|
||||
Reference in New Issue
Block a user