Simplification

This reverts commit 104fa6f8c4.
This commit is contained in:
M66B 2019-05-23 15:24:44 +02:00
parent a7ce90c2db
commit 6703cb80ac
4 changed files with 8 additions and 37 deletions

View File

@ -63,7 +63,6 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.android.colorpicker.ColorPickerDialog;
import com.android.colorpicker.ColorPickerSwatch;
@ -135,7 +134,6 @@ public class FragmentAccount extends FragmentBase {
private Spinner spLeft;
private Spinner spRight;
private CheckBox cbIdentity;
private Button btnSave;
private ContentLoadingProgressBar pbSave;
private TextView tvError;
@ -213,7 +211,6 @@ public class FragmentAccount extends FragmentBase {
spLeft = view.findViewById(R.id.spLeft);
spRight = view.findViewById(R.id.spRight);
cbIdentity = view.findViewById(R.id.cbIdentity);
btnSave = view.findViewById(R.id.btnSave);
pbSave = view.findViewById(R.id.pbSave);
tvError = view.findViewById(R.id.tvError);
@ -267,7 +264,6 @@ public class FragmentAccount extends FragmentBase {
etPrefix.setText(provider.prefix);
grpFolders.setVisibility(View.GONE);
cbIdentity.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE);
}
@ -459,7 +455,6 @@ public class FragmentAccount extends FragmentBase {
btnCheck.setVisibility(View.GONE);
pbCheck.setVisibility(View.GONE);
cbIdentity.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE);
pbSave.setVisibility(View.GONE);
tvError.setVisibility(View.GONE);
@ -706,7 +701,6 @@ public class FragmentAccount extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
grpFolders.setVisibility(View.GONE);
cbIdentity.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE);
if (ex instanceof IllegalArgumentException)
@ -779,7 +773,7 @@ public class FragmentAccount extends FragmentBase {
args.putSerializable("left", left);
args.putSerializable("right", right);
new SimpleTask<Long>() {
new SimpleTask<Void>() {
@Override
protected void onPreExecute(Bundle args) {
saving = true;
@ -798,7 +792,7 @@ public class FragmentAccount extends FragmentBase {
}
@Override
protected Long onExecute(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
int auth_type = args.getInt("auth_type");
@ -1056,18 +1050,12 @@ public class FragmentAccount extends FragmentBase {
nm.cancel("receive", account.id.intValue());
}
return account.id;
return null;
}
@Override
protected void onExecuted(Bundle args, Long id) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
if (cbIdentity.isChecked()) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(
new Intent(ActivitySetup.ACTION_EDIT_IDENTITY)
.putExtra("account", id));
}
}
@Override
@ -1164,8 +1152,6 @@ public class FragmentAccount extends FragmentBase {
cbBrowse.setChecked(account == null ? true : account.browse);
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
cbIdentity.setChecked(account == null);
color = (account == null || account.color == null ? Color.TRANSPARENT : account.color);
new SimpleTask<EntityAccount>() {
@ -1468,7 +1454,6 @@ public class FragmentAccount extends FragmentBase {
}
grpFolders.setVisibility(folders.size() > 1 ? View.VISIBLE : View.GONE);
cbIdentity.setVisibility(folders.size() > 1 ? View.VISIBLE : View.GONE);
btnSave.setVisibility(folders.size() > 1 ? View.VISIBLE : View.GONE);
}

View File

@ -121,7 +121,6 @@ public class FragmentIdentity extends FragmentBase {
private Group grpAdvanced;
private long id = -1;
private long account = -1;
private boolean saving = false;
private int auth_type = ConnectionHelper.AUTH_TYPE_PASSWORD;
private int color = Color.TRANSPARENT;
@ -134,7 +133,6 @@ public class FragmentIdentity extends FragmentBase {
// Get arguments
Bundle args = getArguments();
id = args.getLong("id", -1);
account = args.getLong("account", -1);
}
@Override
@ -214,11 +212,9 @@ public class FragmentIdentity extends FragmentBase {
auth_type = account.auth_type;
// Select associated provider
if (position == 0) {
if (position == 0)
spProvider.setSelection(0);
etHost.setText(account.host.replace("imap", "smtp"));
etPort.setText(null);
} else {
else {
boolean found = false;
for (int pos = 1; pos < spProvider.getAdapter().getCount(); pos++) {
EmailProvider provider = (EmailProvider) spProvider.getItemAtPosition(pos);
@ -896,7 +892,7 @@ public class FragmentIdentity extends FragmentBase {
spAccount.setSelection(0);
for (int pos = 0; pos < accounts.size(); pos++) {
EntityAccount account = accounts.get(pos);
if (account.id.equals(identity == null ? FragmentIdentity.this.account : identity.account)) {
if (account.id.equals((identity == null ? -1 : identity.account))) {
spAccount.setTag(pos);
spAccount.setSelection(pos);
// OAuth token could be updated

View File

@ -702,15 +702,6 @@
<!-- save -->
<CheckBox
android:id="@+id/cbIdentity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_account_setup_identity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spRight" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
@ -719,7 +710,7 @@
android:tag="disable"
android:text="@string/title_save"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbIdentity" />
app:layout_constraintTop_toBottomOf="@id/spRight" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbSave"

View File

@ -322,7 +322,6 @@
<string name="title_no_sync">Synchronization errors since %1$s</string>
<string name="title_identity_required">An identity is required to send messages</string>
<string name="title_drafts_required">A drafts folder is required to send messages</string>
<string name="title_account_setup_identity">Add an identity after saving this account</string>
<string name="title_account_delete">Delete this account permanently?</string>
<string name="title_identity_delete">Delete this identity permanently?</string>
<string name="title_edit_html">Edit as HTML</string>