Show send errors in message lists

This commit is contained in:
M66B 2021-07-03 15:13:20 +02:00
parent fe07b6f954
commit db2128dcd3
3 changed files with 50 additions and 10 deletions

View File

@ -245,11 +245,12 @@ public interface DaoMessage {
boolean filter_archive,
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" +
" WHERE " + is_outbox +
" AND NOT ui_snoozed IS NULL")
LiveData<Integer> liveOutboxPending();
" AND (NOT message.ui_snoozed IS NULL OR message.error IS NOT NULL)")
LiveData<TupleOutboxStats> liveOutboxPending();
@Query("SELECT account.name AS accountName" +
", COUNT(message.id) AS count" +

View File

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

View File

@ -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;
}