Remove concept of 'unknown' recipient.

master
Greyson Parrelli 2019-10-08 13:33:13 -07:00
parent 89c2329fdf
commit 9447ea12cb
6 changed files with 7 additions and 19 deletions

View File

@ -73,7 +73,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
if (type == ContactRepository.NEW_TYPE) {
this.recipient = null;
this.contactPhotoImage.setAvatar(glideRequests, Recipient.UNKNOWN, false);
this.contactPhotoImage.setAvatar(glideRequests, null, false);
} else if (recipientId != null) {
this.recipient = Recipient.live(recipientId);
this.recipient.observeForever(this);

View File

@ -1542,7 +1542,7 @@ public class MmsDatabase extends MessagingDatabase {
List<? extends Attachment> quoteAttachments = Stream.of(attachments).filter(Attachment::isQuote).toList();
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
if (quoteId > 0 && !quoteAuthor.isUnknown()) {
if (quoteId > 0) {
return new Quote(quoteId, quoteAuthor, quoteText, quoteMissing, quoteDeck);
} else {
return null;

View File

@ -189,14 +189,12 @@ public class MmsDownloadJob extends BaseJob {
String body = null;
List<Attachment> attachments = new LinkedList<>();
RecipientId from;
RecipientId from = null;
if (retrieved.getFrom() != null) {
from = Recipient.external(context, Util.toIsoString(retrieved.getFrom().getTextString())).getId();
} else if (notificationFrom != null) {
from = notificationFrom;
} else {
from = RecipientId.UNKNOWN;
}
if (retrieved.getTo() != null) {
@ -211,7 +209,10 @@ public class MmsDownloadJob extends BaseJob {
}
}
members.add(from);
if (from != null) {
members.add(from);
}
members.add(Recipient.self().getId());
if (retrieved.getBody() != null) {

View File

@ -23,7 +23,6 @@ public final class LiveRecipientCache {
private final Context context;
private final RecipientDatabase recipientDatabase;
private final Map<RecipientId, LiveRecipient> recipients;
private final LiveRecipient unknown;
private RecipientId localRecipientId;
@ -32,13 +31,10 @@ public final class LiveRecipientCache {
this.context = context.getApplicationContext();
this.recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
this.recipients = new LRUCache<>(1000);
this.unknown = new LiveRecipient(context, new MutableLiveData<>(), Recipient.UNKNOWN);
}
@AnyThread
synchronized @NonNull LiveRecipient getLive(@NonNull RecipientId id) {
if (id.isUnknown()) return unknown;
LiveRecipient live = recipients.get(id);
if (live == null) {

View File

@ -44,8 +44,6 @@ import java.util.Objects;
public class Recipient {
public static final Recipient UNKNOWN = new Recipient(RecipientId.UNKNOWN);
private final RecipientId id;
private final boolean resolving;
private final Address address;

View File

@ -15,11 +15,8 @@ import java.util.List;
public class RecipientId implements Parcelable, Comparable<RecipientId> {
private static final long UNKNOWN_ID = -1;
private static final char DELIMITER = ',';
public static final RecipientId UNKNOWN = RecipientId.from(UNKNOWN_ID);
private final long id;
public static RecipientId from(long id) {
@ -54,10 +51,6 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
return out;
}
public boolean isUnknown() {
return id == UNKNOWN_ID;
}
public @NonNull String serialize() {
return String.valueOf(id);
}