mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Address review comments
This commit is contained in:
@@ -28,7 +28,7 @@ import org.briarproject.api.event.ForumPostReceivedEvent;
|
||||
import org.briarproject.api.event.IntroductionRequestReceivedEvent;
|
||||
import org.briarproject.api.event.IntroductionResponseReceivedEvent;
|
||||
import org.briarproject.api.event.IntroductionSucceededEvent;
|
||||
import org.briarproject.api.event.InvitationReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationRequestReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationResponseReceivedEvent;
|
||||
import org.briarproject.api.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.api.event.SettingsUpdatedEvent;
|
||||
@@ -235,8 +235,8 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
||||
} else if (e instanceof IntroductionResponseReceivedEvent) {
|
||||
ContactId c = ((IntroductionResponseReceivedEvent) e).getContactId();
|
||||
showNotificationForPrivateConversation(c);
|
||||
} else if (e instanceof InvitationReceivedEvent) {
|
||||
ContactId c = ((InvitationReceivedEvent) e).getContactId();
|
||||
} else if (e instanceof InvitationRequestReceivedEvent) {
|
||||
ContactId c = ((InvitationRequestReceivedEvent) e).getContactId();
|
||||
showNotificationForPrivateConversation(c);
|
||||
} else if (e instanceof InvitationResponseReceivedEvent) {
|
||||
ContactId c = ((InvitationResponseReceivedEvent) e).getContactId();
|
||||
|
||||
@@ -50,10 +50,8 @@ public abstract class BaseContactListAdapter<VH extends BaseContactListAdapter.B
|
||||
}
|
||||
});
|
||||
|
||||
if (item.getGroupId() != null) {
|
||||
ViewCompat.setTransitionName(ui.avatar, "avatar" +
|
||||
StringUtils.toHexString(item.getGroupId().getBytes()));
|
||||
}
|
||||
ViewCompat.setTransitionName(ui.avatar, "avatar" +
|
||||
StringUtils.toHexString(item.getGroupId().getBytes()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,8 +94,7 @@ public abstract class BaseContactListAdapter<VH extends BaseContactListAdapter.B
|
||||
int count = getItemCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
ContactListItem item = getItemAt(i);
|
||||
if (item != null && item.getGroupId() != null &&
|
||||
item.getGroupId().equals(g)) {
|
||||
if (item != null && item.getGroupId().equals(g)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ContactListAdapter
|
||||
if (item == null) return;
|
||||
|
||||
// unread count
|
||||
long unread = item.getUnreadCount();
|
||||
int unread = item.getUnreadCount();
|
||||
if (unread > 0) {
|
||||
ui.unread.setText(String.valueOf(unread));
|
||||
ui.unread.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.IntroductionRequestReceivedEvent;
|
||||
import org.briarproject.api.event.IntroductionResponseReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationRequestReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationResponseReceivedEvent;
|
||||
import org.briarproject.api.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
@@ -121,7 +121,6 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
||||
@Override
|
||||
public void onItemClick(View view, ContactListItem item) {
|
||||
GroupId groupId = item.getGroupId();
|
||||
if (groupId == null) return;
|
||||
Intent i = new Intent(getActivity(),
|
||||
ConversationActivity.class);
|
||||
i.putExtra(GROUP_ID, groupId.getBytes());
|
||||
@@ -270,9 +269,9 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
||||
(IntroductionResponseReceivedEvent) e;
|
||||
IntroductionResponse ir = m.getIntroductionResponse();
|
||||
updateItem(m.getContactId(), ConversationItem.from(ir));
|
||||
} else if (e instanceof InvitationReceivedEvent) {
|
||||
} else if (e instanceof InvitationRequestReceivedEvent) {
|
||||
LOG.info("Invitation Request received, update contact");
|
||||
InvitationReceivedEvent m = (InvitationReceivedEvent) e;
|
||||
InvitationRequestReceivedEvent m = (InvitationRequestReceivedEvent) e;
|
||||
InvitationRequest ir = m.getRequest();
|
||||
updateItem(m.getContactId(), ConversationItem.from(ir));
|
||||
} else if (e instanceof InvitationResponseReceivedEvent) {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.briarproject.api.clients.MessageTracker.GroupCount;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static org.briarproject.android.contact.ConversationItem.IncomingItem;
|
||||
|
||||
@@ -17,10 +16,11 @@ public class ContactListItem {
|
||||
private final GroupId groupId;
|
||||
private boolean connected, empty;
|
||||
private long timestamp;
|
||||
private long unread;
|
||||
private int unread;
|
||||
|
||||
public ContactListItem(Contact contact, LocalAuthor localAuthor,
|
||||
boolean connected, @Nullable GroupId groupId, GroupCount count) {
|
||||
public ContactListItem(@NotNull Contact contact,
|
||||
@NotNull LocalAuthor localAuthor, boolean connected,
|
||||
@NotNull GroupId groupId, @NotNull GroupCount count) {
|
||||
this.contact = contact;
|
||||
this.localAuthor = localAuthor;
|
||||
this.groupId = groupId;
|
||||
@@ -48,7 +48,6 @@ public class ContactListItem {
|
||||
return localAuthor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
@@ -69,7 +68,7 @@ public class ContactListItem {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
long getUnreadCount() {
|
||||
int getUnreadCount() {
|
||||
return unread;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.IntroductionRequestReceivedEvent;
|
||||
import org.briarproject.api.event.IntroductionResponseReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationRequestReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationResponseReceivedEvent;
|
||||
import org.briarproject.api.event.MessagesAckedEvent;
|
||||
import org.briarproject.api.event.MessagesSentEvent;
|
||||
@@ -77,7 +77,7 @@ import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -481,12 +481,13 @@ public class ConversationActivity extends BriarActivity
|
||||
SparseArray<IncomingItem> list = adapter.getIncomingMessages();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
IncomingItem item = list.valueAt(i);
|
||||
if (!item.isRead()) unread.put(item.getId(), item.getGroupId());
|
||||
if (!item.isRead())
|
||||
unread.put(item.getId(), item.getGroupId());
|
||||
}
|
||||
if (unread.isEmpty()) return;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Marking " + unread.size() + " messages read");
|
||||
markMessagesRead(Collections.unmodifiableMap(unread));
|
||||
markMessagesRead(unread);
|
||||
}
|
||||
|
||||
private void markMessagesRead(final Map<MessageId, GroupId> unread) {
|
||||
@@ -573,9 +574,9 @@ public class ConversationActivity extends BriarActivity
|
||||
addConversationItem(item);
|
||||
markMessageReadIfNew(ir);
|
||||
}
|
||||
} else if (e instanceof InvitationReceivedEvent) {
|
||||
InvitationReceivedEvent event =
|
||||
(InvitationReceivedEvent) e;
|
||||
} else if (e instanceof InvitationRequestReceivedEvent) {
|
||||
InvitationRequestReceivedEvent event =
|
||||
(InvitationRequestReceivedEvent) e;
|
||||
if (event.getContactId().equals(contactId)) {
|
||||
LOG.info("Invitation received, adding...");
|
||||
InvitationRequest ir = event.getRequest();
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.android.contact.ConversationItem.IncomingItem;
|
||||
import org.briarproject.api.introduction.IntroductionRequest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
// This class is not thread-safe
|
||||
class ConversationIntroductionInItem extends ConversationIntroductionItem
|
||||
implements ConversationItem.IncomingItem {
|
||||
implements IncomingItem {
|
||||
|
||||
private boolean read;
|
||||
|
||||
ConversationIntroductionInItem(IntroductionRequest ir) {
|
||||
ConversationIntroductionInItem(@NotNull IntroductionRequest ir) {
|
||||
super(ir);
|
||||
|
||||
this.read = ir.isRead();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.api.introduction.IntroductionRequest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
// This class is not thread-safe
|
||||
abstract class ConversationIntroductionItem extends ConversationItem {
|
||||
@@ -8,13 +9,14 @@ abstract class ConversationIntroductionItem extends ConversationItem {
|
||||
private final IntroductionRequest ir;
|
||||
private boolean answered;
|
||||
|
||||
ConversationIntroductionItem(IntroductionRequest ir) {
|
||||
ConversationIntroductionItem(@NotNull IntroductionRequest ir) {
|
||||
super(ir.getMessageId(), ir.getGroupId(), ir.getTimestamp());
|
||||
|
||||
this.ir = ir;
|
||||
this.answered = ir.wasAnswered();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
IntroductionRequest getIntroductionRequest() {
|
||||
return ir;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.briarproject.api.sharing.InvitationRequest;
|
||||
import org.briarproject.api.sharing.InvitationResponse;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
// This class is not thread-safe
|
||||
public abstract class ConversationItem {
|
||||
@@ -31,11 +32,12 @@ public abstract class ConversationItem {
|
||||
final static int BLOG_INVITATION_IN = 9;
|
||||
final static int BLOG_INVITATION_OUT = 10;
|
||||
|
||||
private MessageId id;
|
||||
private GroupId groupId;
|
||||
private long time;
|
||||
final private MessageId id;
|
||||
final private GroupId groupId;
|
||||
final private long time;
|
||||
|
||||
public ConversationItem(MessageId id, GroupId groupId, long time) {
|
||||
public ConversationItem(@NotNull MessageId id, @NotNull GroupId groupId,
|
||||
long time) {
|
||||
this.id = id;
|
||||
this.groupId = groupId;
|
||||
this.time = time;
|
||||
@@ -43,10 +45,12 @@ public abstract class ConversationItem {
|
||||
|
||||
abstract int getType();
|
||||
|
||||
@NotNull
|
||||
public MessageId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
@@ -221,6 +225,7 @@ public abstract class ConversationItem {
|
||||
|
||||
interface OutgoingItem {
|
||||
|
||||
@NotNull
|
||||
MessageId getId();
|
||||
|
||||
boolean isSent();
|
||||
@@ -234,8 +239,10 @@ public abstract class ConversationItem {
|
||||
|
||||
interface IncomingItem {
|
||||
|
||||
@NotNull
|
||||
MessageId getId();
|
||||
|
||||
@NotNull
|
||||
GroupId getGroupId();
|
||||
|
||||
boolean isRead();
|
||||
|
||||
@@ -51,7 +51,7 @@ class ForumListAdapter
|
||||
ui.name.setText(item.getForum().getName());
|
||||
|
||||
// Post Count
|
||||
int postCount = (int) item.getPostCount();
|
||||
int postCount = item.getPostCount();
|
||||
if (postCount > 0) {
|
||||
ui.avatar.setProblem(false);
|
||||
ui.postCount.setText(ctx.getResources()
|
||||
|
||||
@@ -8,7 +8,8 @@ import org.briarproject.api.forum.ForumPostHeader;
|
||||
class ForumListItem {
|
||||
|
||||
private final Forum forum;
|
||||
private long postCount, unread, timestamp;
|
||||
private int postCount, unread;
|
||||
private long timestamp;
|
||||
|
||||
ForumListItem(Forum forum, GroupCount count) {
|
||||
this.forum = forum;
|
||||
@@ -31,7 +32,7 @@ class ForumListItem {
|
||||
return postCount == 0;
|
||||
}
|
||||
|
||||
long getPostCount() {
|
||||
int getPostCount() {
|
||||
return postCount;
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ class ForumListItem {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
long getUnreadCount() {
|
||||
int getUnreadCount() {
|
||||
return unread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.contact.ContactListItem;
|
||||
import org.briarproject.android.view.BriarRecyclerView;
|
||||
import org.briarproject.api.clients.MessageTracker;
|
||||
import org.briarproject.api.clients.MessageTracker.GroupCount;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.db.DbException;
|
||||
@@ -107,8 +106,8 @@ abstract class SharingStatusActivity extends BriarActivity {
|
||||
LocalAuthor localAuthor = identityManager
|
||||
.getLocalAuthor(c.getLocalAuthorId());
|
||||
ContactListItem item =
|
||||
new ContactListItem(c, localAuthor, false, null,
|
||||
new GroupCount(0, 0, 0));
|
||||
new ContactListItem(c, localAuthor, false,
|
||||
groupId, new GroupCount(0, 0, 0));
|
||||
contactItems.add(item);
|
||||
}
|
||||
} catch (DbException e) {
|
||||
@@ -143,8 +142,8 @@ abstract class SharingStatusActivity extends BriarActivity {
|
||||
LocalAuthor localAuthor = identityManager
|
||||
.getLocalAuthor(c.getLocalAuthorId());
|
||||
ContactListItem item =
|
||||
new ContactListItem(c, localAuthor, false, null,
|
||||
new GroupCount(0, 0, 0));
|
||||
new ContactListItem(c, localAuthor, false,
|
||||
groupId, new GroupCount(0, 0, 0));
|
||||
contactItems.add(item);
|
||||
}
|
||||
} catch (DbException e) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TextAvatarView extends FrameLayout {
|
||||
final private AppCompatTextView character;
|
||||
final private CircleImageView background;
|
||||
final private TextView badge;
|
||||
private long unreadCount;
|
||||
private int unreadCount;
|
||||
|
||||
public TextAvatarView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -48,11 +48,7 @@ public class TextAvatarView extends FrameLayout {
|
||||
}
|
||||
|
||||
public void setUnreadCount(int count) {
|
||||
setUnreadCount((long) count);
|
||||
}
|
||||
|
||||
public void setUnreadCount(long count) {
|
||||
this.unreadCount = count;
|
||||
unreadCount = count;
|
||||
if (count > 0) {
|
||||
badge.setBackgroundResource(R.drawable.bubble);
|
||||
badge.setText(String.valueOf(count));
|
||||
@@ -60,7 +56,6 @@ public class TextAvatarView extends FrameLayout {
|
||||
R.color.briar_text_primary_inverse));
|
||||
badge.setVisibility(VISIBLE);
|
||||
} else {
|
||||
badge.setText("");
|
||||
badge.setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -72,11 +67,8 @@ public class TextAvatarView extends FrameLayout {
|
||||
badge.setTextColor(ContextCompat
|
||||
.getColor(getContext(), R.color.briar_primary));
|
||||
badge.setVisibility(VISIBLE);
|
||||
} else if (unreadCount > 0) {
|
||||
setUnreadCount(unreadCount);
|
||||
} else {
|
||||
badge.setText("");
|
||||
badge.setVisibility(INVISIBLE);
|
||||
setUnreadCount(unreadCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,18 +9,13 @@ import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.v7.widget.AppCompatImageButton;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout;
|
||||
@@ -32,7 +27,6 @@ import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
|
||||
@UiThread
|
||||
public class TextInputView extends KeyboardAwareLinearLayout
|
||||
|
||||
Reference in New Issue
Block a user