Skip to content
Snippets Groups Projects

Show trust-indicator with description in contact list

Files
2
@@ -7,6 +7,8 @@ import android.widget.TextView;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.briar.R;
import org.briarproject.briar.android.view.TrustIndicatorView;
import org.briarproject.briar.api.identity.AuthorInfo;
import javax.annotation.Nullable;
@@ -26,6 +28,10 @@ public class ContactItemViewHolder<I extends ContactItem>
protected final TextView name;
@Nullable
protected final ImageView bulb;
@Nullable
protected final TrustIndicatorView trustIndicator;
@Nullable
protected final TextView trustIndicatorDescription;
public ContactItemViewHolder(View v) {
super(v);
@@ -35,6 +41,11 @@ public class ContactItemViewHolder<I extends ContactItem>
name = v.findViewById(R.id.nameView);
// this can be null as not all layouts that use this ViewHolder have it
bulb = v.findViewById(R.id.bulbView);
// this can be null as not all layouts that use this ViewHolder have it
trustIndicator = v.findViewById(R.id.trustIndicator);
// this can be null as not all layouts that use this ViewHolder have it
trustIndicatorDescription =
v.findViewById(R.id.trustIndicatorDescription);
}
protected void bind(I item, @Nullable OnContactClickListener<I> listener) {
@@ -50,6 +61,29 @@ public class ContactItemViewHolder<I extends ContactItem>
}
}
if (trustIndicator != null && trustIndicatorDescription != null) {
final AuthorInfo.Status status = item.getAuthorInfo().getStatus();
trustIndicator.setTrustLevel(status);
switch (status) {
case UNVERIFIED:
trustIndicatorDescription.setText(
R.string.peer_trust_level_unverified);
break;
case VERIFIED:
trustIndicatorDescription.setText(
R.string.peer_trust_level_verified);
break;
case OURSELVES:
trustIndicatorDescription.setText(
R.string.peer_trust_level_ourselves);
break;
default:
trustIndicatorDescription.setText(
R.string.peer_trust_level_stranger);
}
}
layout.setOnClickListener(v -> {
if (listener != null) listener.onItemClick(avatar, item);
});
Loading