From 71cb5d05fbd0c7d6acc99c2835ae4a017c6ff6f6 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 5 Nov 2020 21:32:36 +0100 Subject: [PATCH] Added related identity for POP3 account --- .../java/eu/faircode/email/FragmentPop.java | 25 ++++++++++++++++++- app/src/main/res/layout/fragment_pop.xml | 11 +++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index c1398c3f30..516290c066 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -48,6 +48,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; +import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.Lifecycle; import com.google.android.material.snackbar.Snackbar; @@ -97,6 +98,7 @@ public class FragmentPop extends FragmentBase { private Button btnSave; private ContentLoadingProgressBar pbSave; + private CheckBox cbIdentity; private TextView tvError; private Group grpError; @@ -156,6 +158,7 @@ public class FragmentPop extends FragmentBase { btnSave = view.findViewById(R.id.btnSave); pbSave = view.findViewById(R.id.pbSave); + cbIdentity = view.findViewById(R.id.cbIdentity); tvError = view.findViewById(R.id.tvError); grpError = view.findViewById(R.id.grpError); @@ -444,6 +447,8 @@ public class FragmentPop extends FragmentBase { db.account().updateAccount(account); else account.id = db.account().insertAccount(account); + + args.putLong("account", account.id); EntityLog.log(context, (update ? "Updated" : "Added") + " account=" + account.name); // Make sure the channel exists on commit @@ -537,7 +542,24 @@ public class FragmentPop extends FragmentBase { @Override protected void onExecuted(Bundle args, Boolean dirty) { - getParentFragmentManager().popBackStack(); + Context context = getContext(); + if (context != null) + WidgetUnified.updateData(context); // Update color stripe + + if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { + getParentFragmentManager().popBackStack(); + + if (cbIdentity.isChecked()) { + Bundle aargs = new Bundle(); + aargs.putLong("account", args.getLong("account")); + + FragmentIdentity fragment = new FragmentIdentity(); + fragment.setArguments(aargs); + FragmentTransaction fragmentTransaction = getParentFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("identity"); + fragmentTransaction.commit(); + } + } } @Override @@ -624,6 +646,7 @@ public class FragmentPop extends FragmentBase { ? EntityAccount.DEFAULT_MAX_MESSAGES : account.max_messages)); etInterval.setText(account == null ? "" : Long.toString(account.poll_interval)); + cbIdentity.setChecked(account == null); List folders = getSwipeActions(); for (int pos = 0; pos < folders.size(); pos++) { diff --git a/app/src/main/res/layout/fragment_pop.xml b/app/src/main/res/layout/fragment_pop.xml index 38c3c4679c..38e0460274 100644 --- a/app/src/main/res/layout/fragment_pop.xml +++ b/app/src/main/res/layout/fragment_pop.xml @@ -464,6 +464,15 @@ app:layout_constraintStart_toEndOf="@id/btnSave" app:layout_constraintTop_toTopOf="@id/btnSave" /> + + + app:layout_constraintTop_toBottomOf="@id/cbIdentity" />