Commit 88276a4d authored by Torsten Grote's avatar Torsten Grote

Add support for private messages without text

parent f9987c89
Pipeline #2756 passed with stage
in 11 minutes and 28 seconds
......@@ -460,8 +460,8 @@ public class ConversationActivity extends BriarActivity
observeOnce(viewModel.getContactDisplayName(), this,
name -> addConversationItem(h.accept(visitor)));
} else {
// visitor also loads message text (if existing)
addConversationItem(h.accept(visitor));
loadMessageText(h.getId());
}
});
}
......@@ -535,7 +535,7 @@ public class ConversationActivity extends BriarActivity
PrivateMessageHeader h = new PrivateMessageHeader(
message.getId(), message.getGroupId(),
message.getTimestamp(), true, false, false, false,
emptyList());
true, emptyList());
textCache.put(message.getId(), text);
addConversationItem(h.accept(visitor));
} catch (DbException e) {
......
......@@ -34,9 +34,7 @@ abstract class ConversationItemViewHolder extends ViewHolder {
@CallSuper
void bind(ConversationItem item, ConversationListener listener) {
if (item.getText() == null) {
text.setText("\u2026");
} else {
if (item.getText() != null) {
text.setText(trim(item.getText()));
}
......
......@@ -52,8 +52,10 @@ class ConversationVisitor implements
item = new ConversationMessageItem(
R.layout.list_item_conversation_msg_in, h);
}
String text = textCache.getText(h.getId());
if (text != null) item.setText(text);
if (h.hasText()) {
String text = textCache.getText(h.getId());
if (text != null) item.setText(text);
}
return item;
}
......
......@@ -14,15 +14,21 @@ import javax.annotation.concurrent.Immutable;
@NotNullByDefault
public class PrivateMessageHeader extends ConversationMessageHeader {
private final boolean hasText;
private final List<AttachmentHeader> attachmentHeaders;
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
boolean local, boolean read, boolean sent, boolean seen,
List<AttachmentHeader> attachmentHeaders) {
boolean hasText, List<AttachmentHeader> attachmentHeaders) {
super(id, groupId, timestamp, local, read, sent, seen);
this.hasText = hasText;
this.attachmentHeaders = attachmentHeaders;
}
public boolean hasText() {
return hasText;
}
public List<AttachmentHeader> getAttachmentHeaders() {
return attachmentHeaders;
}
......
......@@ -122,7 +122,7 @@ class MessagingManagerImpl extends ConversationClientImpl
boolean read = meta.getBoolean(MSG_KEY_READ);
PrivateMessageHeader header =
new PrivateMessageHeader(m.getId(), groupId, timestamp, local,
read, false, false, emptyList());
read, false, false, true, emptyList());
ContactId contactId = getContactId(txn, groupId);
PrivateMessageReceivedEvent event =
new PrivateMessageReceivedEvent(header, contactId);
......@@ -217,7 +217,7 @@ class MessagingManagerImpl extends ConversationClientImpl
boolean local = meta.getBoolean("local");
boolean read = meta.getBoolean("read");
headers.add(new PrivateMessageHeader(id, g, timestamp, local,
read, s.isSent(), s.isSeen(), emptyList()));
read, s.isSent(), s.isSeen(), true, emptyList()));
} catch (FormatException e) {
throw new DbException(e);
}
......
......@@ -28,7 +28,17 @@ internal class WebSocketControllerTest : ControllerTest() {
private val controller = WebSocketControllerImpl(ImmediateExecutor())
private val header =
PrivateMessageHeader(message.id, group.id, timestamp, true, true, true, true, emptyList())
PrivateMessageHeader(
message.id,
group.id,
timestamp,
true,
true,
true,
true,
true,
emptyList()
)
private val event = PrivateMessageReceivedEvent(header, contact.id)
private val outputEvent = OutputEvent(EVENT_CONVERSATION_MESSAGE, event.output(text))
......
......@@ -50,7 +50,17 @@ internal class MessagingControllerImplTest : ControllerTest() {
)
private val header =
PrivateMessageHeader(message.id, group.id, timestamp, true, true, true, true, emptyList())
PrivateMessageHeader(
message.id,
group.id,
timestamp,
true,
true,
true,
true,
true,
emptyList()
)
private val sessionId = SessionId(getRandomId())
private val privateMessage = PrivateMessage(message)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment