mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-02 19:10:11 +01:00
Always move sent messages to the sent folder (if any)
This commit is contained in:
@@ -110,7 +110,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
private EditText etBcc;
|
||||
private CheckBox cbDeliveryReceipt;
|
||||
private CheckBox cbReadReceipt;
|
||||
private Spinner spSent;
|
||||
|
||||
private Button btnSave;
|
||||
private ContentLoadingProgressBar pbSave;
|
||||
@@ -123,7 +122,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
|
||||
private long id = -1;
|
||||
private int color = Color.TRANSPARENT;
|
||||
private ArrayAdapter<EntityFolder> adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -175,7 +173,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
etBcc = view.findViewById(R.id.etBcc);
|
||||
cbDeliveryReceipt = view.findViewById(R.id.cbDeliveryReceipt);
|
||||
cbReadReceipt = view.findViewById(R.id.cbReadReceipt);
|
||||
spSent = view.findViewById(R.id.spSent);
|
||||
|
||||
btnSave = view.findViewById(R.id.btnSave);
|
||||
pbSave = view.findViewById(R.id.pbSave);
|
||||
@@ -233,13 +230,10 @@ public class FragmentIdentity extends FragmentBase {
|
||||
etUser.setText(account.user);
|
||||
tilPassword.getEditText().setText(account.password);
|
||||
etRealm.setText(account.realm);
|
||||
|
||||
setFolders(account.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
adapter.clear();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -407,10 +401,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
}
|
||||
});
|
||||
|
||||
adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList<EntityFolder>());
|
||||
adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
||||
spSent.setAdapter(adapter);
|
||||
|
||||
// Initialize
|
||||
Helper.setViewsEnabled(view, false);
|
||||
btnAutoConfig.setEnabled(false);
|
||||
@@ -502,7 +492,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
args.putString("signature", Html.toHtml(etSignature.getText()));
|
||||
args.putBoolean("synchronize", cbSynchronize.isChecked());
|
||||
args.putBoolean("primary", cbPrimary.isChecked());
|
||||
args.putSerializable("sent", (EntityFolder) spSent.getSelectedItem());
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
@@ -546,7 +535,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
String bcc = args.getString("bcc");
|
||||
boolean delivery_receipt = args.getBoolean("delivery_receipt");
|
||||
boolean read_receipt = args.getBoolean("read_receipt");
|
||||
EntityFolder sent = (EntityFolder) args.getSerializable("sent");
|
||||
|
||||
if (TextUtils.isEmpty(name))
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_name));
|
||||
@@ -646,7 +634,7 @@ public class FragmentIdentity extends FragmentBase {
|
||||
identity.delivery_receipt = delivery_receipt;
|
||||
identity.read_receipt = read_receipt;
|
||||
identity.store_sent = false;
|
||||
identity.sent_folder = (sent == null ? null : sent.id);
|
||||
identity.sent_folder = null;
|
||||
identity.error = null;
|
||||
|
||||
if (identity.primary)
|
||||
@@ -838,7 +826,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
// OAuth token could be updated
|
||||
if (pos > 0 && accounts.get(pos).auth_type != Helper.AUTH_TYPE_PASSWORD)
|
||||
tilPassword.getEditText().setText(accounts.get(pos).password);
|
||||
setFolders(account.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -941,64 +928,6 @@ public class FragmentIdentity extends FragmentBase {
|
||||
vwColor.setBackground(border);
|
||||
}
|
||||
|
||||
private void setFolders(long account) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("account", account);
|
||||
args.putLong("identity", id);
|
||||
|
||||
new SimpleTask<IdentityFolders>() {
|
||||
@Override
|
||||
protected IdentityFolders onExecute(Context context, Bundle args) {
|
||||
long aid = args.getLong("account");
|
||||
long iid = args.getLong("identity");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
IdentityFolders result = new IdentityFolders();
|
||||
result.identity = db.identity().getIdentity(iid);
|
||||
result.folders = db.folder().getFolders(aid);
|
||||
|
||||
if (result.folders != null) {
|
||||
for (EntityFolder folder : result.folders)
|
||||
folder.display = folder.getDisplayName(context);
|
||||
EntityFolder.sort(context, result.folders);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, IdentityFolders result) {
|
||||
EntityFolder none = new EntityFolder();
|
||||
none.name = "-";
|
||||
result.folders.add(0, none);
|
||||
|
||||
adapter.clear();
|
||||
adapter.addAll(result.folders);
|
||||
|
||||
if (result.identity != null)
|
||||
for (int pos = 0; pos < result.folders.size(); pos++) {
|
||||
EntityFolder folder = result.folders.get(pos);
|
||||
if (result.identity.store_sent) {
|
||||
if (EntityFolder.SENT.equals(folder.type)) {
|
||||
spSent.setSelection(pos);
|
||||
break;
|
||||
}
|
||||
} else if (result.identity.sent_folder != null) {
|
||||
if (result.identity.sent_folder.equals(folder.id)) {
|
||||
spSent.setSelection(pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
||||
}
|
||||
}.execute(this, args, "identity:folders:get");
|
||||
}
|
||||
|
||||
class IdentityFolders {
|
||||
EntityIdentity identity;
|
||||
List<EntityFolder> folders;
|
||||
|
||||
Reference in New Issue
Block a user