Remove concept of 'unknown' recipient.
This commit is contained in:
parent
89c2329fdf
commit
9447ea12cb
6 changed files with 7 additions and 19 deletions
|
@ -73,7 +73,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
||||||
|
|
||||||
if (type == ContactRepository.NEW_TYPE) {
|
if (type == ContactRepository.NEW_TYPE) {
|
||||||
this.recipient = null;
|
this.recipient = null;
|
||||||
this.contactPhotoImage.setAvatar(glideRequests, Recipient.UNKNOWN, false);
|
this.contactPhotoImage.setAvatar(glideRequests, null, false);
|
||||||
} else if (recipientId != null) {
|
} else if (recipientId != null) {
|
||||||
this.recipient = Recipient.live(recipientId);
|
this.recipient = Recipient.live(recipientId);
|
||||||
this.recipient.observeForever(this);
|
this.recipient.observeForever(this);
|
||||||
|
|
|
@ -1542,7 +1542,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||||
List<? extends Attachment> quoteAttachments = Stream.of(attachments).filter(Attachment::isQuote).toList();
|
List<? extends Attachment> quoteAttachments = Stream.of(attachments).filter(Attachment::isQuote).toList();
|
||||||
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
|
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
|
||||||
|
|
||||||
if (quoteId > 0 && !quoteAuthor.isUnknown()) {
|
if (quoteId > 0) {
|
||||||
return new Quote(quoteId, quoteAuthor, quoteText, quoteMissing, quoteDeck);
|
return new Quote(quoteId, quoteAuthor, quoteText, quoteMissing, quoteDeck);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -189,14 +189,12 @@ public class MmsDownloadJob extends BaseJob {
|
||||||
String body = null;
|
String body = null;
|
||||||
List<Attachment> attachments = new LinkedList<>();
|
List<Attachment> attachments = new LinkedList<>();
|
||||||
|
|
||||||
RecipientId from;
|
RecipientId from = null;
|
||||||
|
|
||||||
if (retrieved.getFrom() != null) {
|
if (retrieved.getFrom() != null) {
|
||||||
from = Recipient.external(context, Util.toIsoString(retrieved.getFrom().getTextString())).getId();
|
from = Recipient.external(context, Util.toIsoString(retrieved.getFrom().getTextString())).getId();
|
||||||
} else if (notificationFrom != null) {
|
} else if (notificationFrom != null) {
|
||||||
from = notificationFrom;
|
from = notificationFrom;
|
||||||
} else {
|
|
||||||
from = RecipientId.UNKNOWN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retrieved.getTo() != null) {
|
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());
|
members.add(Recipient.self().getId());
|
||||||
|
|
||||||
if (retrieved.getBody() != null) {
|
if (retrieved.getBody() != null) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ public final class LiveRecipientCache {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final RecipientDatabase recipientDatabase;
|
private final RecipientDatabase recipientDatabase;
|
||||||
private final Map<RecipientId, LiveRecipient> recipients;
|
private final Map<RecipientId, LiveRecipient> recipients;
|
||||||
private final LiveRecipient unknown;
|
|
||||||
|
|
||||||
private RecipientId localRecipientId;
|
private RecipientId localRecipientId;
|
||||||
|
|
||||||
|
@ -32,13 +31,10 @@ public final class LiveRecipientCache {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
this.recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
|
this.recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
|
||||||
this.recipients = new LRUCache<>(1000);
|
this.recipients = new LRUCache<>(1000);
|
||||||
this.unknown = new LiveRecipient(context, new MutableLiveData<>(), Recipient.UNKNOWN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AnyThread
|
@AnyThread
|
||||||
synchronized @NonNull LiveRecipient getLive(@NonNull RecipientId id) {
|
synchronized @NonNull LiveRecipient getLive(@NonNull RecipientId id) {
|
||||||
if (id.isUnknown()) return unknown;
|
|
||||||
|
|
||||||
LiveRecipient live = recipients.get(id);
|
LiveRecipient live = recipients.get(id);
|
||||||
|
|
||||||
if (live == null) {
|
if (live == null) {
|
||||||
|
|
|
@ -44,8 +44,6 @@ import java.util.Objects;
|
||||||
|
|
||||||
public class Recipient {
|
public class Recipient {
|
||||||
|
|
||||||
public static final Recipient UNKNOWN = new Recipient(RecipientId.UNKNOWN);
|
|
||||||
|
|
||||||
private final RecipientId id;
|
private final RecipientId id;
|
||||||
private final boolean resolving;
|
private final boolean resolving;
|
||||||
private final Address address;
|
private final Address address;
|
||||||
|
|
|
@ -15,11 +15,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
||||||
|
|
||||||
private static final long UNKNOWN_ID = -1;
|
|
||||||
private static final char DELIMITER = ',';
|
private static final char DELIMITER = ',';
|
||||||
|
|
||||||
public static final RecipientId UNKNOWN = RecipientId.from(UNKNOWN_ID);
|
|
||||||
|
|
||||||
private final long id;
|
private final long id;
|
||||||
|
|
||||||
public static RecipientId from(long id) {
|
public static RecipientId from(long id) {
|
||||||
|
@ -54,10 +51,6 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnknown() {
|
|
||||||
return id == UNKNOWN_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull String serialize() {
|
public @NonNull String serialize() {
|
||||||
return String.valueOf(id);
|
return String.valueOf(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue