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

pull/1709/head
ThomasSession 2 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
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>)

@ -106,11 +106,8 @@ class QuoteView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
attachments.audioSlide != null -> {
binding.quoteViewAttachmentPreviewImageView.setImageResource(R.drawable.ic_microphone)
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 attachment = attachments.asAttachments().firstOrNull()
val isVoiceNote = attachment?.isVoiceNote == true ||
attachment != null && attachment.fileName.isNullOrEmpty()
val isVoiceNote = attachments.isVoiceNote
binding.quoteViewBodyTextView.text = if (isVoiceNote) {
resources.getString(R.string.messageVoice)
} else {

@ -48,7 +48,7 @@ abstract class Slide(@JvmField protected val context: Context, protected val att
if (MediaUtil.isAudio(attachment)) {
// A missing file name is the legacy way to determine if an audio attachment is
// 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)
.put(EMOJI_KEY, "🎙")
.format().toString()

@ -17,17 +17,12 @@
package org.thoughtcrime.securesms.mms;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.annimon.stream.Stream;
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
import org.session.libsignal.utilities.Log;
import org.session.libsignal.utilities.guava.Optional;
import org.thoughtcrime.securesms.util.MediaUtil;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
@ -152,4 +147,15 @@ public class SlideDeck {
public int hashCode() {
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() {
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() {

Loading…
Cancel
Save