mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Merge branch '1052-trust-indicator-in-main-contact-list' into 'master'
Show trust-indicator with description in contact list Closes #1052 See merge request briar/briar!1688
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user