Showing last account connected time

pull/147/head
M66B 7 years ago
parent b004dbf998
commit a776533dae

@ -21,9 +21,7 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.preference.PreferenceManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -31,10 +29,11 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import java.text.Collator; import java.text.Collator;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -47,11 +46,12 @@ import androidx.recyclerview.widget.RecyclerView;
public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHolder> { public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHolder> {
private Context context; private Context context;
private LayoutInflater inflater; private LayoutInflater inflater;
private boolean debug;
private List<EntityAccount> all = new ArrayList<>(); private List<EntityAccount> all = new ArrayList<>();
private List<EntityAccount> filtered = new ArrayList<>(); private List<EntityAccount> filtered = new ArrayList<>();
private static final DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
View itemView; View itemView;
View vwColor; View vwColor;
@ -106,8 +106,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
ivState.setImageResource(R.drawable.baseline_cloud_off_24); ivState.setImageResource(R.drawable.baseline_cloud_off_24);
ivState.setVisibility(account.synchronize ? View.VISIBLE : View.INVISIBLE); ivState.setVisibility(account.synchronize ? View.VISIBLE : View.INVISIBLE);
tvLast.setText(account.last_connected == null ? null : new Date(account.last_connected).toString()); tvLast.setText(context.getString(R.string.title_last_connected,
tvLast.setVisibility(debug ? View.VISIBLE : View.GONE); account.last_connected == null ? "" : df.format(account.last_connected)));
tvError.setText(account.error); tvError.setText(account.error);
tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE); tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
@ -134,9 +134,6 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
this.context = context; this.context = context;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.debug = prefs.getBoolean("debug", false);
setHasStableIds(true); setHasStableIds(true);
} }

@ -170,25 +170,29 @@ public class EntityAccount {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof EntityAccount) { if (obj instanceof EntityAccount) {
EntityAccount other = (EntityAccount) obj; EntityAccount other = (EntityAccount) obj;
return ((this.name == null ? other.name == null : this.name.equals(other.name)) && return (this.auth_type.equals(other.auth_type) &&
(this.prefix == null ? other.prefix == null : this.prefix.equals(other.prefix)) &&
this.host.equals(other.host) && this.host.equals(other.host) &&
this.starttls == other.starttls && this.starttls == other.starttls &&
this.insecure == other.insecure && this.insecure == other.insecure &&
this.port.equals(other.port) && this.port.equals(other.port) &&
this.user.equals(other.user) && this.user.equals(other.user) &&
this.password.equals(other.password) && this.password.equals(other.password) &&
this.auth_type.equals(other.auth_type) && (this.realm == null ? other.realm == null : this.realm.equals(other.realm)) &&
(this.name == null ? other.name == null : this.name.equals(other.name)) &&
(this.color == null ? other.color == null : this.color.equals(other.color)) &&
this.synchronize.equals(other.synchronize) && this.synchronize.equals(other.synchronize) &&
this.primary.equals(other.primary) && this.primary.equals(other.primary) &&
this.browse.equals(other.browse) &&
(this.color == null ? other.color == null : this.color.equals(other.color)) &&
this.notify.equals(other.notify) && this.notify.equals(other.notify) &&
this.browse.equals(other.browse) &&
(this.swipe_left == null ? other.swipe_left == null : this.swipe_left.equals(other.swipe_left)) &&
(this.swipe_right == null ? other.swipe_right == null : this.swipe_right.equals(other.swipe_right)) &&
this.poll_interval.equals(other.poll_interval) && this.poll_interval.equals(other.poll_interval) &&
(this.prefix == null ? other.prefix == null : this.prefix.equals(other.prefix)) &&
(this.created == null ? other.created == null : this.created.equals(other.created)) && (this.created == null ? other.created == null : this.created.equals(other.created)) &&
(this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) && (this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) &&
(this.state == null ? other.state == null : this.state.equals(other.state)) && (this.state == null ? other.state == null : this.state.equals(other.state)) &&
(this.error == null ? other.error == null : this.error.equals(other.error))); (this.error == null ? other.error == null : this.error.equals(other.error)) ||
(this.last_connected == null ? other.last_connected == null : this.last_connected.equals(other.last_connected)));
} else } else
return false; return false;
} }

@ -80,7 +80,7 @@ public class EntityIdentity {
@NonNull @NonNull
public Boolean read_receipt = false; public Boolean read_receipt = false;
@NonNull @NonNull
public Boolean store_sent = false; // obsolete public Boolean store_sent = false;
public Long sent_folder; // obsolete public Long sent_folder; // obsolete
public Boolean tbd; public Boolean tbd;
public String state; public String state;
@ -167,17 +167,21 @@ public class EntityIdentity {
(this.display == null ? other.display == null : this.display.equals(other.display)) && (this.display == null ? other.display == null : this.display.equals(other.display)) &&
(this.color == null ? other.color == null : this.color.equals(other.color)) && (this.color == null ? other.color == null : this.color.equals(other.color)) &&
(this.signature == null ? other.signature == null : this.signature.equals(other.signature)) && (this.signature == null ? other.signature == null : this.signature.equals(other.signature)) &&
this.auth_type.equals(other.auth_type) &&
this.host.equals(other.host) && this.host.equals(other.host) &&
this.starttls.equals(other.starttls) && this.starttls.equals(other.starttls) &&
this.insecure.equals(other.insecure) && this.insecure.equals(other.insecure) &&
this.port.equals(other.port) && this.port.equals(other.port) &&
this.user.equals(other.user) && this.user.equals(other.user) &&
this.password.equals(other.password) && this.password.equals(other.password) &&
(this.realm == null ? other.realm == null : this.realm.equals(other.realm)) &&
this.synchronize.equals(other.synchronize) && this.synchronize.equals(other.synchronize) &&
this.primary.equals(other.primary) && this.primary.equals(other.primary) &&
(this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) && (this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) &&
(this.bcc == null ? other.bcc == null : this.bcc.equals(other.bcc)) &&
this.delivery_receipt.equals(other.delivery_receipt) && this.delivery_receipt.equals(other.delivery_receipt) &&
this.read_receipt.equals(other.read_receipt) && this.read_receipt.equals(other.read_receipt) &&
this.store_sent.equals(other.store_sent) &&
(this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) && (this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) &&
(this.state == null ? other.state == null : this.state.equals(other.state)) && (this.state == null ? other.state == null : this.state.equals(other.state)) &&
(this.error == null ? other.error == null : this.error.equals(other.error))); (this.error == null ? other.error == null : this.error.equals(other.error)));

@ -221,6 +221,7 @@
<string name="title_identity_delete">Delete this identity permanently?</string> <string name="title_identity_delete">Delete this identity permanently?</string>
<string name="title_pop">POP is not supported</string> <string name="title_pop">POP is not supported</string>
<string name="title_edit_html">Edit as HTML</string> <string name="title_edit_html">Edit as HTML</string>
<string name="title_last_connected">Last connected: %1$s</string>
<string name="title_unseen_count" translatable="false">%1$s (%2$d)</string> <string name="title_unseen_count" translatable="false">%1$s (%2$d)</string>

Loading…
Cancel
Save