Making sure we get all attachments except voice notes (#940)

pull/1709/head
ThomasSession 3 months ago committed by GitHub
parent 17fcd5ea57
commit 1b2eb4c2f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -214,7 +214,7 @@ class ConfigToDatabaseSync @Inject constructor(
} }
private val MmsMessageRecord.containsAttachment: Boolean private val MmsMessageRecord.containsAttachment: Boolean
get() = this.slideDeck.slides.isNotEmpty() && this.slideDeck.audioSlide == null get() = this.slideDeck.slides.isNotEmpty() && !this.slideDeck.isVoiceNote
private data class UpdateContacts(val contacts: List<Contact>) private data class UpdateContacts(val contacts: List<Contact>)

@ -106,11 +106,8 @@ class QuoteView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
attachments.audioSlide != null -> { attachments.audioSlide != null -> {
binding.quoteViewAttachmentPreviewImageView.setImageResource(R.drawable.ic_microphone) binding.quoteViewAttachmentPreviewImageView.setImageResource(R.drawable.ic_microphone)
binding.quoteViewAttachmentPreviewImageView.isVisible = true binding.quoteViewAttachmentPreviewImageView.isVisible = true
// A missing file name is the legacy way to determine if an audio attachment is
// a voice note vs. other arbitrary audio attachments. val isVoiceNote = attachments.isVoiceNote
val attachment = attachments.asAttachments().firstOrNull()
val isVoiceNote = attachment?.isVoiceNote == true ||
attachment != null && attachment.fileName.isNullOrEmpty()
binding.quoteViewBodyTextView.text = if (isVoiceNote) { binding.quoteViewBodyTextView.text = if (isVoiceNote) {
resources.getString(R.string.messageVoice) resources.getString(R.string.messageVoice)
} else { } else {

@ -48,7 +48,7 @@ abstract class Slide(@JvmField protected val context: Context, protected val att
if (MediaUtil.isAudio(attachment)) { if (MediaUtil.isAudio(attachment)) {
// A missing file name is the legacy way to determine if an audio attachment is // A missing file name is the legacy way to determine if an audio attachment is
// a voice note vs. other arbitrary audio attachments. // a voice note vs. other arbitrary audio attachments.
if (attachment.isVoiceNote || attachment.fileName.isNullOrEmpty()) { if (attachment.isVoiceNote) {
val voiceTxt = Phrase.from(context, R.string.messageVoiceSnippet) val voiceTxt = Phrase.from(context, R.string.messageVoiceSnippet)
.put(EMOJI_KEY, "🎙") .put(EMOJI_KEY, "🎙")
.format().toString() .format().toString()

@ -17,17 +17,12 @@
package org.thoughtcrime.securesms.mms; package org.thoughtcrime.securesms.mms;
import android.content.Context; import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import org.session.libsession.messaging.sending_receiving.attachments.Attachment; import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
import org.session.libsignal.utilities.Log;
import org.session.libsignal.utilities.guava.Optional; import org.session.libsignal.utilities.guava.Optional;
import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.MediaUtil;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -152,4 +147,15 @@ public class SlideDeck {
public int hashCode() { public int hashCode() {
return Objects.hash(slides); return Objects.hash(slides);
} }
public boolean isVoiceNote() {
List<Attachment> attachments = asAttachments();
if (attachments.isEmpty()) {
return false;
}
Attachment attachment = attachments.get(0);
return attachment.isVoiceNote();
}
} }

@ -120,7 +120,9 @@ public abstract class Attachment {
} }
public boolean isVoiceNote() { public boolean isVoiceNote() {
return voiceNote; // A missing file name is the legacy way to determine if an audio attachment is
// a voice note vs. other arbitrary audio attachments.
return voiceNote || getFileName() == null || getFileName().isEmpty();
} }
public int getWidth() { public int getWidth() {

Loading…
Cancel
Save