mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 06:39:54 +01:00
Add support for private messages without text
This commit is contained in:
@@ -460,8 +460,8 @@ public class ConversationActivity extends BriarActivity
|
|||||||
observeOnce(viewModel.getContactDisplayName(), this,
|
observeOnce(viewModel.getContactDisplayName(), this,
|
||||||
name -> addConversationItem(h.accept(visitor)));
|
name -> addConversationItem(h.accept(visitor)));
|
||||||
} else {
|
} else {
|
||||||
|
// visitor also loads message text (if existing)
|
||||||
addConversationItem(h.accept(visitor));
|
addConversationItem(h.accept(visitor));
|
||||||
loadMessageText(h.getId());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -535,7 +535,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
PrivateMessageHeader h = new PrivateMessageHeader(
|
PrivateMessageHeader h = new PrivateMessageHeader(
|
||||||
message.getId(), message.getGroupId(),
|
message.getId(), message.getGroupId(),
|
||||||
message.getTimestamp(), true, false, false, false,
|
message.getTimestamp(), true, false, false, false,
|
||||||
emptyList());
|
true, emptyList());
|
||||||
textCache.put(message.getId(), text);
|
textCache.put(message.getId(), text);
|
||||||
addConversationItem(h.accept(visitor));
|
addConversationItem(h.accept(visitor));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ abstract class ConversationItemViewHolder extends ViewHolder {
|
|||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
void bind(ConversationItem item, ConversationListener listener) {
|
void bind(ConversationItem item, ConversationListener listener) {
|
||||||
if (item.getText() == null) {
|
if (item.getText() != null) {
|
||||||
text.setText("\u2026");
|
|
||||||
} else {
|
|
||||||
text.setText(trim(item.getText()));
|
text.setText(trim(item.getText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,10 @@ class ConversationVisitor implements
|
|||||||
item = new ConversationMessageItem(
|
item = new ConversationMessageItem(
|
||||||
R.layout.list_item_conversation_msg_in, h);
|
R.layout.list_item_conversation_msg_in, h);
|
||||||
}
|
}
|
||||||
String text = textCache.getText(h.getId());
|
if (h.hasText()) {
|
||||||
if (text != null) item.setText(text);
|
String text = textCache.getText(h.getId());
|
||||||
|
if (text != null) item.setText(text);
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,21 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class PrivateMessageHeader extends ConversationMessageHeader {
|
public class PrivateMessageHeader extends ConversationMessageHeader {
|
||||||
|
|
||||||
|
private final boolean hasText;
|
||||||
private final List<AttachmentHeader> attachmentHeaders;
|
private final List<AttachmentHeader> attachmentHeaders;
|
||||||
|
|
||||||
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
||||||
boolean local, boolean read, boolean sent, boolean seen,
|
boolean local, boolean read, boolean sent, boolean seen,
|
||||||
List<AttachmentHeader> attachmentHeaders) {
|
boolean hasText, List<AttachmentHeader> attachmentHeaders) {
|
||||||
super(id, groupId, timestamp, local, read, sent, seen);
|
super(id, groupId, timestamp, local, read, sent, seen);
|
||||||
|
this.hasText = hasText;
|
||||||
this.attachmentHeaders = attachmentHeaders;
|
this.attachmentHeaders = attachmentHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasText() {
|
||||||
|
return hasText;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AttachmentHeader> getAttachmentHeaders() {
|
public List<AttachmentHeader> getAttachmentHeaders() {
|
||||||
return attachmentHeaders;
|
return attachmentHeaders;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
boolean read = meta.getBoolean(MSG_KEY_READ);
|
boolean read = meta.getBoolean(MSG_KEY_READ);
|
||||||
PrivateMessageHeader header =
|
PrivateMessageHeader header =
|
||||||
new PrivateMessageHeader(m.getId(), groupId, timestamp, local,
|
new PrivateMessageHeader(m.getId(), groupId, timestamp, local,
|
||||||
read, false, false, emptyList());
|
read, false, false, true, emptyList());
|
||||||
ContactId contactId = getContactId(txn, groupId);
|
ContactId contactId = getContactId(txn, groupId);
|
||||||
PrivateMessageReceivedEvent event =
|
PrivateMessageReceivedEvent event =
|
||||||
new PrivateMessageReceivedEvent(header, contactId);
|
new PrivateMessageReceivedEvent(header, contactId);
|
||||||
@@ -217,7 +217,7 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
boolean local = meta.getBoolean("local");
|
boolean local = meta.getBoolean("local");
|
||||||
boolean read = meta.getBoolean("read");
|
boolean read = meta.getBoolean("read");
|
||||||
headers.add(new PrivateMessageHeader(id, g, timestamp, local,
|
headers.add(new PrivateMessageHeader(id, g, timestamp, local,
|
||||||
read, s.isSent(), s.isSeen(), emptyList()));
|
read, s.isSent(), s.isSeen(), true, emptyList()));
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,17 @@ internal class WebSocketControllerTest : ControllerTest() {
|
|||||||
private val controller = WebSocketControllerImpl(ImmediateExecutor())
|
private val controller = WebSocketControllerImpl(ImmediateExecutor())
|
||||||
|
|
||||||
private val header =
|
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 event = PrivateMessageReceivedEvent(header, contact.id)
|
||||||
private val outputEvent = OutputEvent(EVENT_CONVERSATION_MESSAGE, event.output(text))
|
private val outputEvent = OutputEvent(EVENT_CONVERSATION_MESSAGE, event.output(text))
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,17 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val header =
|
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 sessionId = SessionId(getRandomId())
|
||||||
private val privateMessage = PrivateMessage(message)
|
private val privateMessage = PrivateMessage(message)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user