[android] Show contact alias inside private groups and their memberlist

parent 6e3adc08
...@@ -10,6 +10,7 @@ import org.briarproject.briar.android.threaded.BaseThreadItemViewHolder; ...@@ -10,6 +10,7 @@ import org.briarproject.briar.android.threaded.BaseThreadItemViewHolder;
import org.briarproject.briar.android.threaded.ThreadItemAdapter.ThreadItemListener; import org.briarproject.briar.android.threaded.ThreadItemAdapter.ThreadItemListener;
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES; import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
@UiThread @UiThread
@NotNullByDefault @NotNullByDefault
...@@ -36,24 +37,27 @@ class JoinMessageItemViewHolder ...@@ -36,24 +37,27 @@ class JoinMessageItemViewHolder
if (item.isInitial()) { if (item.isInitial()) {
textView.setText(R.string.groups_member_created_you); textView.setText(R.string.groups_member_created_you);
} else { } else {
textView.setText( String name = getContactDisplayName(item.getAuthor(),
getContext().getString(R.string.groups_member_joined, item.getAuthorInfo().getAlias());
item.getAuthor().getName())); textView.setText(getContext()
.getString(R.string.groups_member_joined, name));
} }
} }
private void bind(JoinMessageItem item) { private void bind(JoinMessageItem item) {
Context ctx = getContext(); Context ctx = getContext();
String name = getContactDisplayName(item.getAuthor(),
item.getAuthorInfo().getAlias());
if (item.isInitial()) { if (item.isInitial()) {
textView.setText(ctx.getString(R.string.groups_member_created, textView.setText(
item.getAuthor().getName())); ctx.getString(R.string.groups_member_created, name));
} else { } else {
if (item.getAuthorInfo().getStatus() == OURSELVES) { if (item.getAuthorInfo().getStatus() == OURSELVES) {
textView.setText(R.string.groups_member_joined_you); textView.setText(R.string.groups_member_joined_you);
} else { } else {
textView.setText(ctx.getString(R.string.groups_member_joined, textView.setText(
item.getAuthor().getName())); ctx.getString(R.string.groups_member_joined, name));
} }
} }
} }
......
package org.briarproject.briar.android.privategroup.memberlist; package org.briarproject.briar.android.privategroup.memberlist;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -8,6 +9,8 @@ import android.view.ViewGroup; ...@@ -8,6 +9,8 @@ import android.view.ViewGroup;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.briarproject.briar.android.util.BriarAdapter; import org.briarproject.briar.android.util.BriarAdapter;
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
class MemberListAdapter extends class MemberListAdapter extends
BriarAdapter<MemberListItem, MemberListItemHolder> { BriarAdapter<MemberListItem, MemberListItemHolder> {
...@@ -15,8 +18,9 @@ class MemberListAdapter extends ...@@ -15,8 +18,9 @@ class MemberListAdapter extends
super(context, MemberListItem.class); super(context, MemberListItem.class);
} }
@NonNull
@Override @Override
public MemberListItemHolder onCreateViewHolder(ViewGroup viewGroup, public MemberListItemHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
int i) { int i) {
View v = LayoutInflater.from(ctx).inflate( View v = LayoutInflater.from(ctx).inflate(
R.layout.list_item_group_member, viewGroup, false); R.layout.list_item_group_member, viewGroup, false);
...@@ -24,13 +28,18 @@ class MemberListAdapter extends ...@@ -24,13 +28,18 @@ class MemberListAdapter extends
} }
@Override @Override
public void onBindViewHolder(MemberListItemHolder ui, int position) { public void onBindViewHolder(@NonNull MemberListItemHolder ui,
int position) {
ui.bind(items.get(position)); ui.bind(items.get(position));
} }
@Override @Override
public int compare(MemberListItem m1, MemberListItem m2) { public int compare(MemberListItem m1, MemberListItem m2) {
return m1.getMember().getName().compareTo(m2.getMember().getName()); String n1 = getContactDisplayName(m1.getMember(),
m1.getAuthorInfo().getAlias());
String n2 = getContactDisplayName(m2.getMember(),
m2.getAuthorInfo().getAlias());
return n1.compareTo(n2);
} }
@Override @Override
......
...@@ -13,6 +13,7 @@ import org.briarproject.briar.android.view.AuthorView; ...@@ -13,6 +13,7 @@ import org.briarproject.briar.android.view.AuthorView;
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES; import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
@UiThread @UiThread
@NotNullByDefault @NotNullByDefault
...@@ -51,9 +52,10 @@ class MemberListItemHolder extends RecyclerView.ViewHolder { ...@@ -51,9 +52,10 @@ class MemberListItemHolder extends RecyclerView.ViewHolder {
if (item.getStatus() == OURSELVES) { if (item.getStatus() == OURSELVES) {
creator.setText(R.string.groups_member_created_you); creator.setText(R.string.groups_member_created_you);
} else { } else {
String name = getContactDisplayName(item.getMember(),
item.getAuthorInfo().getAlias());
creator.setText(creator.getContext() creator.setText(creator.getContext()
.getString(R.string.groups_member_created, .getString(R.string.groups_member_created, name));
item.getMember().getName()));
} }
} else { } else {
creator.setVisibility(GONE); creator.setVisibility(GONE);
......
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