mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 04:19:21 +01:00
Bring back store sent
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user