mirror of https://github.com/M66B/FairEmail.git
Show last folder sync time in nav menu
This commit is contained in:
parent
7b21f6a24e
commit
ddb75168ec
|
@ -62,7 +62,7 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
private boolean nav_count_pinned;
|
||||
private boolean nav_unseen_drafts;
|
||||
private boolean nav_categories;
|
||||
|
||||
private boolean last_sync_time;
|
||||
|
||||
private int dp6;
|
||||
private int dp12;
|
||||
|
@ -167,17 +167,20 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
tvItem.setTypeface(count == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
|
||||
tvItem.setVisibility(expanded ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (account.folderName == null) {
|
||||
if (account.last_connected != null && expanded) {
|
||||
if (account.folderName == null || last_sync_time) {
|
||||
Long last_connected = (account.folderName == null
|
||||
? account.last_connected
|
||||
: account.folderLastSync);
|
||||
if (last_connected != null && expanded) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
if (account.last_connected < cal.getTimeInMillis())
|
||||
tvItemExtra.setText(DF.format(account.last_connected));
|
||||
if (last_connected < cal.getTimeInMillis())
|
||||
tvItemExtra.setText(DF.format(last_connected));
|
||||
else
|
||||
tvItemExtra.setText(TF.format(account.last_connected));
|
||||
tvItemExtra.setText(TF.format(last_connected));
|
||||
tvItemExtra.setVisibility(View.VISIBLE);
|
||||
} else
|
||||
tvItemExtra.setVisibility(View.GONE);
|
||||
|
@ -289,6 +292,8 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
this.nav_count_pinned = prefs.getBoolean("nav_count_pinned", false);
|
||||
this.nav_unseen_drafts = prefs.getBoolean("nav_unseen_drafts", false);
|
||||
this.nav_categories = prefs.getBoolean("nav_categories", false);
|
||||
this.last_sync_time = prefs.getBoolean("last_sync_time", false);
|
||||
|
||||
boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
|
||||
int colorHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight));
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ public interface DaoAccount {
|
|||
", NULL AS folderId, NULL AS folderSeparator" +
|
||||
", NULL AS folderType, -1 AS folderOrder" +
|
||||
", NULL AS folderName, NULL AS folderDisplay, NULL AS folderColor" +
|
||||
", 0 AS folderSync, NULL AS folderState, NULL AS folderSyncState" +
|
||||
", 0 AS folderSync, NULL AS folderState" +
|
||||
", NULL AS folderSyncState, NULL AS folderLastSync" +
|
||||
", 0 AS executing" +
|
||||
", 0 AS messages" +
|
||||
", (SELECT COUNT(DISTINCT" +
|
||||
|
@ -110,7 +111,8 @@ public interface DaoAccount {
|
|||
", folder.id AS folderId, folder.separator AS folderSeparator" +
|
||||
", folder.type AS folderType, folder.`order` AS folderOrder" +
|
||||
", folder.name AS folderName, folder.display AS folderDisplay, folder.color AS folderColor" +
|
||||
", folder.synchronize AS folderSync, folder.state AS foldeState, folder.sync_state AS folderSyncState" +
|
||||
", folder.synchronize AS folderSync, folder.state AS foldeState" +
|
||||
", folder.sync_state AS folderSyncState, folder.last_sync AS folderLastSync" +
|
||||
", (SELECT COUNT(operation.id) FROM operation" +
|
||||
" WHERE operation.folder = folder.id" +
|
||||
" AND state = 'executing') AS executing" +
|
||||
|
|
|
@ -262,7 +262,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private ImageButton ibHintSwipe;
|
||||
private ImageButton ibHintSelect;
|
||||
private ImageButton ibHintJunk;
|
||||
private TextView tvLastSync;
|
||||
private TextView tvNoEmail;
|
||||
private TextView tvNoEmailHint;
|
||||
private FixedRecyclerView rvMessage;
|
||||
|
@ -280,7 +279,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private BottomNavigationView bottom_navigation;
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpAirplane;
|
||||
private Group grpLastSync;
|
||||
private Group grpSupport;
|
||||
private Group grpHintSupport;
|
||||
private Group grpHintSwipe;
|
||||
|
@ -338,7 +336,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private boolean quick_scroll;
|
||||
private boolean addresses;
|
||||
private boolean swipe_reply;
|
||||
private boolean last_sync_time;
|
||||
|
||||
private int colorPrimary;
|
||||
private int colorAccent;
|
||||
|
@ -372,7 +369,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private Boolean lastRefreshing;
|
||||
private Boolean lastFolderErrors;
|
||||
private Boolean lastAccountErrors;
|
||||
private Long lastSyncTime;
|
||||
|
||||
final private Map<String, String> kv = new HashMap<>();
|
||||
final private Map<String, List<Long>> values = new HashMap<>();
|
||||
|
@ -388,7 +384,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private static final int MAX_SEND_RAW = 50; // messages
|
||||
private static final int SWIPE_DISABLE_SELECT_DURATION = 1500; // milliseconds
|
||||
private static final float LUMINANCE_THRESHOLD = 0.7f;
|
||||
private static final long MAX_SYNC_AGE = 24 * 3600 * 1000L;
|
||||
|
||||
private static final int REQUEST_RAW = 1;
|
||||
private static final int REQUEST_OPENPGP = 4;
|
||||
|
@ -477,7 +472,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
quick_scroll = prefs.getBoolean("quick_scroll", true);
|
||||
addresses = prefs.getBoolean("addresses", false);
|
||||
swipe_reply = prefs.getBoolean("swipe_reply", false);
|
||||
last_sync_time = prefs.getBoolean("last_sync_time", false);
|
||||
|
||||
colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary);
|
||||
colorAccent = Helper.resolveColor(getContext(), R.attr.colorAccent);
|
||||
|
@ -532,7 +526,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
ibHintSwipe = view.findViewById(R.id.ibHintSwipe);
|
||||
ibHintSelect = view.findViewById(R.id.ibHintSelect);
|
||||
ibHintJunk = view.findViewById(R.id.ibHintJunk);
|
||||
tvLastSync = view.findViewById(R.id.tvLastSync);
|
||||
tvNoEmail = view.findViewById(R.id.tvNoEmail);
|
||||
tvNoEmailHint = view.findViewById(R.id.tvNoEmailHint);
|
||||
rvMessage = view.findViewById(R.id.rvMessage);
|
||||
|
@ -551,7 +544,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
pbWait = view.findViewById(R.id.pbWait);
|
||||
grpAirplane = view.findViewById(R.id.grpAirplane);
|
||||
grpLastSync = view.findViewById(R.id.grpLastSync);
|
||||
grpSupport = view.findViewById(R.id.grpSupport);
|
||||
grpHintSupport = view.findViewById(R.id.grpHintSupport);
|
||||
grpHintSwipe = view.findViewById(R.id.grpHintSwipe);
|
||||
|
@ -1487,7 +1479,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
// Initialize
|
||||
FragmentDialogTheme.setBackground(getContext(), view, false);
|
||||
grpAirplane.setVisibility(View.GONE);
|
||||
grpLastSync.setVisibility(View.GONE);
|
||||
tvNoEmail.setVisibility(View.GONE);
|
||||
tvNoEmailHint.setVisibility(View.GONE);
|
||||
etSearch.setVisibility(View.GONE);
|
||||
|
@ -5705,20 +5696,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
}
|
||||
|
||||
Long syncTime = null;
|
||||
if (viewType == AdapterMessage.ViewType.FOLDER &&
|
||||
last_sync_time && folders.size() == 1) {
|
||||
syncTime = folders.get(0).last_sync;
|
||||
if (syncTime != null &&
|
||||
new Date().getTime() - syncTime < MAX_SYNC_AGE)
|
||||
syncTime = null;
|
||||
}
|
||||
|
||||
if (Objects.equals(lastUnseen, unseen) &&
|
||||
Objects.equals(lastRefreshing, refreshing) &&
|
||||
Objects.equals(lastFolderErrors, folderErrors) &&
|
||||
Objects.equals(lastAccountErrors, accountErrors) &&
|
||||
Objects.equals(lastSyncTime, syncTime)) {
|
||||
Objects.equals(lastAccountErrors, accountErrors)) {
|
||||
Log.i("Folder state unchanged");
|
||||
return;
|
||||
}
|
||||
|
@ -5727,7 +5708,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
lastRefreshing = refreshing;
|
||||
lastFolderErrors = folderErrors;
|
||||
lastAccountErrors = accountErrors;
|
||||
lastSyncTime = syncTime;
|
||||
|
||||
// Get name
|
||||
String name;
|
||||
|
@ -5753,10 +5733,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
name = getString(R.string.title_name_count, name, NF.format(unseen));
|
||||
setSubtitle(name);
|
||||
|
||||
tvLastSync.setText(syncTime == null ? null
|
||||
: DateUtils.getRelativeTimeSpanString(context, syncTime, true));
|
||||
grpLastSync.setVisibility(syncTime == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
fabError.setTag(accountErrors);
|
||||
if (folderErrors || accountErrors)
|
||||
fabError.show();
|
||||
|
|
|
@ -34,6 +34,7 @@ public class TupleAccountFolder extends EntityAccount {
|
|||
public boolean folderSync;
|
||||
public String folderState;
|
||||
public String folderSyncState;
|
||||
public Long folderLastSync;
|
||||
public int executing;
|
||||
public int messages;
|
||||
public int unseen;
|
||||
|
@ -73,6 +74,7 @@ public class TupleAccountFolder extends EntityAccount {
|
|||
this.folderSync == other.folderSync &&
|
||||
Objects.equals(this.folderState, other.folderState) &&
|
||||
Objects.equals(this.folderSyncState, other.folderSyncState) &&
|
||||
Objects.equals(this.folderLastSync, other.folderLastSync) &&
|
||||
this.executing == other.executing &&
|
||||
this.messages == other.messages &&
|
||||
this.unseen == other.unseen);
|
||||
|
|
|
@ -192,26 +192,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHintJunk" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvLastSync"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:text="@string/title_last_connected"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintJunk" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorLastSync"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLastSync" />
|
||||
|
||||
<include
|
||||
android:id="@+id/inGroup"
|
||||
layout="@layout/item_group"
|
||||
|
@ -219,7 +199,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorLastSync" />
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintJunk" />
|
||||
|
||||
<eu.faircode.email.ViewTextDelayed
|
||||
android:id="@+id/tvNoEmail"
|
||||
|
@ -449,12 +429,6 @@
|
|||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvAirplane,vSeparatorAirplane" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpLastSync"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvLastSync,vSeparatorLastSync" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpSupport"
|
||||
android:layout_width="0dp"
|
||||
|
|
Loading…
Reference in New Issue