1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-24 16:53:37 +00:00

Revised folder waiting state

This commit is contained in:
M66B 2020-10-26 13:21:43 +01:00
parent d22d4553d7
commit e3a57e55ba
5 changed files with 57 additions and 35 deletions

View file

@ -67,7 +67,9 @@ import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -102,6 +104,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private List<TupleFolderEx> all = new ArrayList<>();
private List<TupleFolderEx> items = new ArrayList<>();
private DateFormat DTF;
private NumberFormat NF = NumberFormat.getNumberInstance();
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
@ -223,9 +226,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (folder.executing > 0) {
ivState.setImageResource(R.drawable.twotone_dns_24);
ivState.setContentDescription(context.getString(R.string.title_legend_executing));
} else if ("waiting".equals(folder.state)) {
ivState.setImageResource(R.drawable.twotone_hourglass_top_24);
ivState.setContentDescription(context.getString(R.string.title_legend_waiting));
} else if ("connected".equals(folder.state)) {
ivState.setImageResource(R.drawable.twotone_cloud_done_24);
ivState.setContentDescription(context.getString(R.string.title_legend_connected));
@ -315,7 +315,18 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
else
tvType.setText(EntityFolder.localizeType(context, folder.type));
tvTotal.setText(folder.total == null ? "" : NF.format(folder.total));
StringBuilder t = new StringBuilder();
if (folder.total != null)
t.append(NF.format(folder.total));
if (BuildConfig.DEBUG &&
folder.synchronize && folder.poll && folder.last_sync != null) {
if (t.length() > 0)
t.append(' ');
t.append(DTF.format(folder.last_sync));
}
tvTotal.setText(t.toString());
if (folder.account == null) {
tvAfter.setText(null);
@ -337,8 +348,17 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
a.append(NF.format(folder.keep_days));
tvAfter.setText(a.toString());
ivSync.setImageResource(folder.synchronize ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
ivSync.setContentDescription(context.getString(folder.synchronize ? R.string.title_legend_synchronize_on : R.string.title_legend_synchronize_off));
if (folder.synchronize) {
ivSync.setImageResource(folder.poll
? R.drawable.twotone_hourglass_top_24
: R.drawable.twotone_sync_24);
ivSync.setContentDescription(context.getString(folder.poll
? R.string.title_legend_synchronize_poll
: R.string.title_legend_synchronize_on));
} else {
ivSync.setImageResource(R.drawable.twotone_sync_disabled_24);
ivSync.setContentDescription(context.getString(R.string.title_legend_synchronize_off));
}
}
ivSync.setImageTintList(ColorStateList.valueOf(
folder.synchronize && folder.initialize != 0 && !EntityFolder.OUTBOX.equals(folder.type)
@ -819,6 +839,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
AdapterFolder(Fragment parentFragment, long account, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {
this(parentFragment.getContext(), parentFragment.getViewLifecycleOwner(), account, primary, show_compact, show_hidden, show_flagged, listener);
this.parentFragment = parentFragment;
this.DTF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT);
}
AdapterFolder(Context context, LifecycleOwner owner, long account, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {

View file

@ -2113,6 +2113,7 @@ class Core {
((POP3Message) imessage).invalidate(true);
}
db.folder().setFolderLastSync(folder.id, new Date().getTime());
Log.i(folder.name + " POP done");
} finally {
db.folder().setFolderSyncState(folder.id, null);

View file

@ -1256,6 +1256,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} else {
mapFolders.put(folder, null);
db.folder().setFolderState(folder.id, null);
if (!capIdle && !folder.poll) {
folder.poll = true;
db.folder().setFolderPoll(folder.id, folder.poll);
}
}
}
@ -1424,11 +1428,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.w(folder.name, ex);
}
}
if (!isTransient(account) &&
folder.synchronize && (folder.poll || !capIdle))
db.folder().setFolderState(folder.id, "waiting");
else
db.folder().setFolderState(folder.id, null);
db.folder().setFolderState(folder.id, null);
}
}
} finally {

View file

@ -166,6 +166,28 @@
app:layout_constraintStart_toEndOf="@id/ivSynchronizeOff"
app:layout_constraintTop_toTopOf="@id/ivSynchronizeOff" />
<ImageView
android:id="@+id/ivSynchronizePoll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_synchronize_poll"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivSynchronizeOff"
app:srcCompat="@drawable/twotone_hourglass_top_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSynchronizePoll"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_synchronize_poll"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivSynchronizePoll"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivSynchronizePoll"
app:layout_constraintTop_toTopOf="@id/ivSynchronizePoll" />
<ImageView
android:id="@+id/ivDisconnected"
android:layout_width="wrap_content"
@ -173,7 +195,7 @@
android:contentDescription="@string/title_legend_disconnected"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivSynchronizeOff"
app:layout_constraintTop_toBottomOf="@id/ivSynchronizePoll"
app:srcCompat="@drawable/twotone_cloud_off_24" />
<eu.faircode.email.FixedTextView
@ -319,27 +341,5 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivClosing"
app:layout_constraintTop_toTopOf="@id/ivClosing" />
<ImageView
android:id="@+id/ivWaiting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_waiting"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivClosing"
app:srcCompat="@drawable/twotone_hourglass_top_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvWaiting"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_waiting"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivWaiting"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivWaiting"
app:layout_constraintTop_toTopOf="@id/ivWaiting" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

View file

@ -1202,6 +1202,7 @@
<string name="title_legend_download_off">Download message content on demand</string>
<string name="title_legend_synchronize_on">Synchronize on</string>
<string name="title_legend_synchronize_off">Synchronize off</string>
<string name="title_legend_synchronize_poll">Synchronize periodically</string>
<string name="title_legend_disconnected">Disconnected</string>
<string name="title_legend_connecting">Connecting</string>
<string name="title_legend_connected">Connected</string>
@ -1209,7 +1210,6 @@
<string name="title_legend_synchronizing">Synchronizing</string>
<string name="title_legend_downloading">Downloading</string>
<string name="title_legend_closing">Closing</string>
<string name="title_legend_waiting">Waiting for next synchronization</string>
<string name="title_legend_unified">Unified inbox / primary account</string>
<string name="title_legend_inbox">Inbox</string>