From 267e08685ce586ee1887affabe471eba1a9d8571 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 6 Aug 2018 14:04:35 +0000 Subject: [PATCH] Added debug info to messages --- .idea/caches/build_file_checksums.ser | Bin 535 -> 535 bytes .../java/eu/faircode/email/AdapterMessage.java | 3 ++- .../main/java/eu/faircode/email/DaoMessage.java | 12 ++++++------ .../eu/faircode/email/FragmentMessages.java | 8 +++++--- .../eu/faircode/email/ServiceSynchronize.java | 11 +++++++---- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 17cfb1a4fa98b548cccfa449d8a63a423ab6f3d2..3800d0d5e57e6caa717dace4c2f530f092d657aa 100644 GIT binary patch delta 33 rcmV++0N($X1eXMmm;?`9tzfa7Y5@_jm3OVB|IA!MMq;RW1U~6_=jaZI delta 33 pcmbQvGM#0@3>NN&{b?KLWHAb|ZIofwY~S2)lmEJ=^2_VjDge;F4XywH diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 4092525ead..07802de8c3 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -239,7 +239,8 @@ public class AdapterMessage extends RecyclerView.Adapter 1 ? View.VISIBLE : View.GONE); } else holder.tvCount.setText(Helper.localizeFolderName(context, message.folderName)); diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index c70985cfba..8bf28534e2 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -37,11 +37,11 @@ public interface DaoMessage { " FROM folder" + " JOIN message ON folder = folder.id" + " WHERE folder.type = '" + EntityFolder.TYPE_INBOX + "'" + - " AND NOT ui_hide" + + " AND (NOT ui_hide OR :debug)" + " AND received IN (SELECT MAX(m.received) FROM message m WHERE m.folder = message.folder" + " GROUP BY CASE WHEN m.thread IS NULL THEN m.id ELSE m.thread END)") // in theory the message id and thread could be the same - LiveData> liveUnifiedInbox(); + LiveData> liveUnifiedInbox(boolean debug); @Query("SELECT message.*, folder.name as folderName, folder.type as folderType" + ", (SELECT COUNT(m.id) FROM message m WHERE m.account = message.account AND m.thread = message.thread) AS count" + @@ -50,10 +50,10 @@ public interface DaoMessage { " FROM folder" + " JOIN message ON folder = folder.id" + " WHERE folder.id = :folder" + - " AND NOT ui_hide" + + " AND (NOT ui_hide OR :debug)" + " AND received IN (SELECT MAX(m.received) FROM message m WHERE m.folder = message.folder" + " GROUP BY CASE WHEN m.thread IS NULL THEN m.id ELSE m.thread END)") - LiveData> liveMessages(long folder); + LiveData> liveMessages(long folder, boolean debug); @Query("SELECT message.*, folder.name as folderName, folder.type as folderType" + ", (SELECT COUNT(m.id) FROM message m WHERE m.account = message.account AND m.thread = message.thread) AS count" + @@ -62,8 +62,8 @@ public interface DaoMessage { " FROM message" + " JOIN folder ON folder.id = message.folder" + " JOIN message m1 ON m1.id = :msgid AND m1.account = message.account AND m1.thread = message.thread" + - " WHERE NOT message.ui_hide") - LiveData> liveThread(long msgid); + " WHERE NOT message.ui_hide OR :debug") + LiveData> liveThread(long msgid, boolean debug); @Query("SELECT * FROM message WHERE id = :id") EntityMessage getMessage(long id); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 4314e8e84b..cfb391c192 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -23,6 +23,7 @@ import android.arch.lifecycle.Observer; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.constraint.Group; @@ -95,10 +96,11 @@ public class FragmentMessages extends FragmentEx { DB db = DB.getInstance(getContext()); // Observe folder/messages + boolean debug = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("debug", false); if (thread < 0) if (folder < 0) { setSubtitle(R.string.title_folder_unified); - db.message().liveUnifiedInbox().observe(this, messagesObserver); + db.message().liveUnifiedInbox(debug).observe(this, messagesObserver); } else { DB.getInstance(getContext()).folder().liveFolderEx(folder).observe(this, new Observer() { @Override @@ -106,11 +108,11 @@ public class FragmentMessages extends FragmentEx { setSubtitle(folder == null ? null : Helper.localizeFolderName(getContext(), folder.name)); } }); - db.message().liveMessages(folder).observe(this, messagesObserver); + db.message().liveMessages(folder, debug).observe(this, messagesObserver); } else { setSubtitle(R.string.title_folder_thread); - db.message().liveThread(thread).observe(this, messagesObserver); + db.message().liveThread(thread, debug).observe(this, messagesObserver); } getLoaderManager().restartLoader(ActivityView.LOADER_MESSAGES_INIT, new Bundle(), initLoaderCallbacks).forceLoad(); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 0bcca602ef..a511687f9b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -975,7 +975,7 @@ public class ServiceSynchronize extends LifecycleService { } // Add/update local messages - Log.i(Helper.TAG, folder.name + " added count=" + imessages.length); + Log.i(Helper.TAG, folder.name + " add=" + imessages.length); for (int batch = 0; batch < imessages.length; batch += FETCH_BATCH_SIZE) { Log.i(Helper.TAG, folder.name + " fetch @" + batch); try { @@ -1057,10 +1057,10 @@ public class ServiceSynchronize extends LifecycleService { if (update) { db.message().updateMessage(message); - Log.i(Helper.TAG, folder.name + " updated id=" + message.id); + Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid); } else { message.id = db.message().insertMessage(message); - Log.i(Helper.TAG, folder.name + " added id=" + message.id); + Log.i(Helper.TAG, folder.name + " added id=" + message.id + " uid=" + message.uid); } int sequence = 0; @@ -1075,8 +1075,11 @@ public class ServiceSynchronize extends LifecycleService { } else if (message.seen != seen) { message.seen = seen; message.ui_seen = seen; + // TODO: synchronize all data? db.message().updateMessage(message); - Log.i(Helper.TAG, folder.name + " updated id=" + message.id); + Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid); + } else { + Log.i(Helper.TAG, folder.name + " unchanged id=" + message.id + " uid=" + message.uid); } } finally {