mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-29 21:34:44 +02:00
Improved quick setup flow
This commit is contained in:
@@ -62,7 +62,7 @@ import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
import com.sun.mail.imap.IMAPStore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -294,8 +294,8 @@ public class FragmentAccount extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IOException)
|
||||
Snackbar.make(view, R.string.title_no_settings, Snackbar.LENGTH_LONG).show();
|
||||
if (ex instanceof IllegalArgumentException || ex instanceof UnknownHostException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ import com.android.colorpicker.ColorPickerSwatch;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@@ -387,8 +387,8 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IOException)
|
||||
Snackbar.make(view, R.string.title_no_settings, Snackbar.LENGTH_LONG).show();
|
||||
if (ex instanceof IllegalArgumentException || ex instanceof UnknownHostException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ import javax.mail.Transport;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.LiveData;
|
||||
@@ -106,6 +107,8 @@ public class FragmentSetup extends FragmentEx {
|
||||
private EditText etEmail;
|
||||
private TextInputLayout tilPassword;
|
||||
private Button btnQuick;
|
||||
private TextView tvQuickError;
|
||||
private Group grpQuickError;
|
||||
private TextView tvInstructions;
|
||||
|
||||
private Button btnAccount;
|
||||
@@ -156,6 +159,8 @@ public class FragmentSetup extends FragmentEx {
|
||||
etEmail = view.findViewById(R.id.etEmail);
|
||||
tilPassword = view.findViewById(R.id.tilPassword);
|
||||
btnQuick = view.findViewById(R.id.btnQuick);
|
||||
tvQuickError = view.findViewById(R.id.tvQuickError);
|
||||
grpQuickError = view.findViewById(R.id.grpQuickError);
|
||||
tvInstructions = view.findViewById(R.id.tvInstructions);
|
||||
|
||||
btnAccount = view.findViewById(R.id.btnAccount);
|
||||
@@ -205,6 +210,8 @@ public class FragmentSetup extends FragmentEx {
|
||||
etEmail.setEnabled(false);
|
||||
tilPassword.setEnabled(false);
|
||||
btnQuick.setEnabled(false);
|
||||
grpQuickError.setVisibility(View.GONE);
|
||||
tvInstructions.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -385,7 +392,11 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onLoaded(Bundle args, Void data) {
|
||||
finish();
|
||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||
.setMessage(R.string.title_setup_quick_success)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -397,12 +408,10 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
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 {
|
||||
tvQuickError.setText(Helper.formatThrowable(ex));
|
||||
grpQuickError.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}.load(FragmentSetup.this, args);
|
||||
}
|
||||
@@ -524,6 +533,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
// Initialize
|
||||
ibHelp.setVisibility(View.GONE);
|
||||
grpQuickError.setVisibility(View.GONE);
|
||||
tvInstructions.setVisibility(View.GONE);
|
||||
tvInstructions.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public class Provider {
|
||||
return Provider.fromDNS(domain);
|
||||
} catch (UnknownHostException ex1) {
|
||||
Log.w(ex1);
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_settings));
|
||||
throw new UnknownHostException(context.getString(R.string.title_setup_no_settings, domain));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,8 +335,8 @@ public class Provider {
|
||||
private static SRVRecord lookup(String dns) throws TextParseException, UnknownHostException {
|
||||
Lookup lookup = new Lookup(dns, Type.SRV);
|
||||
|
||||
// https://dns.watch/
|
||||
SimpleResolver resolver = new SimpleResolver("84.200.69.80");
|
||||
// https://dns.watch/ 84.200.69.80
|
||||
SimpleResolver resolver = new SimpleResolver("8.8.8.8");
|
||||
lookup.setResolver(resolver);
|
||||
Log.i("Lookup dns=" + dns + " @" + resolver.getAddress());
|
||||
Record[] records = lookup.run();
|
||||
|
||||
Reference in New Issue
Block a user