Fix crash when showing a message with a button without media.

This commit is contained in:
Cody Henthorne 2022-11-14 17:04:10 -05:00 committed by Alex Hart
parent b2f3867b0b
commit 52a5fb8ea2
2 changed files with 9 additions and 2 deletions

View file

@ -178,9 +178,9 @@ public class ConversationAdapter
} else if (messageRecord.isUpdate()) {
return MESSAGE_TYPE_UPDATE;
} else if (messageRecord.isOutgoing()) {
return MessageRecordUtil.isTextOnly(messageRecord, context) && !conversationMessage.hasBeenQuoted() ? MESSAGE_TYPE_OUTGOING_TEXT : MESSAGE_TYPE_OUTGOING_MULTIMEDIA;
return conversationMessage.isTextOnly(context) ? MESSAGE_TYPE_OUTGOING_TEXT : MESSAGE_TYPE_OUTGOING_MULTIMEDIA;
} else {
return MessageRecordUtil.isTextOnly(messageRecord, context) && !conversationMessage.hasBeenQuoted() ? MESSAGE_TYPE_INCOMING_TEXT : MESSAGE_TYPE_INCOMING_MULTIMEDIA;
return conversationMessage.isTextOnly(context) ? MESSAGE_TYPE_INCOMING_TEXT : MESSAGE_TYPE_INCOMING_MULTIMEDIA;
}
}

View file

@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.database.model.Mention;
import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList;
import org.thoughtcrime.securesms.util.MessageRecordUtil;
import java.security.MessageDigest;
import java.util.Collections;
@ -120,6 +121,12 @@ public class ConversationMessage {
return styleResult.getBottomButton();
}
public boolean isTextOnly(@NonNull Context context) {
return MessageRecordUtil.isTextOnly(messageRecord, context) &&
!hasBeenQuoted() &&
getBottomButton() == null;
}
/**
* Factory providing multiple ways of creating {@link ConversationMessage}s.
*/