Added related identity for POP3 account

This commit is contained in:
M66B 2020-11-05 21:32:36 +01:00
parent eac3f3d58f
commit 71cb5d05fb
2 changed files with 34 additions and 2 deletions

View File

@ -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<EntityFolder> folders = getSwipeActions();
for (int pos = 0; pos < folders.size(); pos++) {

View File

@ -464,6 +464,15 @@
app:layout_constraintStart_toEndOf="@id/btnSave"
app:layout_constraintTop_toTopOf="@id/btnSave" />
<CheckBox
android:id="@+id/cbIdentity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_related_identity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnSave" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvErrorTitle"
android:layout_width="wrap_content"
@ -473,7 +482,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnSave" />
app:layout_constraintTop_toBottomOf="@id/cbIdentity" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvError"