Improved selecting identities

This commit is contained in:
M66B 2023-11-01 15:02:44 +01:00
parent dcb455a374
commit 32286bea04
2 changed files with 59 additions and 5 deletions

View File

@ -128,12 +128,14 @@ public class FragmentDialogSelectIdentity extends FragmentDialogBase {
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private View vwColor;
private TextView tv;
private TextView text1;
private TextView text2;
ViewHolder(View itemView) {
super(itemView);
vwColor = itemView.findViewById(R.id.vwColor);
tv = itemView.findViewById(android.R.id.text1);
text1 = itemView.findViewById(android.R.id.text1);
text2 = itemView.findViewById(android.R.id.text2);
}
private void wire() {
@ -146,12 +148,15 @@ public class FragmentDialogSelectIdentity extends FragmentDialogBase {
private void bindTo(TupleIdentityEx identity) {
int vpad = (getItemCount() > 10 ? dp6 : dp12);
tv.setPadding(0, vpad, 0, vpad);
text1.setPadding(0, vpad, 0, 0);
text2.setPadding(0, 0, 0, vpad);
Integer color = (identity.color == null ? identity.accountColor : identity.color);
vwColor.setBackgroundColor(color == null ? Color.TRANSPARENT : color);
String name = identity.getDisplayName();
tv.setText(TextUtils.isEmpty(name) ? identity.email : name);
text1.setText(TextUtils.isEmpty(name) ? "-" : name);
text2.setText(identity.email);
}
@Override
@ -189,7 +194,7 @@ public class FragmentDialogSelectIdentity extends FragmentDialogBase {
@Override
@NonNull
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(inflater.inflate(R.layout.item_account_select, parent, false));
return new ViewHolder(inflater.inflate(R.layout.item_identity_select, parent, false));
}
@Override

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingHorizontal="12dp">
<eu.faircode.email.ViewStripe
android:id="@+id/vwColor"
android:layout_width="6dp"
android:layout_height="0dp"
android:layout_marginVertical="3dp"
android:layout_marginStart="6dp"
app:layout_constraintBottom_toBottomOf="@android:id/text2"
app:layout_constraintEnd_toStartOf="@android:id/text1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@android:id/text1" />
<TextView
android:id="@android:id/text1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:paddingTop="6dp"
android:text="Text1"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toTopOf="@android:id/text2"
app:layout_constraintStart_toEndOf="@+id/vwColor"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@android:id/text2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="Text2"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/vwColor"
app:layout_constraintTop_toBottomOf="@android:id/text1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>