mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Address review comments
This commit is contained in:
@@ -2,7 +2,6 @@ package org.briarproject.android.privategroup.conversation;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
||||
import org.briarproject.android.threaded.ThreadListControllerImpl;
|
||||
@@ -95,8 +94,8 @@ public class GroupControllerImpl extends
|
||||
protected String loadMessageBody(GroupMessageHeader header)
|
||||
throws DbException {
|
||||
if (header instanceof JoinMessageHeader) {
|
||||
return listener.getApplicationContext()
|
||||
.getString(R.string.groups_member_joined);
|
||||
// will be looked up later
|
||||
return "";
|
||||
}
|
||||
return privateGroupManager.getMessageBody(header.getId());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.android.privategroup.conversation;
|
||||
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -19,12 +20,11 @@ public class GroupMessageAdapter extends ThreadItemAdapter<GroupMessageItem> {
|
||||
super(listener, layoutManager);
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
GroupMessageItem item = getVisibleItem(position);
|
||||
if (item instanceof JoinMessageItem) {
|
||||
return R.layout.list_item_thread_notice;
|
||||
}
|
||||
if (item != null) return item.getLayout();
|
||||
return R.layout.list_item_thread;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GroupMessageAdapter extends ThreadItemAdapter<GroupMessageItem> {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(type, parent, false);
|
||||
if (type == R.layout.list_item_thread_notice) {
|
||||
return new BaseThreadItemViewHolder<>(v);
|
||||
return new JoinMessageItemHolder(v);
|
||||
}
|
||||
return new ThreadItemViewHolder<>(v);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package org.briarproject.android.privategroup.conversation;
|
||||
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.threaded.ThreadItem;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.Author.Status;
|
||||
import org.briarproject.api.privategroup.GroupMessageHeader;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
@UiThread
|
||||
@NotThreadSafe
|
||||
class GroupMessageItem extends ThreadItem {
|
||||
|
||||
private GroupMessageItem(MessageId messageId, MessageId parentId,
|
||||
@@ -19,4 +27,9 @@ class GroupMessageItem extends ThreadItem {
|
||||
h.getAuthorStatus(), h.isRead());
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
public int getLayout() {
|
||||
return R.layout.list_item_thread;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
package org.briarproject.android.privategroup.conversation;
|
||||
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.privategroup.GroupMessageHeader;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
@UiThread
|
||||
@NotThreadSafe
|
||||
class JoinMessageItem extends GroupMessageItem {
|
||||
|
||||
JoinMessageItem(GroupMessageHeader h,
|
||||
@@ -19,4 +27,9 @@ class JoinMessageItem extends GroupMessageItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
public int getLayout() {
|
||||
return R.layout.list_item_thread_notice;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.briarproject.android.privategroup.conversation;
|
||||
|
||||
import android.support.annotation.UiThread;
|
||||
import android.view.View;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.threaded.BaseThreadItemViewHolder;
|
||||
import org.briarproject.android.threaded.ThreadItemAdapter;
|
||||
import org.briarproject.android.threaded.ThreadItemAdapter.ThreadItemListener;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
public class JoinMessageItemHolder
|
||||
extends BaseThreadItemViewHolder<GroupMessageItem> {
|
||||
|
||||
public JoinMessageItemHolder(View v) {
|
||||
super(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(final ThreadItemAdapter<GroupMessageItem> adapter,
|
||||
final ThreadItemListener<GroupMessageItem> listener,
|
||||
final GroupMessageItem item, int pos) {
|
||||
super.bind(adapter, listener, item, pos);
|
||||
|
||||
textView.setText(getContext().getString(R.string.groups_member_joined));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,13 +21,13 @@ import org.briarproject.util.StringUtils;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
public class BaseThreadItemViewHolder<I extends ThreadItem>
|
||||
public abstract class BaseThreadItemViewHolder<I extends ThreadItem>
|
||||
extends RecyclerView.ViewHolder {
|
||||
|
||||
private final static int ANIMATION_DURATION = 5000;
|
||||
|
||||
protected final TextView textView;
|
||||
private final ViewGroup layout;
|
||||
private final TextView textView;
|
||||
private final AuthorView author;
|
||||
private final View topDivider;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.android.threaded;
|
||||
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import org.briarproject.api.clients.MessageTree.MessageNode;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.Author.Status;
|
||||
@@ -11,7 +9,6 @@ import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import static org.briarproject.android.threaded.ThreadItemAdapter.UNDEFINED;
|
||||
|
||||
@UiThread
|
||||
@NotThreadSafe
|
||||
public abstract class ThreadItem implements MessageNode {
|
||||
|
||||
@@ -97,4 +94,5 @@ public abstract class ThreadItem implements MessageNode {
|
||||
public void setDescendantCount(int descendantCount) {
|
||||
this.descendantCount = descendantCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public class ThreadItemAdapter<I extends ThreadItem>
|
||||
revision++;
|
||||
}
|
||||
|
||||
protected interface ThreadItemListener<I> {
|
||||
public interface ThreadItemListener<I> {
|
||||
|
||||
void onItemVisible(I item);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.android.threaded;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
@@ -40,8 +39,6 @@ public interface ThreadListController<G extends NamedGroup, I extends ThreadItem
|
||||
|
||||
@UiThread
|
||||
void onGroupRemoved();
|
||||
|
||||
Context getApplicationContext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
Logger.getLogger(ThreadListControllerImpl.class.getName());
|
||||
|
||||
protected final IdentityManager identityManager;
|
||||
@CryptoExecutor
|
||||
protected final Executor cryptoExecutor;
|
||||
protected final AndroidNotificationManager notificationManager;
|
||||
protected final Clock clock;
|
||||
|
||||
Reference in New Issue
Block a user