mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Widget message/threading
This commit is contained in:
parent
ca352356ec
commit
721d151dc4
4 changed files with 11 additions and 7 deletions
|
@ -283,17 +283,18 @@ public interface DaoMessage {
|
|||
" AND message.ui_snoozed IS NULL" +
|
||||
" AND (NOT :unseen OR NOT message.ui_seen)" +
|
||||
" AND (NOT :flagged OR message.ui_flagged)" +
|
||||
" GROUP BY account.id, CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" +
|
||||
" GROUP BY account.id" +
|
||||
", CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" +
|
||||
" ORDER BY message.received DESC" +
|
||||
" LIMIT 100";
|
||||
|
||||
@Query(widget)
|
||||
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
|
||||
LiveData<List<TupleMessageWidget>> liveWidgetUnified(boolean unseen, boolean flagged);
|
||||
LiveData<List<TupleMessageWidget>> liveWidgetUnified(boolean threading, boolean unseen, boolean flagged);
|
||||
|
||||
@Query(widget)
|
||||
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
|
||||
List<TupleMessageWidget> getWidgetUnified(boolean unseen, boolean flagged);
|
||||
List<TupleMessageWidget> getWidgetUnified(boolean threading, boolean unseen, boolean flagged);
|
||||
|
||||
@Query("SELECT COUNT(message.id) FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
|
|
|
@ -162,6 +162,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("threading", checked).apply();
|
||||
WidgetUnified.update(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
}
|
||||
});
|
||||
|
||||
db.message().liveWidgetUnified(false, false).observe(this, new Observer<List<TupleMessageWidget>>() {
|
||||
db.message().liveWidgetUnified(false, false, false).observe(this, new Observer<List<TupleMessageWidget>>() {
|
||||
private List<TupleMessageWidget> last = null;
|
||||
|
||||
@Override
|
||||
|
@ -230,12 +230,13 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
TupleMessageWidget m1 = last.get(i);
|
||||
TupleMessageWidget m2 = messages.get(i);
|
||||
if (!m1.id.equals(m2.id) ||
|
||||
!Objects.equals(m1.account, m2.account) ||
|
||||
!Objects.equals(m1.accountName, m2.accountName) ||
|
||||
!MessageHelper.equal(m1.from, m2.from) ||
|
||||
!m1.received.equals(m2.received) ||
|
||||
!Objects.equals(m1.subject, m2.subject) ||
|
||||
!(m1.unseen == m2.unseen) ||
|
||||
!(m1.unflagged == m2.unflagged) ||
|
||||
!Objects.equals(m1.accountName, m2.accountName)) {
|
||||
!(m1.unflagged == m2.unflagged)) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
Log.i("Widget factory changed id=" + appWidgetId);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean threading = prefs.getBoolean("threading", true);
|
||||
account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
|
||||
unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
|
||||
flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
|
||||
|
@ -70,7 +71,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
messages.clear();
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
List<TupleMessageWidget> wmessages = db.message().getWidgetUnified(unseen, flagged);
|
||||
List<TupleMessageWidget> wmessages = db.message().getWidgetUnified(threading, unseen, flagged);
|
||||
for (TupleMessageWidget wmessage : wmessages)
|
||||
if (account < 0 || wmessage.account == account)
|
||||
messages.add(wmessage);
|
||||
|
|
Loading…
Reference in a new issue