mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Blur avatar photos from unknown senders when in message request state.
This commit is contained in:
@@ -32,6 +32,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase.MentionSetting;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.RecipientExtras;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
@@ -111,7 +112,8 @@ public class Recipient {
|
||||
private final String aboutEmoji;
|
||||
private final ProfileName systemProfileName;
|
||||
private final String systemContactName;
|
||||
|
||||
private final Optional<Extras> extras;
|
||||
private final boolean hasGroupsInCommon;
|
||||
|
||||
/**
|
||||
* Returns a {@link LiveRecipient}, which contains a {@link Recipient} that may or may not be
|
||||
@@ -349,6 +351,8 @@ public class Recipient {
|
||||
this.aboutEmoji = null;
|
||||
this.systemProfileName = ProfileName.EMPTY;
|
||||
this.systemContactName = null;
|
||||
this.extras = Optional.absent();
|
||||
this.hasGroupsInCommon = false;
|
||||
}
|
||||
|
||||
public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) {
|
||||
@@ -396,6 +400,8 @@ public class Recipient {
|
||||
this.aboutEmoji = details.aboutEmoji;
|
||||
this.systemProfileName = details.systemProfileName;
|
||||
this.systemContactName = details.systemContactName;
|
||||
this.extras = details.extras;
|
||||
this.hasGroupsInCommon = details.hasGroupsInCommon;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getId() {
|
||||
@@ -929,6 +935,18 @@ public class Recipient {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldBlurAvatar() {
|
||||
boolean showOverride = false;
|
||||
if (extras.isPresent()) {
|
||||
showOverride = extras.get().manuallyShownAvatar();
|
||||
}
|
||||
return !showOverride && !isSelf() && !isProfileSharing() && !isSystemContact() && !hasGroupsInCommon && isRegistered();
|
||||
}
|
||||
|
||||
public boolean hasGroupsInCommon() {
|
||||
return hasGroupsInCommon;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this recipient is missing crucial data, this will return a populated copy. Otherwise it
|
||||
* returns itself.
|
||||
@@ -1003,6 +1021,39 @@ public class Recipient {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Extras {
|
||||
private final RecipientExtras recipientExtras;
|
||||
|
||||
public static @Nullable Extras from(@Nullable RecipientExtras recipientExtras) {
|
||||
if (recipientExtras != null) {
|
||||
return new Extras(recipientExtras);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Extras(@NonNull RecipientExtras extras) {
|
||||
this.recipientExtras = extras;
|
||||
}
|
||||
|
||||
public boolean manuallyShownAvatar() {
|
||||
return recipientExtras.getManuallyShownAvatar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final Extras that = (Extras) o;
|
||||
return manuallyShownAvatar() == that.manuallyShownAvatar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(manuallyShownAvatar());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasSameContent(@NonNull Recipient other) {
|
||||
return Objects.equals(id, other.id) &&
|
||||
resolving == other.resolving &&
|
||||
@@ -1047,7 +1098,8 @@ public class Recipient {
|
||||
mentionSetting == other.mentionSetting &&
|
||||
Objects.equals(wallpaper, other.wallpaper) &&
|
||||
Objects.equals(about, other.about) &&
|
||||
Objects.equals(aboutEmoji, other.aboutEmoji);
|
||||
Objects.equals(aboutEmoji, other.aboutEmoji) &&
|
||||
Objects.equals(extras, other.extras);
|
||||
}
|
||||
|
||||
private static boolean allContentsAreTheSame(@NonNull List<Recipient> a, @NonNull List<Recipient> b) {
|
||||
|
||||
@@ -27,49 +27,51 @@ import java.util.UUID;
|
||||
|
||||
public class RecipientDetails {
|
||||
|
||||
final UUID uuid;
|
||||
final String username;
|
||||
final String e164;
|
||||
final String email;
|
||||
final GroupId groupId;
|
||||
final String groupName;
|
||||
final String systemContactName;
|
||||
final String customLabel;
|
||||
final Uri systemContactPhoto;
|
||||
final Uri contactUri;
|
||||
final Optional<Long> groupAvatarId;
|
||||
final MaterialColor color;
|
||||
final Uri messageRingtone;
|
||||
final Uri callRingtone;
|
||||
final long mutedUntil;
|
||||
final VibrateState messageVibrateState;
|
||||
final VibrateState callVibrateState;
|
||||
final boolean blocked;
|
||||
final int expireMessages;
|
||||
final List<Recipient> participants;
|
||||
final ProfileName profileName;
|
||||
final Optional<Integer> defaultSubscriptionId;
|
||||
final RegisteredState registered;
|
||||
final byte[] profileKey;
|
||||
final ProfileKeyCredential profileKeyCredential;
|
||||
final String profileAvatar;
|
||||
final boolean hasProfileImage;
|
||||
final boolean profileSharing;
|
||||
final long lastProfileFetch;
|
||||
final boolean systemContact;
|
||||
final boolean isSelf;
|
||||
final String notificationChannel;
|
||||
final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||
final boolean forceSmsSelection;
|
||||
final Recipient.Capability groupsV2Capability;
|
||||
final Recipient.Capability groupsV1MigrationCapability;
|
||||
final InsightsBannerTier insightsBannerTier;
|
||||
final byte[] storageId;
|
||||
final MentionSetting mentionSetting;
|
||||
final ChatWallpaper wallpaper;
|
||||
final String about;
|
||||
final String aboutEmoji;
|
||||
final ProfileName systemProfileName;
|
||||
final UUID uuid;
|
||||
final String username;
|
||||
final String e164;
|
||||
final String email;
|
||||
final GroupId groupId;
|
||||
final String groupName;
|
||||
final String systemContactName;
|
||||
final String customLabel;
|
||||
final Uri systemContactPhoto;
|
||||
final Uri contactUri;
|
||||
final Optional<Long> groupAvatarId;
|
||||
final MaterialColor color;
|
||||
final Uri messageRingtone;
|
||||
final Uri callRingtone;
|
||||
final long mutedUntil;
|
||||
final VibrateState messageVibrateState;
|
||||
final VibrateState callVibrateState;
|
||||
final boolean blocked;
|
||||
final int expireMessages;
|
||||
final List<Recipient> participants;
|
||||
final ProfileName profileName;
|
||||
final Optional<Integer> defaultSubscriptionId;
|
||||
final RegisteredState registered;
|
||||
final byte[] profileKey;
|
||||
final ProfileKeyCredential profileKeyCredential;
|
||||
final String profileAvatar;
|
||||
final boolean hasProfileImage;
|
||||
final boolean profileSharing;
|
||||
final long lastProfileFetch;
|
||||
final boolean systemContact;
|
||||
final boolean isSelf;
|
||||
final String notificationChannel;
|
||||
final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||
final boolean forceSmsSelection;
|
||||
final Recipient.Capability groupsV2Capability;
|
||||
final Recipient.Capability groupsV1MigrationCapability;
|
||||
final InsightsBannerTier insightsBannerTier;
|
||||
final byte[] storageId;
|
||||
final MentionSetting mentionSetting;
|
||||
final ChatWallpaper wallpaper;
|
||||
final String about;
|
||||
final String aboutEmoji;
|
||||
final ProfileName systemProfileName;
|
||||
final Optional<Recipient.Extras> extras;
|
||||
final boolean hasGroupsInCommon;
|
||||
|
||||
public RecipientDetails(@Nullable String groupName,
|
||||
@Nullable String systemContactName,
|
||||
@@ -122,6 +124,8 @@ public class RecipientDetails {
|
||||
this.systemProfileName = settings.getSystemProfileName();
|
||||
this.groupName = groupName;
|
||||
this.systemContactName = systemContactName;
|
||||
this.extras = Optional.fromNullable(settings.getExtras());
|
||||
this.hasGroupsInCommon = settings.hasGroupsInCommon();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +175,8 @@ public class RecipientDetails {
|
||||
this.aboutEmoji = null;
|
||||
this.systemProfileName = ProfileName.EMPTY;
|
||||
this.systemContactName = null;
|
||||
this.extras = Optional.absent();
|
||||
this.hasGroupsInCommon = false;
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientSettings settings) {
|
||||
|
||||
Reference in New Issue
Block a user