mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +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);
|
||||
});
|
||||
|
||||
@@ -55,13 +55,42 @@
|
||||
android:paddingEnd="@dimen/margin_medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dateView"
|
||||
app:layout_constraintBottom_toTopOf="@+id/trustIndicatorDescription"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bulbView"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/avatarFrameView"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="This is a name of a contact" />
|
||||
|
||||
<org.briarproject.briar.android.view.TrustIndicatorView
|
||||
android:id="@+id/trustIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dateView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/trustIndicatorDescription"
|
||||
app:layout_constraintStart_toEndOf="@+id/avatarFrameView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameView"
|
||||
tools:src="@drawable/trust_indicator_verified" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/trustIndicatorDescription"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:paddingStart="@dimen/margin_medium"
|
||||
android:paddingEnd="@dimen/margin_medium"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/text_size_small"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dateView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bulbView"
|
||||
app:layout_constraintStart_toEndOf="@+id/trustIndicator"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameView"
|
||||
tools:text="verified contact"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateView"
|
||||
android:layout_width="0dp"
|
||||
@@ -70,15 +99,16 @@
|
||||
android:layout_marginLeft="@dimen/margin_medium"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:layout_marginRight="@dimen/margin_medium"
|
||||
android:layout_marginBottom="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:paddingStart="@dimen/margin_medium"
|
||||
android:paddingEnd="@dimen/margin_medium"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/text_size_small"
|
||||
app:layout_constraintBottom_toTopOf="@+id/divider"
|
||||
app:layout_constraintBottom_toTopOf="@id/divider"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bulbView"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/avatarFrameView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/trustIndicatorDescription"
|
||||
tools:text="Dec 24" />
|
||||
|
||||
<ImageView
|
||||
|
||||
Reference in New Issue
Block a user