Add visibility information to group member list

parent 9b09b64a
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:alpha="0.54"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6.99,11L3,15l3.99,4v-3H14v-2H6.99v-3zM21,9l-3.99,-4v3H10v2h7.01v3L21,9z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_marginStart="@dimen/listitem_horizontal_margin"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_medium"
android:paddingTop="@dimen/margin_medium">
<org.briarproject.android.view.AuthorView
android:id="@+id/authorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="@dimen/margin_small"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
app:persona="list"/>
<ImageView
android:id="@+id/sharingView"
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_sharing"
android:layout_marginLeft="@dimen/margin_medium"
android:contentDescription="@string/forum_invitation_already_sharing"/>
android:layout_below="@+id/authorView"
android:layout_marginLeft="@dimen/listitem_group_member_indentation"
android:layout_marginRight="@dimen/margin_small"
android:contentDescription="@string/forum_invitation_already_sharing"
android:src="@drawable/ic_visibility"/>
</LinearLayout>
<TextView
android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/authorView"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_toRightOf="@+id/icon"
android:gravity="center_vertical"
android:minHeight="24dp"
android:textColor="@color/briar_text_secondary"
android:textIsSelectable="true"
android:textSize="@dimen/text_size_tiny"
android:textStyle="italic"
tools:text="@string/groups_reveal_visible_revealed_by_us"/>
<View
android:id="@+id/divider"
style="@style/Divider.ContactList"
android:layout_below="@+id/info"
android:layout_marginLeft="@dimen/listitem_group_member_indentation"
android:layout_marginTop="@dimen/margin_medium"/>
</RelativeLayout>
......@@ -28,6 +28,7 @@
<dimen name="listitem_picture_frame_offset_horizontal">1dp</dimen>
<dimen name="listitem_picture_frame_offset_vertical">2dp</dimen>
<dimen name="listitem_selectable_picture_size">40dp</dimen>
<dimen name="listitem_group_member_indentation">32dp</dimen>
<dimen name="avatar_forum_size">48dp</dimen>
<dimen name="avatar_border_width">2dp</dimen>
<dimen name="avatar_text_size">30sp</dimen>
......
......@@ -202,10 +202,10 @@
<!-- Private Groups Revealing Contacts -->
<string name="groups_reveal_contacts">Reveal Contacts</string>
<string name="groups_reveal_dialog_message">You can choose whether to reveal contacts to all current and future members of this group.\n\nRevealing contacts makes your connection to the group faster and more reliable, because you can communicate with revealed contacts even when the creator of the group is offline.</string>
<string name="groups_reveal_visible">Your relationship is visible to the group</string>
<string name="groups_reveal_visible_revealed_by_us">Your relationship is visible to the group (revealed by you)</string>
<string name="groups_reveal_visible_revealed_by_contact">Your relationship is visible to the group (revealed by contact)</string>
<string name="groups_reveal_invisible">Your relationship is not visible to the group</string>
<string name="groups_reveal_visible">Contact relationship is visible to the group</string>
<string name="groups_reveal_visible_revealed_by_us">Contact relationship is visible to the group (revealed by you)</string>
<string name="groups_reveal_visible_revealed_by_contact">Contact relationship is visible to the group (revealed by %s)</string>
<string name="groups_reveal_invisible">Contact relationship is not visible to the group</string>
<!-- Forums -->
<string name="no_forums">You don\'t have any forums yet.\n\nWhy don\'t you create a new one yourself by tapping the + icon at the top?\n\nYou can also ask your contacts to share forums with you.</string>
......
package org.briarproject.android.privategroup;
import android.support.annotation.StringRes;
import android.content.Context;
import android.support.annotation.DrawableRes;
import org.briarproject.R;
import org.briarproject.api.privategroup.Visibility;
public class VisibilityStringProvider {
import static org.briarproject.api.privategroup.Visibility.INVISIBLE;
@StringRes
public static int getVisibilityStringId(Visibility v) {
public class VisibilityHelper {
public static String getVisibilityString(Context ctx, Visibility v,
String contact) {
switch (v) {
case VISIBLE:
return R.string.groups_reveal_visible;
return ctx.getString(R.string.groups_reveal_visible);
case REVEALED_BY_US:
return R.string.groups_reveal_visible_revealed_by_us;
return ctx.getString(
R.string.groups_reveal_visible_revealed_by_us);
case REVEALED_BY_CONTACT:
return R.string.groups_reveal_visible_revealed_by_contact;
return ctx.getString(
R.string.groups_reveal_visible_revealed_by_contact,
contact);
case INVISIBLE:
return R.string.groups_reveal_invisible;
return ctx.getString(R.string.groups_reveal_invisible);
default:
throw new IllegalArgumentException("Unknown visibility");
}
}
@DrawableRes
public static int getVisibilityIcon(Visibility v) {
if (v == INVISIBLE) {
return R.drawable.ic_visibility_off;
}
return R.drawable.ic_visibility;
}
}
......@@ -16,7 +16,8 @@ import org.briarproject.android.threaded.ThreadItemAdapter.ThreadItemListener;
import org.briarproject.api.nullsafety.NotNullByDefault;
import static org.briarproject.android.BriarActivity.GROUP_ID;
import static org.briarproject.android.privategroup.VisibilityStringProvider.getVisibilityStringId;
import static org.briarproject.android.privategroup.VisibilityHelper.getVisibilityIcon;
import static org.briarproject.android.privategroup.VisibilityHelper.getVisibilityString;
import static org.briarproject.api.identity.Author.Status.OURSELVES;
import static org.briarproject.api.identity.Author.Status.UNKNOWN;
import static org.briarproject.api.privategroup.Visibility.INVISIBLE;
......@@ -83,11 +84,11 @@ class JoinMessageItemViewHolder
options.setVisibility(View.GONE);
} else {
icon.setVisibility(View.VISIBLE);
icon.setImageResource(getVisibilityIcon(item.getVisibility()));
info.setVisibility(View.VISIBLE);
info.setText(getVisibilityStringId(item.getVisibility()));
info.setText(getVisibilityString(getContext(), item.getVisibility(),
item.getAuthor().getName()));
if (item.getVisibility() == INVISIBLE) {
icon.setImageResource(R.drawable.ic_visibility_off);
options.setVisibility(View.VISIBLE);
options.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -99,7 +100,6 @@ class JoinMessageItemViewHolder
}
});
} else {
icon.setImageResource(R.drawable.ic_visibility);
options.setVisibility(View.GONE);
}
}
......
......@@ -35,7 +35,7 @@ class MemberListAdapter extends
@Override
public boolean areContentsTheSame(MemberListItem m1, MemberListItem m2) {
if (m1.isSharing() != m2.isSharing()) return false;
if (m1.getVisibility() != m2.getVisibility()) return false;
if (m1.getStatus() != m2.getStatus()) return false;
return true;
}
......
......@@ -4,6 +4,7 @@ import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.Author.Status;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.privategroup.GroupMember;
import org.briarproject.api.privategroup.Visibility;
import javax.annotation.concurrent.Immutable;
......@@ -15,11 +16,11 @@ class MemberListItem {
private final Author member;
private final Status status;
private final boolean sharing;
private final Visibility visibility;
public MemberListItem(GroupMember groupMember) {
this.member = groupMember.getAuthor();
this.sharing = groupMember.getVisibility() != INVISIBLE;
this.visibility = groupMember.getVisibility();
this.status = groupMember.getStatus();
}
......@@ -27,8 +28,8 @@ class MemberListItem {
return member;
}
public boolean isSharing() {
return sharing;
public Visibility getVisibility() {
return visibility;
}
public Status getStatus() {
......
......@@ -4,35 +4,45 @@ import android.support.annotation.UiThread;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import org.briarproject.R;
import org.briarproject.android.view.AuthorView;
import org.briarproject.api.nullsafety.NotNullByDefault;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static org.briarproject.android.privategroup.VisibilityHelper.getVisibilityIcon;
import static org.briarproject.android.privategroup.VisibilityHelper.getVisibilityString;
import static org.briarproject.api.identity.Author.Status.OURSELVES;
import static org.briarproject.api.identity.Author.Status.UNKNOWN;
@UiThread
@NotNullByDefault
class MemberListItemHolder extends RecyclerView.ViewHolder {
private final AuthorView author;
private final ImageView sharing;
private final ImageView icon;
private final TextView info;
MemberListItemHolder(View v) {
super(v);
author = (AuthorView) v.findViewById(R.id.authorView);
sharing = (ImageView) v.findViewById(R.id.sharingView);
icon = (ImageView) v.findViewById(R.id.icon);
info = (TextView) v.findViewById(R.id.info);
}
protected void bind(MemberListItem item) {
author.setAuthor(item.getMember());
author.setAuthorStatus(item.getStatus());
if (item.isSharing() && item.getStatus() != OURSELVES) {
sharing.setVisibility(VISIBLE);
if (item.getStatus() == OURSELVES || item.getStatus() == UNKNOWN) {
icon.setVisibility(View.GONE);
info.setVisibility(View.GONE);
} else {
sharing.setVisibility(INVISIBLE);
icon.setVisibility(View.VISIBLE);
icon.setImageResource(getVisibilityIcon(item.getVisibility()));
info.setVisibility(View.VISIBLE);
info.setText(
getVisibilityString(info.getContext(), item.getVisibility(),
item.getMember().getName()));
}
}
......
......@@ -10,7 +10,8 @@ import org.briarproject.android.contactselection.BaseSelectableContactHolder;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.jetbrains.annotations.Nullable;
import static org.briarproject.android.privategroup.VisibilityStringProvider.getVisibilityStringId;
import static org.briarproject.android.privategroup.VisibilityHelper.getVisibilityIcon;
import static org.briarproject.android.privategroup.VisibilityHelper.getVisibilityString;
import static org.briarproject.android.util.AndroidUtils.GREY_OUT;
import static org.briarproject.api.privategroup.Visibility.INVISIBLE;
......@@ -32,13 +33,10 @@ public class RevealableContactViewHolder
OnContactClickListener<RevealableContactItem> listener) {
super.bind(item, listener);
info.setText(getVisibilityStringId(item.getVisibility()));
if (item.getVisibility() == INVISIBLE) {
icon.setImageResource(R.drawable.ic_visibility_off);
} else {
icon.setImageResource(R.drawable.ic_visibility);
}
icon.setImageResource(getVisibilityIcon(item.getVisibility()));
info.setText(
getVisibilityString(info.getContext(), item.getVisibility(),
item.getContact().getAuthor().getName()));
}
@Override
......
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