Bring back store sent

This commit is contained in:
M66B 2019-02-17 16:35:01 +00:00
parent a5a727b900
commit 72de959ceb
6 changed files with 53 additions and 9 deletions

View File

@ -265,6 +265,9 @@ public interface DaoMessage {
@Update
int updateMessage(EntityMessage message);
@Query("UPDATE message SET folder = :folder WHERE id = :id")
int setMessageFolder(long id, long folder);
@Query("UPDATE message SET uid = :uid WHERE id = :id")
int setMessageUid(long id, long uid);

View File

@ -82,7 +82,7 @@ public class EntityIdentity {
@NonNull
public Boolean read_receipt = false;
@NonNull
public Boolean store_sent = false; // obsolete
public Boolean store_sent = false;
public Long sent_folder = null; // obsolete
public Boolean tbd;
public String state;
@ -122,6 +122,7 @@ public class EntityIdentity {
json.put("plain_only", plain_only);
json.put("delivery_receipt", delivery_receipt);
json.put("read_receipt", read_receipt);
json.put("store_sent", store_sent);
// not state
// not error
return json;
@ -164,6 +165,9 @@ public class EntityIdentity {
if (json.has("read_receipt"))
identity.read_receipt = json.getBoolean("read_receipt");
if (json.has("store_sent"))
identity.store_sent = json.getBoolean("store_sent");
return identity;
}
@ -191,6 +195,7 @@ public class EntityIdentity {
(this.bcc == null ? other.bcc == null : this.bcc.equals(other.bcc)) &&
this.delivery_receipt.equals(other.delivery_receipt) &&
this.read_receipt.equals(other.read_receipt) &&
this.store_sent.equals(other.store_sent) &&
(this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) &&
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
(this.error == null ? other.error == null : this.error.equals(other.error)) &&

View File

@ -102,6 +102,8 @@ public class FragmentIdentity extends FragmentBase {
private CheckBox cbDeliveryReceipt;
private CheckBox cbReadReceipt;
private CheckBox cbStoreSent;
private Button btnSave;
private ContentLoadingProgressBar pbSave;
private TextView tvError;
@ -167,6 +169,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);
@ -463,6 +467,7 @@ public class FragmentIdentity extends FragmentBase {
args.putBoolean("plain_only", cbPlainOnly.isChecked());
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", auth_type);
args.putString("host", etHost.getText().toString());
@ -522,6 +527,7 @@ public class FragmentIdentity extends FragmentBase {
boolean plain_only = args.getBoolean("plain_only");
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));
@ -626,6 +632,8 @@ public class FragmentIdentity extends FragmentBase {
identity.plain_only = plain_only;
identity.delivery_receipt = delivery_receipt;
identity.read_receipt = read_receipt;
identity.store_sent = store_sent;
identity.sent_folder = null;
identity.error = null;
identity.last_connected = last_connected;
@ -726,6 +734,7 @@ public class FragmentIdentity extends FragmentBase {
cbPlainOnly.setChecked(identity == null ? false : identity.plain_only);
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

@ -1987,7 +1987,13 @@ public class ServiceSynchronize extends LifecycleService {
EntityLog.log(this, "Sent via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to));
// Append replied/forwarded text
StringBuilder sb = new StringBuilder();
sb.append(Helper.readText(EntityMessage.getFile(this, message.id)));
File refFile = EntityMessage.getRefFile(this, message.id);
if (refFile.exists())
sb.append(Helper.readText(refFile));
Helper.writeText(EntityMessage.getFile(this, message.id), sb.toString());
try {
db.beginTransaction();
@ -1997,13 +2003,13 @@ public class ServiceSynchronize extends LifecycleService {
db.message().setMessageUiSeen(message.id, true);
db.message().setMessageError(message.id, null);
// Append replied/forwarded text
StringBuilder sb = new StringBuilder();
sb.append(Helper.readText(EntityMessage.getFile(this, message.id)));
if (refFile.exists())
sb.append(Helper.readText(refFile));
Helper.writeText(EntityMessage.getFile(this, message.id), sb.toString());
EntityFolder sent = db.folder().getFolderByType(message.account, EntityFolder.SENT);
if (ident.store_sent && sent != null) {
db.message().setMessageFolder(message.id, sent.id);
message.folder = sent.id;
EntityOperation.queue(this, db, message, EntityOperation.ADD);
} else
db.message().setMessageUiHide(message.id, true);
db.setTransactionSuccessful();
} finally {

View File

@ -485,6 +485,25 @@
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"
@ -493,7 +512,7 @@
android:tag="disable"
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"

View File

@ -199,6 +199,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>