Show send errors in message lists

pull/199/head
M66B 4 years ago
parent fe07b6f954
commit db2128dcd3

@ -245,11 +245,12 @@ public interface DaoMessage {
boolean filter_archive, boolean filter_archive,
boolean ascending, boolean debug); boolean ascending, boolean debug);
@Query("SELECT COUNT(*) FROM message" + @Query("SELECT COUNT(*) AS pending, SUM(message.error IS NOT NULL) AS errors" +
" FROM message" +
" JOIN folder_view AS folder ON folder.id = message.folder" + " JOIN folder_view AS folder ON folder.id = message.folder" +
" WHERE " + is_outbox + " WHERE " + is_outbox +
" AND NOT ui_snoozed IS NULL") " AND (NOT message.ui_snoozed IS NULL OR message.error IS NOT NULL)")
LiveData<Integer> liveOutboxPending(); LiveData<TupleOutboxStats> liveOutboxPending();
@Query("SELECT account.name AS accountName" + @Query("SELECT account.name AS accountName" +
", COUNT(message.id) AS count" + ", COUNT(message.id) AS count" +

@ -314,6 +314,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private int colorPrimary; private int colorPrimary;
private int colorAccent; private int colorAccent;
private int colorSeparator;
private int colorWarning;
private long primary; private long primary;
private boolean connected; private boolean connected;
@ -431,6 +433,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary); colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary);
colorAccent = Helper.resolveColor(getContext(), R.attr.colorAccent); colorAccent = Helper.resolveColor(getContext(), R.attr.colorAccent);
colorSeparator = Helper.resolveColor(getContext(), R.attr.colorSeparator);
colorWarning = Helper.resolveColor(getContext(), R.attr.colorWarning);
if (criteria == null) if (criteria == null)
if (thread == null) { if (thread == null) {
@ -3998,16 +4002,26 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
break; break;
} }
if (send_pending && if (!EntityFolder.OUTBOX.equals(type) &&
(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER)) (viewType == AdapterMessage.ViewType.UNIFIED ||
db.message().liveOutboxPending().observe(getViewLifecycleOwner(), new Observer<Integer>() { viewType == AdapterMessage.ViewType.FOLDER))
db.message().liveOutboxPending().observe(getViewLifecycleOwner(), new Observer<TupleOutboxStats>() {
@Override @Override
public void onChanged(Integer pending) { public void onChanged(TupleOutboxStats stats) {
if (pending != null && pending > 10) int pending = (stats == null || stats.pending == null ? 0 : stats.pending);
int errors = (stats == null || stats.errors == null ? 0 : stats.errors);
int count = (send_pending ? pending : errors);
if (count > 10)
tvOutboxCount.setText("+"); tvOutboxCount.setText("+");
else else
tvOutboxCount.setText(pending == null || pending == 0 ? null : NF.format(pending)); tvOutboxCount.setText(count == 0 ? null : NF.format(count));
grpOutbox.setVisibility(pending == null || pending == 0 ? View.GONE : View.VISIBLE);
int color = (errors == 0 ? colorSeparator : colorWarning);
ibOutbox.setImageTintList(ColorStateList.valueOf(color));
tvOutboxCount.setTextColor(color);
grpOutbox.setVisibility(count == 0 ? View.GONE : View.VISIBLE);
} }
}); });

@ -0,0 +1,25 @@
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FairEmail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/
public class TupleOutboxStats {
Integer pending;
Integer errors;
}
Loading…
Cancel
Save