diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java
index bbe32f658b..c09b698289 100644
--- a/app/src/main/java/eu/faircode/email/FragmentSetup.java
+++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java
@@ -37,7 +37,9 @@ import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
+import android.text.Html;
import android.text.TextUtils;
+import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -104,6 +106,7 @@ public class FragmentSetup extends FragmentEx {
private EditText etEmail;
private TextInputLayout tilPassword;
private Button btnQuick;
+ private TextView tvInstructions;
private Button btnAccount;
private TextView tvAccountDone;
@@ -153,6 +156,7 @@ public class FragmentSetup extends FragmentEx {
etEmail = view.findViewById(R.id.etEmail);
tilPassword = view.findViewById(R.id.tilPassword);
btnQuick = view.findViewById(R.id.btnQuick);
+ tvInstructions = view.findViewById(R.id.tvInstructions);
btnAccount = view.findViewById(R.id.btnAccount);
tvAccountDone = view.findViewById(R.id.tvAccountDone);
@@ -225,6 +229,9 @@ public class FragmentSetup extends FragmentEx {
String[] dparts = email.split("@");
Provider provider = Provider.fromDomain(context, dparts[1]);
+ if (provider.documentation != null)
+ args.putString("documentation", provider.documentation.toString());
+
String user = (provider.user == Provider.UserType.EMAIL ? email : dparts[0]);
Character separator;
@@ -381,6 +388,11 @@ public class FragmentSetup extends FragmentEx {
@Override
protected void onException(Bundle args, Throwable ex) {
+ if (args.containsKey("documentation")) {
+ tvInstructions.setText(Html.fromHtml(args.getString("documentation")));
+ tvInstructions.setVisibility(View.VISIBLE);
+ }
+
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
@@ -510,6 +522,8 @@ public class FragmentSetup extends FragmentEx {
// Initialize
ibHelp.setVisibility(View.GONE);
+ tvInstructions.setVisibility(View.GONE);
+ tvInstructions.setMovementMethod(LinkMovementMethod.getInstance());
tvAccountDone.setText(null);
tvAccountDone.setCompoundDrawables(null, null, null, null);
diff --git a/app/src/main/java/eu/faircode/email/Provider.java b/app/src/main/java/eu/faircode/email/Provider.java
index 7d5d3152bc..cd7d9691a7 100644
--- a/app/src/main/java/eu/faircode/email/Provider.java
+++ b/app/src/main/java/eu/faircode/email/Provider.java
@@ -57,6 +57,7 @@ public class Provider {
public int smtp_port;
public boolean smtp_starttls;
public UserType user = UserType.EMAIL;
+ public StringBuilder documentation = null; // html
enum UserType {LOCAL, EMAIL}
@@ -75,25 +76,26 @@ public class Provider {
int eventType = xml.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
- if ("providers".equals(xml.getName()))
+ String name = xml.getName();
+ if ("providers".equals(name))
result = new ArrayList<>();
- else if ("provider".equals(xml.getName())) {
+ else if ("provider".equals(name)) {
provider = new Provider();
provider.name = xml.getAttributeValue(null, "name");
provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
provider.link = xml.getAttributeValue(null, "link");
provider.type = xml.getAttributeValue(null, "type");
provider.prefix = xml.getAttributeValue(null, "prefix");
- } else if ("imap".equals(xml.getName())) {
+ } else if ("imap".equals(name)) {
provider.imap_host = xml.getAttributeValue(null, "host");
provider.imap_port = xml.getAttributeIntValue(null, "port", 0);
provider.imap_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
- } else if ("smtp".equals(xml.getName())) {
+ } else if ("smtp".equals(name)) {
provider.smtp_host = xml.getAttributeValue(null, "host");
provider.smtp_port = xml.getAttributeIntValue(null, "port", 0);
provider.smtp_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
} else
- throw new IllegalAccessException(xml.getName());
+ throw new IllegalAccessException(name);
} else if (eventType == XmlPullParser.END_TAG) {
if ("provider".equals(xml.getName())) {
result.add(provider);
@@ -151,17 +153,36 @@ public class Provider {
boolean imap = false;
boolean smtp = false;
+ String href = null;
+ String title = null;
Provider provider = new Provider(domain);
int eventType = xml.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
- if ("incomingServer".equals(xml.getName()))
+ String name = xml.getName();
+ if ("incomingServer".equals(name)) {
+ //
+ // imap.gmail.com
+ // 993
+ // SSL
+ // %EMAILADDRESS%
+ // OAuth2
+ // password-cleartext
+ //
imap = "imap".equals(xml.getAttributeValue(null, "type"));
- else if ("outgoingServer".equals(xml.getName()))
+ } else if ("outgoingServer".equals(name)) {
+ //
+ // smtp.gmail.com
+ // 465
+ // SSL
+ // %EMAILADDRESS%
+ // OAuth2
+ // password-cleartext
+ //
smtp = "smtp".equals(xml.getAttributeValue(null, "type"));
- else if ("hostname".equals(xml.getName())) {
+ } else if ("hostname".equals(name)) {
eventType = xml.next();
if (eventType == XmlPullParser.TEXT) {
String host = xml.getText();
@@ -173,7 +194,7 @@ public class Provider {
}
continue;
- } else if ("port".equals(xml.getName())) {
+ } else if ("port".equals(name)) {
eventType = xml.next();
if (eventType == XmlPullParser.TEXT) {
String port = xml.getText();
@@ -188,7 +209,7 @@ public class Provider {
}
continue;
- } else if ("socketType".equals(xml.getName())) {
+ } else if ("socketType".equals(name)) {
eventType = xml.next();
if (eventType == XmlPullParser.TEXT) {
String socket = xml.getText();
@@ -208,7 +229,7 @@ public class Provider {
}
continue;
- } else if ("username".equals(xml.getName())) {
+ } else if ("username".equals(name)) {
eventType = xml.next();
if (eventType == XmlPullParser.TEXT) {
String username = xml.getText();
@@ -222,13 +243,59 @@ public class Provider {
}
continue;
+ } else if ("enable".equals(name)) {
+ //
+ // You need to enable IMAP access
+ //
+ href = xml.getAttributeValue(null, "visiturl");
+ title = null;
+
+ } else if ("documentation".equals(name)) {
+ //
+ // How to enable IMAP/POP3 in GMail
+ //
+ href = xml.getAttributeValue(null, "url");
+ title = null;
+
+ } else if ("instruction".equals(name) || "descr".equals(name)) {
+ if (href != null) {
+ eventType = xml.next();
+ if (eventType == XmlPullParser.TEXT) {
+ if (title == null)
+ title = "";
+ else
+ title += "
";
+ title += xml.getText();
+ }
+ continue;
+ }
}
} else if (eventType == XmlPullParser.END_TAG) {
- if ("incomingServer".equals(xml.getName()))
+ String name = xml.getName();
+ if ("incomingServer".equals(name))
imap = false;
- else if ("outgoingServer".equals(xml.getName()))
+
+ else if ("outgoingServer".equals(name))
smtp = false;
+
+ else if ("enable".equals(name) || "documentation".equals(name)) {
+ if (href != null) {
+ if (title == null)
+ title = href;
+
+ if (provider.documentation == null)
+ provider.documentation = new StringBuilder();
+ else
+ provider.documentation.append("
");
+
+ provider.documentation
+ .append("").append(title).append("");
+
+ href = null;
+ title = null;
+ }
+ }
}
eventType = xml.next();
diff --git a/app/src/main/res/layout/fragment_setup.xml b/app/src/main/res/layout/fragment_setup.xml
index 00688abd41..11f96a3be9 100644
--- a/app/src/main/res/layout/fragment_setup.xml
+++ b/app/src/main/res/layout/fragment_setup.xml
@@ -77,6 +77,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilPassword" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/tvInstructions" />