mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Show last connected time accounts in debug mode
This commit is contained in:
parent
9046207b5d
commit
98f97139a5
2 changed files with 34 additions and 7 deletions
|
@ -21,7 +21,9 @@ package eu.faircode.email;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -33,6 +35,7 @@ import java.text.Collator;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -44,6 +47,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHolder> {
|
||||
private Context context;
|
||||
private boolean debug;
|
||||
|
||||
private List<EntityAccount> all = new ArrayList<>();
|
||||
private List<EntityAccount> filtered = new ArrayList<>();
|
||||
|
@ -57,6 +61,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
TextView tvUser;
|
||||
TextView tvHost;
|
||||
ImageView ivState;
|
||||
TextView tvLast;
|
||||
TextView tvError;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
|
@ -70,6 +75,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
tvUser = itemView.findViewById(R.id.tvUser);
|
||||
tvHost = itemView.findViewById(R.id.tvHost);
|
||||
ivState = itemView.findViewById(R.id.ivState);
|
||||
tvLast = itemView.findViewById(R.id.tvLast);
|
||||
tvError = itemView.findViewById(R.id.tvError);
|
||||
}
|
||||
|
||||
|
@ -99,6 +105,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
ivState.setImageResource(R.drawable.baseline_cloud_off_24);
|
||||
ivState.setVisibility(account.synchronize ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
tvLast.setText(new Date(account.last_connected).toString());
|
||||
tvLast.setVisibility(debug ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvError.setText(account.error);
|
||||
tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
@ -119,6 +128,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
|
||||
AdapterAccount(Context context) {
|
||||
this.context = context;
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
android:id="@+id/ivPrimary"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
|
@ -34,8 +34,8 @@
|
|||
android:id="@+id/tvName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="Name"
|
||||
|
@ -58,8 +58,8 @@
|
|||
android:id="@+id/tvUser"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="user"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivSync"
|
||||
|
@ -70,8 +70,8 @@
|
|||
android:id="@+id/ivState"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
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" />
|
||||
|
@ -80,8 +80,8 @@
|
|||
android:id="@+id/tvHost"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="host"
|
||||
|
@ -91,18 +91,32 @@
|
|||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toTopOf="@id/ivState" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLast"
|
||||
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="Last connected time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvError"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="error"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?attr/colorWarning"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLast" />
|
||||
|
||||
<View
|
||||
android:id="@+id/marginBottom"
|
||||
|
|
Loading…
Reference in a new issue