mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-21 21:57:19 +00:00
Improved quick setup flow
This commit is contained in:
parent
a8a51ba029
commit
c3ec3204a3
6 changed files with 61 additions and 19 deletions
|
@ -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();
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibHelp"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -85,6 +84,31 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnQuick" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvQuickError"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="error"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?attr/colorWarning"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQuickRemark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvQuickFailed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_setup_quick_failed"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQuickError" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvInstructions"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -94,7 +118,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQuickRemark" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQuickFailed" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorQuick"
|
||||
|
@ -347,5 +371,11 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbBlackTheme" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpQuickError"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvQuickError,tvQuickFailed" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
|
@ -87,6 +87,9 @@
|
|||
<string name="title_setup_imported">Settings imported</string>
|
||||
<string name="title_setup_quick">Quick config</string>
|
||||
<string name="title_setup_quick_remark">Quick config can be used for most major providers</string>
|
||||
<string name="title_setup_no_settings">No settings found for \'%1$s\'</string>
|
||||
<string name="title_setup_quick_success">An account and an identity have been added. You can review the details below using the \'manage\' buttons.</string>
|
||||
<string name="title_setup_quick_failed">You can try to configure an account and an identity below</string>
|
||||
<string name="title_setup_account">Manage accounts</string>
|
||||
<string name="title_setup_account_remark">To receive email</string>
|
||||
<string name="title_setup_identity">Manage identities</string>
|
||||
|
@ -166,7 +169,6 @@
|
|||
<string name="title_account_notify">Separate notifications</string>
|
||||
<string name="title_domain">Domain name</string>
|
||||
<string name="title_autoconfig">Get settings</string>
|
||||
<string name="title_no_settings">Settings not found</string>
|
||||
<string name="title_imap">IMAP</string>
|
||||
<string name="title_smtp">SMTP</string>
|
||||
<string name="title_provider">Provider</string>
|
||||
|
|
Loading…
Reference in a new issue