mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 14:17:03 +02:00
Improved error handling
This commit is contained in:
@@ -52,6 +52,7 @@ import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.colorpicker.ColorPickerDialog;
|
||||
import com.android.colorpicker.ColorPickerSwatch;
|
||||
@@ -110,6 +111,8 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
private Button btnSave;
|
||||
private ContentLoadingProgressBar pbSave;
|
||||
private TextView tvError;
|
||||
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
|
||||
private Group grpAuthorize;
|
||||
@@ -149,8 +152,10 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
btnAdvanced = view.findViewById(R.id.btnAdvanced);
|
||||
spProvider = view.findViewById(R.id.spProvider);
|
||||
|
||||
etDomain = view.findViewById(R.id.etDomain);
|
||||
btnAutoConfig = view.findViewById(R.id.btnAutoConfig);
|
||||
|
||||
etHost = view.findViewById(R.id.etHost);
|
||||
cbStartTls = view.findViewById(R.id.cbStartTls);
|
||||
cbInsecure = view.findViewById(R.id.cbInsecure);
|
||||
@@ -169,6 +174,8 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
btnSave = view.findViewById(R.id.btnSave);
|
||||
pbSave = view.findViewById(R.id.pbSave);
|
||||
tvError = view.findViewById(R.id.tvError);
|
||||
|
||||
pbWait = view.findViewById(R.id.pbWait);
|
||||
|
||||
grpAuthorize = view.findViewById(R.id.grpAuthorize);
|
||||
@@ -348,8 +355,6 @@ public class FragmentIdentity extends FragmentEx {
|
||||
}
|
||||
});
|
||||
|
||||
btnAutoConfig.setEnabled(false);
|
||||
|
||||
btnAutoConfig.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -413,10 +418,6 @@ public class FragmentIdentity extends FragmentEx {
|
||||
btnSave.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Helper.setViewsEnabled(view, false);
|
||||
btnSave.setEnabled(false);
|
||||
pbSave.setVisibility(View.VISIBLE);
|
||||
|
||||
EntityAccount account = (EntityAccount) spAccount.getSelectedItem();
|
||||
|
||||
String name = etName.getText().toString();
|
||||
@@ -450,6 +451,21 @@ public class FragmentIdentity extends FragmentEx {
|
||||
args.putSerializable("sent", (EntityFolder) spSent.getSelectedItem());
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected void onInit(Bundle args) {
|
||||
Helper.setViewsEnabled(view, false);
|
||||
btnSave.setEnabled(false);
|
||||
pbSave.setVisibility(View.VISIBLE);
|
||||
tvError.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCleanup(Bundle args) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
btnSave.setEnabled(true);
|
||||
pbSave.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void onLoad(Context context, Bundle args) throws Throwable {
|
||||
long id = args.getLong("id");
|
||||
@@ -596,18 +612,18 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
btnSave.setEnabled(true);
|
||||
pbSave.setVisibility(View.GONE);
|
||||
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||
.setMessage(Helper.formatThrowable(ex))
|
||||
.setPositiveButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
.show();
|
||||
else {
|
||||
tvError.setText(Helper.formatThrowable(ex));
|
||||
tvError.setVisibility(View.VISIBLE);
|
||||
new Handler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((ScrollView) view).smoothScrollTo(0, tvError.getBottom());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}.load(FragmentIdentity.this, args);
|
||||
}
|
||||
@@ -619,11 +635,13 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
// Initialize
|
||||
Helper.setViewsEnabled(view, false);
|
||||
btnAutoConfig.setEnabled(false);
|
||||
cbInsecure.setVisibility(View.GONE);
|
||||
tilPassword.setPasswordVisibilityToggleEnabled(id < 0);
|
||||
btnSave.setVisibility(View.GONE);
|
||||
btnAdvanced.setVisibility(View.GONE);
|
||||
pbSave.setVisibility(View.GONE);
|
||||
tvError.setVisibility(View.GONE);
|
||||
|
||||
grpAuthorize.setVisibility(View.GONE);
|
||||
grpAdvanced.setVisibility(View.GONE);
|
||||
|
||||
Reference in New Issue
Block a user