Browse Source

Mark outbox messages read on sent

main
M66B 6 years ago
parent
commit
b50646d05e
3 changed files with 18 additions and 5 deletions
  1. +6
    -3
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +3
    -1
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  3. +9
    -1
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 6
- 3
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

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


+ 3
- 1
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

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


+ 9
- 1
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

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