mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Add GroupId to conversation items
This commit is contained in:
@@ -681,11 +681,10 @@ public class ConversationActivity extends BriarActivity
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Storing message took " + duration + " ms");
|
||||
|
||||
MessageId id = m.getMessage().getId();
|
||||
PrivateMessageHeader h = new PrivateMessageHeader(id,
|
||||
m.getMessage().getTimestamp(), m.getContentType(),
|
||||
true, false, false, false);
|
||||
groupId, m.getMessage().getTimestamp(),
|
||||
m.getContentType(), true, false, false, false);
|
||||
ConversationMessageItem item = ConversationItem.from(h);
|
||||
item.setBody(body);
|
||||
bodyCache.put(id, body);
|
||||
|
||||
@@ -9,7 +9,7 @@ abstract class ConversationIntroductionItem extends ConversationItem {
|
||||
private boolean answered;
|
||||
|
||||
ConversationIntroductionItem(IntroductionRequest ir) {
|
||||
super(ir.getMessageId(), ir.getTimestamp());
|
||||
super(ir.getMessageId(), ir.getGroupId(), ir.getTimestamp());
|
||||
|
||||
this.ir = ir;
|
||||
this.answered = ir.wasAnswered();
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.api.sharing.InvitationMessage;
|
||||
import org.briarproject.api.sharing.InvitationRequest;
|
||||
import org.briarproject.api.sharing.InvitationResponse;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
// This class is not thread-safe
|
||||
@@ -31,10 +32,12 @@ public abstract class ConversationItem {
|
||||
final static int BLOG_INVITATION_OUT = 10;
|
||||
|
||||
private MessageId id;
|
||||
private GroupId groupId;
|
||||
private long time;
|
||||
|
||||
public ConversationItem(MessageId id, long time) {
|
||||
public ConversationItem(MessageId id, GroupId groupId, long time) {
|
||||
this.id = id;
|
||||
this.groupId = groupId;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@@ -44,6 +47,10 @@ public abstract class ConversationItem {
|
||||
return id;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
long getTime() {
|
||||
return time;
|
||||
}
|
||||
@@ -78,8 +85,9 @@ public abstract class ConversationItem {
|
||||
R.string.introduction_response_declined_sent,
|
||||
ir.getName());
|
||||
}
|
||||
return new ConversationNoticeOutItem(ir.getMessageId(), text,
|
||||
ir.getTimestamp(), ir.isSent(), ir.isSeen());
|
||||
return new ConversationNoticeOutItem(ir.getMessageId(),
|
||||
ir.getGroupId(), text, ir.getTimestamp(), ir.isSent(),
|
||||
ir.isSeen());
|
||||
} else {
|
||||
String text;
|
||||
if (ir.wasAccepted()) {
|
||||
@@ -97,8 +105,8 @@ public abstract class ConversationItem {
|
||||
contactName, ir.getName());
|
||||
}
|
||||
}
|
||||
return new ConversationNoticeInItem(ir.getMessageId(), text,
|
||||
ir.getTimestamp(), ir.isRead());
|
||||
return new ConversationNoticeInItem(ir.getMessageId(),
|
||||
ir.getGroupId(), text, ir.getTimestamp(), ir.isRead());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +145,8 @@ public abstract class ConversationItem {
|
||||
R.string.forum_invitation_response_declined_sent,
|
||||
contactName);
|
||||
}
|
||||
return new ConversationNoticeOutItem(fir.getId(), text,
|
||||
fir.getTimestamp(), fir.isSent(), fir.isSeen());
|
||||
return new ConversationNoticeOutItem(fir.getId(), fir.getGroupId(),
|
||||
text, fir.getTimestamp(), fir.isSent(), fir.isSeen());
|
||||
} else {
|
||||
String text;
|
||||
if (fir.wasAccepted()) {
|
||||
@@ -150,8 +158,8 @@ public abstract class ConversationItem {
|
||||
R.string.forum_invitation_response_declined_received,
|
||||
contactName);
|
||||
}
|
||||
return new ConversationNoticeInItem(fir.getId(), text,
|
||||
fir.getTimestamp(), fir.isRead());
|
||||
return new ConversationNoticeInItem(fir.getId(), fir.getGroupId(),
|
||||
text, fir.getTimestamp(), fir.isRead());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +177,8 @@ public abstract class ConversationItem {
|
||||
R.string.blogs_sharing_response_declined_sent,
|
||||
contactName);
|
||||
}
|
||||
return new ConversationNoticeOutItem(fir.getId(), text,
|
||||
fir.getTimestamp(), fir.isSent(), fir.isSeen());
|
||||
return new ConversationNoticeOutItem(fir.getId(), fir.getGroupId(),
|
||||
text, fir.getTimestamp(), fir.isSent(), fir.isSeen());
|
||||
} else {
|
||||
String text;
|
||||
if (fir.wasAccepted()) {
|
||||
@@ -182,8 +190,8 @@ public abstract class ConversationItem {
|
||||
R.string.blogs_sharing_response_declined_received,
|
||||
contactName);
|
||||
}
|
||||
return new ConversationNoticeInItem(fir.getId(), text,
|
||||
fir.getTimestamp(), fir.isRead());
|
||||
return new ConversationNoticeInItem(fir.getId(), fir.getGroupId(),
|
||||
text, fir.getTimestamp(), fir.isRead());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,10 +201,10 @@ public abstract class ConversationItem {
|
||||
*/
|
||||
public static ConversationItem from(IntroductionMessage im) {
|
||||
if (im.isLocal())
|
||||
return new ConversationNoticeOutItem(im.getMessageId(), "",
|
||||
im.getTimestamp(), false, false);
|
||||
return new ConversationNoticeInItem(im.getMessageId(), "",
|
||||
im.getTimestamp(), im.isRead());
|
||||
return new ConversationNoticeOutItem(im.getMessageId(),
|
||||
im.getGroupId(), "", im.getTimestamp(), false, false);
|
||||
return new ConversationNoticeInItem(im.getMessageId(), im.getGroupId(),
|
||||
"", im.getTimestamp(), im.isRead());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,9 +213,9 @@ public abstract class ConversationItem {
|
||||
*/
|
||||
public static ConversationItem from(InvitationMessage im) {
|
||||
if (im.isLocal())
|
||||
return new ConversationNoticeOutItem(im.getId(), "",
|
||||
im.getTimestamp(), false, false);
|
||||
return new ConversationNoticeInItem(im.getId(), "",
|
||||
return new ConversationNoticeOutItem(im.getId(), im.getGroupId(),
|
||||
"", im.getTimestamp(), false, false);
|
||||
return new ConversationNoticeInItem(im.getId(), im.getGroupId(), "",
|
||||
im.getTimestamp(), im.isRead());
|
||||
}
|
||||
|
||||
@@ -228,6 +236,8 @@ public abstract class ConversationItem {
|
||||
|
||||
MessageId getId();
|
||||
|
||||
GroupId getGroupId();
|
||||
|
||||
boolean isRead();
|
||||
|
||||
void setRead(boolean read);
|
||||
|
||||
@@ -9,7 +9,7 @@ abstract class ConversationMessageItem extends ConversationItem {
|
||||
private byte[] body;
|
||||
|
||||
ConversationMessageItem(PrivateMessageHeader header) {
|
||||
super(header.getId(), header.getTimestamp());
|
||||
super(header.getId(), header.getGroupId(), header.getTimestamp());
|
||||
|
||||
this.header = header;
|
||||
body = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
// This class is not thread-safe
|
||||
@@ -8,9 +9,9 @@ class ConversationNoticeInItem extends ConversationNoticeItem
|
||||
|
||||
private boolean read;
|
||||
|
||||
ConversationNoticeInItem(MessageId id, String text, long time,
|
||||
boolean read) {
|
||||
super(id, text, time);
|
||||
ConversationNoticeInItem(MessageId id, GroupId groupId, String text,
|
||||
long time, boolean read) {
|
||||
super(id, groupId, text, time);
|
||||
|
||||
this.read = read;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
abstract class ConversationNoticeItem extends ConversationItem {
|
||||
|
||||
private final String text;
|
||||
|
||||
ConversationNoticeItem(MessageId id, String text, long time) {
|
||||
super(id, time);
|
||||
ConversationNoticeItem(MessageId id, GroupId groupId, String text,
|
||||
long time) {
|
||||
super(id, groupId, time);
|
||||
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
// This class is not thread-safe
|
||||
@@ -8,9 +9,9 @@ class ConversationNoticeOutItem extends ConversationNoticeItem
|
||||
|
||||
private boolean sent, seen;
|
||||
|
||||
ConversationNoticeOutItem(MessageId id, String text, long time,
|
||||
boolean sent, boolean seen) {
|
||||
super(id, text, time);
|
||||
ConversationNoticeOutItem(MessageId id, GroupId groupId, String text,
|
||||
long time, boolean sent, boolean seen) {
|
||||
super(id, groupId, text, time);
|
||||
|
||||
this.sent = sent;
|
||||
this.seen = seen;
|
||||
|
||||
@@ -7,7 +7,7 @@ abstract class ConversationShareableInvitationItem extends ConversationItem {
|
||||
private final InvitationRequest fim;
|
||||
|
||||
ConversationShareableInvitationItem(InvitationRequest fim) {
|
||||
super(fim.getId(), fim.getTimestamp());
|
||||
super(fim.getId(), fim.getGroupId(), fim.getTimestamp());
|
||||
|
||||
this.fim = fim;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user