Bring back store sent

This commit is contained in:
M66B 2019-01-19 18:13:48 +00:00
parent 1e2170d594
commit 8ba30c59ee
9 changed files with 85 additions and 72 deletions

8
FAQ.md
View File

@ -980,13 +980,15 @@ but even Google's Chrome cannot handle this.
**(61) Why are some messages shown dimmed?**
Messages shown dimmed are locally moved messages for which the move is not confirmed by the server yet.
This can happen when there is no connection with the server or when the messages are too old to be synchronized.
This can happen when the folder is set to not synchronize, when there is no connection to the server or when the messages are too old to be synchronized.
Eventually, these messages will be synchronized when the connection to the server is restored or will be deleted if they are too old to be synchronized.
Some providers don't store sent messages, in this case messages in the sent folder might never be synchronized.
You can view these messages, but you cannot move these messages again until the previous move has been confirmed by the server.
Some providers don't keep track of sent messages or you might be using an SMTP server not related to the provider.
This will result in messages in the sent folder never to be synchronized.
In these cases you should enable the advanced identity setting *Store sent messages*.
<br />
<a name="faq62"></a>

View File

@ -76,9 +76,9 @@ public class EntityIdentity {
public String replyto;
public String bcc;
@NonNull
public Boolean delivery_receipt;
public Boolean delivery_receipt = false;
@NonNull
public Boolean read_receipt;
public Boolean read_receipt = false;
@NonNull
public Boolean store_sent = false; // obsolete
public Long sent_folder; // obsolete
@ -109,6 +109,7 @@ public class EntityIdentity {
json.put("bcc", bcc);
json.put("delivery_receipt", delivery_receipt);
json.put("read_receipt", read_receipt);
json.put("store_sent", store_sent);
// not state
// not error
return json;
@ -146,13 +147,12 @@ public class EntityIdentity {
if (json.has("delivery_receipt"))
identity.delivery_receipt = json.getBoolean("delivery_receipt");
else
identity.delivery_receipt = false;
if (json.has("read_receipt"))
identity.read_receipt = json.getBoolean("read_receipt");
else
identity.read_receipt = false;
if (json.has("store_sent"))
identity.store_sent = json.getBoolean("store_sent");
return identity;
}

View File

@ -166,13 +166,17 @@ public class EntityOperation {
db.message().countMessageByMsgId(target.id, message.msgid) == 0) {
long id = message.id;
long uid = message.uid;
boolean browsed = message.ui_browsed;
message.id = null;
message.uid = null;
message.folder = target.id;
message.ui_browsed = true;
long newid = db.message().insertMessage(message);
message.id = id;
message.uid = uid;
message.folder = source.id;
message.ui_browsed = browsed;
if (message.content)
try {
Helper.copy(

View File

@ -111,6 +111,8 @@ public class FragmentIdentity extends FragmentBase {
private CheckBox cbDeliveryReceipt;
private CheckBox cbReadReceipt;
private CheckBox cbStoreSent;
private Button btnSave;
private ContentLoadingProgressBar pbSave;
private TextView tvError;
@ -174,6 +176,8 @@ public class FragmentIdentity extends FragmentBase {
cbDeliveryReceipt = view.findViewById(R.id.cbDeliveryReceipt);
cbReadReceipt = view.findViewById(R.id.cbReadReceipt);
cbStoreSent = view.findViewById(R.id.cbStoreSent);
btnSave = view.findViewById(R.id.btnSave);
pbSave = view.findViewById(R.id.pbSave);
tvError = view.findViewById(R.id.tvError);
@ -479,6 +483,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("bcc", etBcc.getText().toString().trim());
args.putBoolean("delivery_receipt", cbDeliveryReceipt.isChecked());
args.putBoolean("read_receipt", cbReadReceipt.isChecked());
args.putBoolean("store_sent", cbStoreSent.isChecked());
args.putLong("account", account == null ? -1 : account.id);
args.putInt("auth_type", account == null || account.auth_type == null ? Helper.AUTH_TYPE_PASSWORD : account.auth_type);
args.putString("host", etHost.getText().toString());
@ -535,6 +540,8 @@ public class FragmentIdentity extends FragmentBase {
String bcc = args.getString("bcc");
boolean delivery_receipt = args.getBoolean("delivery_receipt");
boolean read_receipt = args.getBoolean("read_receipt");
boolean store_sent = args.getBoolean("store_sent");
if (TextUtils.isEmpty(name))
throw new IllegalArgumentException(context.getString(R.string.title_no_name));
@ -633,7 +640,7 @@ public class FragmentIdentity extends FragmentBase {
identity.bcc = bcc;
identity.delivery_receipt = delivery_receipt;
identity.read_receipt = read_receipt;
identity.store_sent = false;
identity.store_sent = store_sent;
identity.sent_folder = null;
identity.error = null;
@ -727,6 +734,7 @@ public class FragmentIdentity extends FragmentBase {
etBcc.setText(identity == null ? null : identity.bcc);
cbDeliveryReceipt.setChecked(identity == null ? false : identity.delivery_receipt);
cbReadReceipt.setChecked(identity == null ? false : identity.read_receipt);
cbStoreSent.setChecked(identity == null ? false : identity.store_sent);
color = (identity == null || identity.color == null ? Color.TRANSPARENT : identity.color);

View File

@ -1311,9 +1311,13 @@ public class FragmentMessages extends FragmentBase {
db.account().livePrimaryAccount().observe(getViewLifecycleOwner(), new Observer<EntityAccount>() {
@Override
public void onChanged(EntityAccount account) {
primary = (account == null ? -1 : account.id);
connected = (account != null && "connected".equals(account.state));
getActivity().invalidateOptionsMenu();
long primary = (account == null ? -1 : account.id);
boolean connected = (account != null && "connected".equals(account.state));
if (FragmentMessages.this.primary != primary || FragmentMessages.this.connected != connected) {
FragmentMessages.this.primary = primary;
FragmentMessages.this.connected = connected;
getActivity().invalidateOptionsMenu();
}
}
});
@ -1360,8 +1364,11 @@ public class FragmentMessages extends FragmentBase {
else
setSubtitle(name);
outbox = EntityFolder.OUTBOX.equals(folder.type);
getActivity().invalidateOptionsMenu();
boolean outbox = EntityFolder.OUTBOX.equals(folder.type);
if (FragmentMessages.this.outbox != outbox) {
FragmentMessages.this.outbox = outbox;
getActivity().invalidateOptionsMenu();
}
}
swipeRefresh.setRefreshing(
@ -1584,8 +1591,6 @@ public class FragmentMessages extends FragmentBase {
(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER));
menu.findItem(R.id.menu_snoozed).setChecked(prefs.getBoolean("snoozed", false));
menu.findItem(R.id.menu_move_sent).setVisible(!selection && outbox);
super.onPrepareOptionsMenu(menu);
}
@ -1629,10 +1634,6 @@ public class FragmentMessages extends FragmentBase {
onMenuSnoozed();
return true;
case R.id.menu_move_sent:
onMenuMoveSent();
return true;
default:
return super.onOptionsItemSelected(item);
}
@ -1688,47 +1689,6 @@ public class FragmentMessages extends FragmentBase {
loadMessages();
}
private void onMenuMoveSent() {
Bundle args = new Bundle();
args.putLong("folder", folder);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long outbox = args.getLong("folder");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
for (EntityMessage message : db.message().getMessageSeen(outbox))
if (message.identity != null) {
EntityIdentity identity = db.identity().getIdentity(message.identity);
EntityFolder sent = db.folder().getFolderByType(identity.account, EntityFolder.SENT);
if (sent != null) {
message.folder = sent.id;
message.uid = null;
db.message().updateMessage(message);
Log.i("Appending sent msgid=" + message.msgid);
EntityOperation.queue(context, db, message, EntityOperation.ADD); // Could already exist
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.execute(this, args, "messages:movesent");
}
private void loadMessages() {
ViewModelBrowse modelBrowse = ViewModelProviders.of(getActivity()).get(ViewModelBrowse.class);
modelBrowse.set(getContext(), folder, search, REMOTE_PAGE_SIZE);

View File

@ -1840,6 +1840,12 @@ public class ServiceSynchronize extends LifecycleService {
db.message().setMessageSent(sid, imessage.getSentDate().getTime());
db.message().setMessageUiHide(sid, false);
db.message().deleteMessage(message.id);
if (ident.store_sent) {
message.id = sid;
message.folder = sent.id;
EntityOperation.queue(this, db, message, EntityOperation.ADD);
}
}
db.setTransactionSuccessful();
@ -2560,6 +2566,12 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");
}
if (message.ui_browsed) {
update = true;
message.ui_browsed = false;
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unbrowse");
}
if (update)
db.message().updateMessage(message);
}

View File

@ -477,13 +477,31 @@
android:id="@+id/tvReceipt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_receipt_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbReadReceipt" />
<CheckBox
android:id="@+id/cbStoreSent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_store_sent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReceipt" />
<TextView
android:id="@+id/tvStoreSent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_identity_store_sent_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbStoreSent" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
@ -491,7 +509,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_save"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReceipt" />
app:layout_constraintTop_toBottomOf="@id/tvStoreSent" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbSave"
@ -532,12 +550,25 @@
android:id="@+id/grpAuthorize"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvName,etName,tvEmail,etEmail,tvDisplay,etDisplay,btnColor,vwColor,ibColorDefault,tvSignature,etSignature,ibPro,btnHtml,btnAdvanced,btnSave" />
app:constraint_referenced_ids="
tvName,etName,tvEmail,etEmail,tvDisplay,etDisplay,
btnColor,vwColor,ibColorDefault,
tvSignature,etSignature,ibPro,btnHtml,
btnAdvanced,btnSave" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpAdvanced"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvReplyTo,etReplyTo,tvBcc,etBcc,cbDeliveryReceipt,cbReadReceipt,tvReceipt,tvProvider,spProvider,tvDomain,tvDomainHint,etDomain,btnAutoConfig,tvSmtp,tvHost,etHost,cbStartTls,cbInsecure,tvPort,etPort,tvUser,etUser,tvPassword,tilPassword,tvRealm,etRealm,cbSynchronize,cbPrimary,tvSent,spSent,tvSentHint" />
app:constraint_referenced_ids="
tvProvider,spProvider,
tvDomain,tvDomainHint,etDomain,btnAutoConfig,
tvSmtp,tvHost,etHost,cbStartTls,cbInsecure,tvPort,etPort,
tvUser,etUser,tvPassword,tilPassword,
tvRealm,etRealm,
cbSynchronize,cbPrimary,
tvReplyTo,etReplyTo,tvBcc,etBcc,
cbDeliveryReceipt,cbReadReceipt,tvReceipt,
cbStoreSent,tvStoreSent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View File

@ -55,9 +55,4 @@
android:checkable="true"
android:title="@string/title_snoozed"
app:showAsAction="never" />
<item
android:id="@+id/menu_move_sent"
android:title="@string/title_move_sent"
app:showAsAction="never" />
</menu>

View File

@ -169,6 +169,8 @@
<string name="title_identity_read_receipt">Request read receipt</string>
<string name="title_identity_delivery_receipt">Request delivery receipt</string>
<string name="title_identity_receipt_remark">Most providers ignore receipt requests</string>
<string name="title_identity_store_sent">Store sent messages</string>
<string name="title_identity_store_sent_remark">Enable this only if your provider does not automatically stores sent messages</string>
<string name="title_optional">Optional</string>
<string name="title_account_linked">Linked account</string>
<string name="title_account_name">Account name</string>
@ -367,7 +369,6 @@
<string name="title_address_unsent">Unsent:</string>
<string name="title_address_invalid">Invalid:</string>
<string name="title_snoozed">Snoozed</string>
<string name="title_move_sent">Move to sent</string>
<string name="title_previous">Previous</string>
<string name="title_next">Next</string>