Convert AttachmentTable and models to kotlin.

This commit is contained in:
Greyson Parrelli
2024-01-03 14:43:05 -05:00
committed by Alex Hart
parent 888a40a5c4
commit 3554f82ea3
62 changed files with 2626 additions and 2986 deletions

View File

@@ -37,15 +37,15 @@ public class AttachmentUtil {
}
Set<String> allowedTypes = getAllowedAutoDownloadTypes(context);
String contentType = attachment.getContentType();
String contentType = attachment.contentType;
if (attachment.isVoiceNote() ||
(MediaUtil.isAudio(attachment) && TextUtils.isEmpty(attachment.getFileName())) ||
MediaUtil.isLongTextType(attachment.getContentType()) ||
if (attachment.voiceNote ||
(MediaUtil.isAudio(attachment) && TextUtils.isEmpty(attachment.fileName)) ||
MediaUtil.isLongTextType(attachment.contentType) ||
attachment.isSticker())
{
return true;
} else if (attachment.isVideoGif()) {
} else if (attachment.videoGif) {
boolean allowed = NotInCallConstraint.isNotInConnectedCall() && allowedTypes.contains("image");
if (!allowed) {
Log.w(TAG, "Not auto downloading. inCall: " + NotInCallConstraint.isNotInConnectedCall() + " allowedType: " + allowedTypes.contains("image"));
@@ -74,8 +74,8 @@ public class AttachmentUtil {
public static void deleteAttachment(@NonNull Context context,
@NonNull DatabaseAttachment attachment)
{
AttachmentId attachmentId = attachment.getAttachmentId();
long mmsId = attachment.getMmsId();
AttachmentId attachmentId = attachment.attachmentId;
long mmsId = attachment.mmsId;
int attachmentCount = SignalDatabase.attachments()
.getAttachmentsForMessage(mmsId)
.size();
@@ -104,7 +104,7 @@ public class AttachmentUtil {
@WorkerThread
private static boolean isFromTrustedConversation(@NonNull Context context, @NonNull DatabaseAttachment attachment) {
try {
MessageRecord message = SignalDatabase.messages().getMessageRecord(attachment.getMmsId());
MessageRecord message = SignalDatabase.messages().getMessageRecord(attachment.mmsId);
Recipient fromRecipient = message.getFromRecipient();
Recipient toRecipient = SignalDatabase.threads().getRecipientForThreadId(message.getThreadId());

View File

@@ -100,7 +100,7 @@ public class MediaUtil {
return new StickerSlide(attachment);
}
switch (getSlideTypeFromContentType(attachment.getContentType())) {
switch (getSlideTypeFromContentType(attachment.contentType)) {
case GIF : return new GifSlide(attachment);
case IMAGE : return new ImageSlide(attachment);
case VIDEO : return new VideoSlide(attachment);
@@ -262,31 +262,31 @@ public class MediaUtil {
}
public static boolean isGif(Attachment attachment) {
return isGif(attachment.getContentType());
return isGif(attachment.contentType);
}
public static boolean isJpeg(Attachment attachment) {
return isJpegType(attachment.getContentType());
return isJpegType(attachment.contentType);
}
public static boolean isHeic(Attachment attachment) {
return isHeicType(attachment.getContentType());
return isHeicType(attachment.contentType);
}
public static boolean isHeif(Attachment attachment) {
return isHeifType(attachment.getContentType());
return isHeifType(attachment.contentType);
}
public static boolean isImage(Attachment attachment) {
return isImageType(attachment.getContentType());
return isImageType(attachment.contentType);
}
public static boolean isAudio(Attachment attachment) {
return isAudioType(attachment.getContentType());
return isAudioType(attachment.contentType);
}
public static boolean isVideo(Attachment attachment) {
return isVideoType(attachment.getContentType());
return isVideoType(attachment.contentType);
}
public static boolean isVideo(String contentType) {
@@ -473,7 +473,7 @@ public class MediaUtil {
}
final Attachment attachment = slide.asAttachment();
final boolean isIncremental = attachment.getIncrementalDigest() != null;
final boolean hasIncrementalMacChunkSizeDefined = attachment.getIncrementalMacChunkSize() > 0;
final boolean hasIncrementalMacChunkSizeDefined = attachment.incrementalMacChunkSize > 0;
final boolean contentTypeSupported = isVideoType(slide.getContentType());
return isIncremental && contentTypeSupported && hasIncrementalMacChunkSizeDefined;
}