Mark outbox messages read on sent

pull/23/head
M66B 6 years ago
parent 409a9f5b3c
commit b50646d05e

@ -98,7 +98,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new Intent(context, ActivityCompose.class)
.putExtra("id", message.id));
else {
if (!message.seen && !message.ui_seen) {
boolean outbox = EntityFolder.TYPE_OUTBOX.equals(message.folderType);
if (!outbox && !message.seen && !message.ui_seen) {
message.ui_seen = !message.ui_seen;
DB.getInstance(context).message().updateMessage(message);
EntityOperation.queue(context, message, EntityOperation.SEEN, message.ui_seen);
@ -227,8 +228,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
holder.unwire();
TupleMessageEx message = filtered.get(position);
boolean outgoing = EntityFolder.isOutgoing(message.folderType);
boolean outbox = EntityFolder.TYPE_OUTBOX.equals(message.folderType);
if (EntityFolder.isOutgoing(message.folderType)) {
if (outgoing) {
holder.tvFrom.setText(MessageHelper.getFormattedAddresses(message.to));
holder.tvTime.setText(DateUtils.getRelativeTimeSpanString(context, message.received));
} else {
@ -246,7 +249,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
holder.ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
boolean unseen = (message.thread == null ? message.unseen > 0 : !message.seen);
boolean unseen = (message.thread == null && !outbox ? message.unseen > 0 : !message.seen);
int visibility = (unseen ? Typeface.BOLD : Typeface.NORMAL);
holder.tvFrom.setTypeface(null, visibility);

@ -25,6 +25,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
@ -211,12 +212,13 @@ public class FragmentMessage extends FragmentEx {
rvAttachment.setAdapter(adapter);
final DB db = DB.getInstance(getContext());
final boolean debug = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("debug", false);
// Observe message
db.message().liveMessage(id).observe(this, new Observer<TupleMessageEx>() {
@Override
public void onChanged(@Nullable final TupleMessageEx message) {
if (message == null || message.ui_hide) {
if (message == null || (message.ui_hide && !debug)) {
// Message gone (moved, deleted)
if (FragmentMessage.this.isVisible())
getFragmentManager().popBackStack();

@ -790,7 +790,9 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(Helper.TAG, "Sent via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to));
msg.ui_hide = true;
msg.sent = new Date().getTime();
msg.seen = true;
msg.ui_seen = true;
message.updateMessage(msg);
// TODO: purge sent messages
} finally {
@ -860,6 +862,12 @@ public class ServiceSynchronize extends LifecycleService {
// Response codes: https://www.ietf.org/rfc/rfc821.txt
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
// There is probably no use in repeating
operation.deleteOperation(op.id);
reportError(null, folder.name, ex);
} catch (NullPointerException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
// There is probably no use in repeating
operation.deleteOperation(op.id);
reportError(null, folder.name, ex);

Loading…
Cancel
Save