Added debug info to messages

pull/23/head
M66B 6 years ago
parent 9bb4e9b92d
commit 267e08685c

@ -239,7 +239,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
holder.tvSubject.setText(message.subject);
if (viewType == ViewType.FOLDER) {
holder.tvCount.setText((debug ? message.uid + "/" + message.id : "") + Integer.toString(message.count));
String extra = (message.ui_hide ? "HIDDEN " : "") + message.uid + "/" + message.id;
holder.tvCount.setText((debug ? extra + " " : "") + Integer.toString(message.count));
holder.tvCount.setVisibility(debug || message.count > 1 ? View.VISIBLE : View.GONE);
} else
holder.tvCount.setText(Helper.localizeFolderName(context, message.folderName));

@ -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<List<TupleMessageEx>> liveUnifiedInbox();
LiveData<List<TupleMessageEx>> 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<List<TupleMessageEx>> liveMessages(long folder);
LiveData<List<TupleMessageEx>> 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<List<TupleMessageEx>> liveThread(long msgid);
" WHERE NOT message.ui_hide OR :debug")
LiveData<List<TupleMessageEx>> liveThread(long msgid, boolean debug);
@Query("SELECT * FROM message WHERE id = :id")
EntityMessage getMessage(long id);

@ -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<TupleFolderEx>() {
@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();

@ -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 {

Loading…
Cancel
Save