mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Convert AttachmentTable and models to kotlin.
This commit is contained in:
committed by
Alex Hart
parent
888a40a5c4
commit
3554f82ea3
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2316,7 +2316,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
val quoteText = cursor.requireString(QUOTE_BODY)
|
||||
val quoteType = cursor.requireInt(QUOTE_TYPE)
|
||||
val quoteMissing = cursor.requireBoolean(QUOTE_MISSING)
|
||||
val quoteAttachments: List<Attachment> = associatedAttachments.filter { it.isQuote }.toList()
|
||||
val quoteAttachments: List<Attachment> = associatedAttachments.filter { it.quote }.toList()
|
||||
val quoteMentions: List<Mention> = parseQuoteMentions(cursor)
|
||||
val quoteBodyRanges: BodyRangeList? = parseQuoteBodyRanges(cursor)
|
||||
val quote: QuoteModel? = if (quoteId != QUOTE_NOT_PRESENT_ID && quoteAuthor > 0 && (!TextUtils.isEmpty(quoteText) || quoteAttachments.isNotEmpty())) {
|
||||
@@ -2330,7 +2330,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
val previews: List<LinkPreview> = getLinkPreviews(cursor, associatedAttachments)
|
||||
val previewAttachments: Set<Attachment> = previews.filter { it.thumbnail.isPresent }.map { it.thumbnail.get() }.toSet()
|
||||
val attachments: List<Attachment> = associatedAttachments
|
||||
.filterNot { it.isQuote }
|
||||
.filterNot { it.quote }
|
||||
.filterNot { contactAttachments.contains(it) }
|
||||
.filterNot { previewAttachments.contains(it) }
|
||||
.sortedWith(DisplayOrderComparator())
|
||||
@@ -5119,7 +5119,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
val bodyRanges = parseQuoteBodyRanges(cursor)
|
||||
|
||||
val attachments = attachments.getAttachments(cursor)
|
||||
val quoteAttachments: List<Attachment> = attachments.filter { it.isQuote }
|
||||
val quoteAttachments: List<Attachment> = attachments.filter { it.quote }
|
||||
val quoteDeck = SlideDeck(quoteAttachments)
|
||||
|
||||
return if (quoteId != QUOTE_NOT_PRESENT_ID && quoteAuthor > 0) {
|
||||
@@ -5170,7 +5170,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
@JvmStatic
|
||||
fun buildSlideDeck(attachments: List<DatabaseAttachment>): SlideDeck {
|
||||
val messageAttachments = attachments
|
||||
.filterNot { it.isQuote }
|
||||
.filterNot { it.quote }
|
||||
.sortedWith(DisplayOrderComparator())
|
||||
|
||||
return SlideDeck(messageAttachments)
|
||||
|
||||
@@ -182,7 +182,7 @@ public final class GroupedThreadMediaLoader extends AsyncTaskLoader<GroupedThrea
|
||||
|
||||
@Override
|
||||
public int groupForRecord(@NonNull MediaTable.MediaRecord mediaRecord) {
|
||||
long size = mediaRecord.getAttachment().getSize();
|
||||
long size = mediaRecord.getAttachment().size;
|
||||
|
||||
if (size < MB) return SMALL;
|
||||
if (size < 20 * MB) return MEDIUM;
|
||||
|
||||
@@ -294,7 +294,7 @@ public class MmsMessageRecord extends MessageRecord {
|
||||
public @NonNull MmsMessageRecord withAttachments(@NonNull List<DatabaseAttachment> attachments) {
|
||||
Map<AttachmentId, DatabaseAttachment> attachmentIdMap = new HashMap<>();
|
||||
for (DatabaseAttachment attachment : attachments) {
|
||||
attachmentIdMap.put(attachment.getAttachmentId(), attachment);
|
||||
attachmentIdMap.put(attachment.attachmentId, attachment);
|
||||
}
|
||||
|
||||
List<Contact> contacts = updateContacts(getSharedContacts(), attachmentIdMap);
|
||||
@@ -369,7 +369,7 @@ public class MmsMessageRecord extends MessageRecord {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<DatabaseAttachment> quoteAttachments = attachments.stream().filter(Attachment::isQuote).collect(Collectors.toList());
|
||||
List<DatabaseAttachment> quoteAttachments = attachments.stream().filter(a -> a.quote).collect(Collectors.toList());
|
||||
|
||||
return quote.withAttachment(new SlideDeck(quoteAttachments));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user