mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 15:11:03 +00:00
Layout improvement
This commit is contained in:
parent
cf602fa570
commit
7a2143c186
4 changed files with 142 additions and 110 deletions
|
@ -40,6 +40,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||
|
@ -59,30 +60,32 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
private static final DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
View view;
|
||||
View vwColor;
|
||||
ImageView ivPrimary;
|
||||
TextView tvName;
|
||||
ImageView ivSync;
|
||||
TextView tvUser;
|
||||
ImageView ivState;
|
||||
TextView tvHost;
|
||||
TextView tvLast;
|
||||
TextView tvError;
|
||||
private View view;
|
||||
private View vwColor;
|
||||
private ImageView ivPrimary;
|
||||
private TextView tvName;
|
||||
private ImageView ivSync;
|
||||
private TextView tvUser;
|
||||
private ImageView ivState;
|
||||
private TextView tvHost;
|
||||
private TextView tvLast;
|
||||
private TextView tvError;
|
||||
private Group grpSettings;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
view = itemView.findViewById(R.id.clItem);
|
||||
vwColor = itemView.findViewById(R.id.vwColor);
|
||||
ivSync = itemView.findViewById(R.id.ivSync);
|
||||
ivPrimary = itemView.findViewById(R.id.ivPrimary);
|
||||
tvName = itemView.findViewById(R.id.tvName);
|
||||
ivSync = itemView.findViewById(R.id.ivSync);
|
||||
tvUser = itemView.findViewById(R.id.tvUser);
|
||||
ivState = itemView.findViewById(R.id.ivState);
|
||||
tvHost = itemView.findViewById(R.id.tvHost);
|
||||
tvLast = itemView.findViewById(R.id.tvLast);
|
||||
tvError = itemView.findViewById(R.id.tvError);
|
||||
grpSettings = itemView.findViewById(R.id.grpSettings);
|
||||
}
|
||||
|
||||
private void wire() {
|
||||
|
@ -96,7 +99,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
private void bindTo(TupleAccountEx account) {
|
||||
view.setActivated(account.tbd != null);
|
||||
vwColor.setBackgroundColor(account.color == null ? Color.TRANSPARENT : account.color);
|
||||
ivPrimary.setVisibility(account.primary ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
ivSync.setImageResource(account.synchronize ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24);
|
||||
|
||||
ivPrimary.setVisibility(account.primary ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (settings)
|
||||
tvName.setText(account.name);
|
||||
|
@ -110,9 +116,6 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
tvName.setTextColor(account.unseen > 0 ? colorUnread : textColorSecondary);
|
||||
}
|
||||
|
||||
ivSync.setImageResource(account.synchronize ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24);
|
||||
ivSync.setVisibility(settings ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvUser.setText(account.user);
|
||||
|
||||
if ("connected".equals(account.state))
|
||||
|
@ -131,6 +134,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
|
||||
tvError.setText(account.error);
|
||||
tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
grpSettings.setVisibility(settings ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,26 +52,26 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
private static final DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
View view;
|
||||
View vwColor;
|
||||
ImageView ivPrimary;
|
||||
TextView tvName;
|
||||
ImageView ivSync;
|
||||
TextView tvUser;
|
||||
TextView tvHost;
|
||||
ImageView ivState;
|
||||
TextView tvAccount;
|
||||
TextView tvLast;
|
||||
TextView tvError;
|
||||
private View view;
|
||||
private View vwColor;
|
||||
private ImageView ivSync;
|
||||
private ImageView ivPrimary;
|
||||
private TextView tvName;
|
||||
private TextView tvUser;
|
||||
private TextView tvHost;
|
||||
private ImageView ivState;
|
||||
private TextView tvAccount;
|
||||
private TextView tvLast;
|
||||
private TextView tvError;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
view = itemView.findViewById(R.id.clItem);
|
||||
vwColor = itemView.findViewById(R.id.vwColor);
|
||||
ivSync = itemView.findViewById(R.id.ivSync);
|
||||
ivPrimary = itemView.findViewById(R.id.ivPrimary);
|
||||
tvName = itemView.findViewById(R.id.tvName);
|
||||
ivSync = itemView.findViewById(R.id.ivSync);
|
||||
tvUser = itemView.findViewById(R.id.tvUser);
|
||||
tvHost = itemView.findViewById(R.id.tvHost);
|
||||
ivState = itemView.findViewById(R.id.ivState);
|
||||
|
@ -91,9 +91,11 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
private void bindTo(TupleIdentityEx identity) {
|
||||
view.setActivated(identity.tbd != null);
|
||||
vwColor.setBackgroundColor(identity.color == null ? Color.TRANSPARENT : identity.color);
|
||||
ivPrimary.setVisibility(identity.primary ? View.VISIBLE : View.INVISIBLE);
|
||||
tvName.setText(identity.getDisplayName());
|
||||
|
||||
ivSync.setImageResource(identity.synchronize ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24);
|
||||
|
||||
ivPrimary.setVisibility(identity.primary ? View.VISIBLE : View.GONE);
|
||||
tvName.setText(identity.getDisplayName());
|
||||
tvUser.setText(identity.email);
|
||||
|
||||
if ("connected".equals(identity.state))
|
||||
|
|
|
@ -27,6 +27,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivState"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_cloud_off_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvName"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvName" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivPrimary"
|
||||
android:layout_width="24dp"
|
||||
|
@ -34,9 +45,9 @@
|
|||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/marginTop" />
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvName"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvName"
|
||||
|
@ -44,14 +55,15 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="middle"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="24dp"
|
||||
android:singleLine="true"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivPrimary"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
app:layout_constraintStart_toEndOf="@id/ivPrimary"
|
||||
app:layout_constraintTop_toTopOf="@id/ivPrimary" />
|
||||
app:layout_constraintTop_toBottomOf="@id/marginTop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSync"
|
||||
|
@ -59,8 +71,9 @@
|
|||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_sync_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/marginTop" />
|
||||
app:layout_constraintTop_toTopOf="@+id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvUser"
|
||||
|
@ -68,21 +81,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="user"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivPrimary"
|
||||
app:layout_constraintTop_toBottomOf="@id/ivPrimary" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivState"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_cloud_off_24"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUser" />
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHost"
|
||||
|
@ -94,10 +99,9 @@
|
|||
android:maxLines="1"
|
||||
android:text="host"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivState"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toTopOf="@id/ivState" />
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUser" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLast"
|
||||
|
@ -110,7 +114,7 @@
|
|||
android:text="Last connected time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<TextView
|
||||
|
@ -141,5 +145,11 @@
|
|||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/marginBottom" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpSettings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="ivSync,tvHost" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
|
@ -20,54 +20,13 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivPrimary"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
<View
|
||||
android:id="@+id/marginTop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ivSync"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivPrimary"
|
||||
app:layout_constraintTop_toTopOf="@+id/ivSync" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSync"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_sync_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvUser"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="user"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivPrimary"
|
||||
app:layout_constraintTop_toBottomOf="@id/ivSync" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivState"
|
||||
android:layout_width="24dp"
|
||||
|
@ -75,22 +34,74 @@
|
|||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_cloud_off_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvName"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUser" />
|
||||
app:layout_constraintTop_toTopOf="@+id/tvName" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivPrimary"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvName"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="middle"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="24dp"
|
||||
android:singleLine="true"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
app:layout_constraintStart_toEndOf="@id/ivPrimary"
|
||||
app:layout_constraintTop_toBottomOf="@id/marginTop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSync"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_sync_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvUser"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="user"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHost"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="host"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivState"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvAccount"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivPrimary"
|
||||
app:layout_constraintTop_toTopOf="@id/ivState" />
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUser" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAccount"
|
||||
|
@ -101,10 +112,9 @@
|
|||
android:text="account"
|
||||
android:textAlignment="textEnd"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivState"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tvHost"
|
||||
app:layout_constraintTop_toTopOf="@id/ivState" />
|
||||
app:layout_constraintTop_toTopOf="@id/tvHost" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLast"
|
||||
|
@ -117,7 +127,7 @@
|
|||
android:text="Last connected time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<TextView
|
||||
|
@ -134,14 +144,19 @@
|
|||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLast" />
|
||||
|
||||
<View
|
||||
android:id="@+id/marginBottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvError" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvError" />
|
||||
app:layout_constraintTop_toBottomOf="@id/marginBottom" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
|
Loading…
Reference in a new issue