mirror of https://github.com/M66B/FairEmail.git
Fetch setup instructions
This commit is contained in:
parent
ef2172f7fb
commit
f054b7c6b4
|
@ -37,7 +37,9 @@ import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -104,6 +106,7 @@ public class FragmentSetup extends FragmentEx {
|
||||||
private EditText etEmail;
|
private EditText etEmail;
|
||||||
private TextInputLayout tilPassword;
|
private TextInputLayout tilPassword;
|
||||||
private Button btnQuick;
|
private Button btnQuick;
|
||||||
|
private TextView tvInstructions;
|
||||||
|
|
||||||
private Button btnAccount;
|
private Button btnAccount;
|
||||||
private TextView tvAccountDone;
|
private TextView tvAccountDone;
|
||||||
|
@ -153,6 +156,7 @@ public class FragmentSetup extends FragmentEx {
|
||||||
etEmail = view.findViewById(R.id.etEmail);
|
etEmail = view.findViewById(R.id.etEmail);
|
||||||
tilPassword = view.findViewById(R.id.tilPassword);
|
tilPassword = view.findViewById(R.id.tilPassword);
|
||||||
btnQuick = view.findViewById(R.id.btnQuick);
|
btnQuick = view.findViewById(R.id.btnQuick);
|
||||||
|
tvInstructions = view.findViewById(R.id.tvInstructions);
|
||||||
|
|
||||||
btnAccount = view.findViewById(R.id.btnAccount);
|
btnAccount = view.findViewById(R.id.btnAccount);
|
||||||
tvAccountDone = view.findViewById(R.id.tvAccountDone);
|
tvAccountDone = view.findViewById(R.id.tvAccountDone);
|
||||||
|
@ -225,6 +229,9 @@ public class FragmentSetup extends FragmentEx {
|
||||||
String[] dparts = email.split("@");
|
String[] dparts = email.split("@");
|
||||||
Provider provider = Provider.fromDomain(context, dparts[1]);
|
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]);
|
String user = (provider.user == Provider.UserType.EMAIL ? email : dparts[0]);
|
||||||
|
|
||||||
Character separator;
|
Character separator;
|
||||||
|
@ -381,6 +388,11 @@ public class FragmentSetup extends FragmentEx {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
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)
|
if (ex instanceof IllegalArgumentException)
|
||||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||||
else
|
else
|
||||||
|
@ -510,6 +522,8 @@ public class FragmentSetup extends FragmentEx {
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
ibHelp.setVisibility(View.GONE);
|
ibHelp.setVisibility(View.GONE);
|
||||||
|
tvInstructions.setVisibility(View.GONE);
|
||||||
|
tvInstructions.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
tvAccountDone.setText(null);
|
tvAccountDone.setText(null);
|
||||||
tvAccountDone.setCompoundDrawables(null, null, null, null);
|
tvAccountDone.setCompoundDrawables(null, null, null, null);
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class Provider {
|
||||||
public int smtp_port;
|
public int smtp_port;
|
||||||
public boolean smtp_starttls;
|
public boolean smtp_starttls;
|
||||||
public UserType user = UserType.EMAIL;
|
public UserType user = UserType.EMAIL;
|
||||||
|
public StringBuilder documentation = null; // html
|
||||||
|
|
||||||
enum UserType {LOCAL, EMAIL}
|
enum UserType {LOCAL, EMAIL}
|
||||||
|
|
||||||
|
@ -75,25 +76,26 @@ public class Provider {
|
||||||
int eventType = xml.getEventType();
|
int eventType = xml.getEventType();
|
||||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
if (eventType == XmlPullParser.START_TAG) {
|
||||||
if ("providers".equals(xml.getName()))
|
String name = xml.getName();
|
||||||
|
if ("providers".equals(name))
|
||||||
result = new ArrayList<>();
|
result = new ArrayList<>();
|
||||||
else if ("provider".equals(xml.getName())) {
|
else if ("provider".equals(name)) {
|
||||||
provider = new Provider();
|
provider = new Provider();
|
||||||
provider.name = xml.getAttributeValue(null, "name");
|
provider.name = xml.getAttributeValue(null, "name");
|
||||||
provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
|
provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
|
||||||
provider.link = xml.getAttributeValue(null, "link");
|
provider.link = xml.getAttributeValue(null, "link");
|
||||||
provider.type = xml.getAttributeValue(null, "type");
|
provider.type = xml.getAttributeValue(null, "type");
|
||||||
provider.prefix = xml.getAttributeValue(null, "prefix");
|
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_host = xml.getAttributeValue(null, "host");
|
||||||
provider.imap_port = xml.getAttributeIntValue(null, "port", 0);
|
provider.imap_port = xml.getAttributeIntValue(null, "port", 0);
|
||||||
provider.imap_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
|
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_host = xml.getAttributeValue(null, "host");
|
||||||
provider.smtp_port = xml.getAttributeIntValue(null, "port", 0);
|
provider.smtp_port = xml.getAttributeIntValue(null, "port", 0);
|
||||||
provider.smtp_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
|
provider.smtp_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
|
||||||
} else
|
} else
|
||||||
throw new IllegalAccessException(xml.getName());
|
throw new IllegalAccessException(name);
|
||||||
} else if (eventType == XmlPullParser.END_TAG) {
|
} else if (eventType == XmlPullParser.END_TAG) {
|
||||||
if ("provider".equals(xml.getName())) {
|
if ("provider".equals(xml.getName())) {
|
||||||
result.add(provider);
|
result.add(provider);
|
||||||
|
@ -151,17 +153,36 @@ public class Provider {
|
||||||
|
|
||||||
boolean imap = false;
|
boolean imap = false;
|
||||||
boolean smtp = false;
|
boolean smtp = false;
|
||||||
|
String href = null;
|
||||||
|
String title = null;
|
||||||
Provider provider = new Provider(domain);
|
Provider provider = new Provider(domain);
|
||||||
int eventType = xml.getEventType();
|
int eventType = xml.getEventType();
|
||||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
if (eventType == XmlPullParser.START_TAG) {
|
||||||
if ("incomingServer".equals(xml.getName()))
|
String name = xml.getName();
|
||||||
|
if ("incomingServer".equals(name)) {
|
||||||
|
// <incomingServer type="imap">
|
||||||
|
// <hostname>imap.gmail.com</hostname>
|
||||||
|
// <port>993</port>
|
||||||
|
// <socketType>SSL</socketType>
|
||||||
|
// <username>%EMAILADDRESS%</username>
|
||||||
|
// <authentication>OAuth2</authentication>
|
||||||
|
// <authentication>password-cleartext</authentication>
|
||||||
|
// </incomingServer>
|
||||||
imap = "imap".equals(xml.getAttributeValue(null, "type"));
|
imap = "imap".equals(xml.getAttributeValue(null, "type"));
|
||||||
|
|
||||||
else if ("outgoingServer".equals(xml.getName()))
|
} else if ("outgoingServer".equals(name)) {
|
||||||
|
// <outgoingServer type="smtp">
|
||||||
|
// <hostname>smtp.gmail.com</hostname>
|
||||||
|
// <port>465</port>
|
||||||
|
// <socketType>SSL</socketType>
|
||||||
|
// <username>%EMAILADDRESS%</username>
|
||||||
|
// <authentication>OAuth2</authentication>
|
||||||
|
// <authentication>password-cleartext</authentication>
|
||||||
|
// </outgoingServer>
|
||||||
smtp = "smtp".equals(xml.getAttributeValue(null, "type"));
|
smtp = "smtp".equals(xml.getAttributeValue(null, "type"));
|
||||||
|
|
||||||
else if ("hostname".equals(xml.getName())) {
|
} else if ("hostname".equals(name)) {
|
||||||
eventType = xml.next();
|
eventType = xml.next();
|
||||||
if (eventType == XmlPullParser.TEXT) {
|
if (eventType == XmlPullParser.TEXT) {
|
||||||
String host = xml.getText();
|
String host = xml.getText();
|
||||||
|
@ -173,7 +194,7 @@ public class Provider {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if ("port".equals(xml.getName())) {
|
} else if ("port".equals(name)) {
|
||||||
eventType = xml.next();
|
eventType = xml.next();
|
||||||
if (eventType == XmlPullParser.TEXT) {
|
if (eventType == XmlPullParser.TEXT) {
|
||||||
String port = xml.getText();
|
String port = xml.getText();
|
||||||
|
@ -188,7 +209,7 @@ public class Provider {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if ("socketType".equals(xml.getName())) {
|
} else if ("socketType".equals(name)) {
|
||||||
eventType = xml.next();
|
eventType = xml.next();
|
||||||
if (eventType == XmlPullParser.TEXT) {
|
if (eventType == XmlPullParser.TEXT) {
|
||||||
String socket = xml.getText();
|
String socket = xml.getText();
|
||||||
|
@ -208,7 +229,7 @@ public class Provider {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if ("username".equals(xml.getName())) {
|
} else if ("username".equals(name)) {
|
||||||
eventType = xml.next();
|
eventType = xml.next();
|
||||||
if (eventType == XmlPullParser.TEXT) {
|
if (eventType == XmlPullParser.TEXT) {
|
||||||
String username = xml.getText();
|
String username = xml.getText();
|
||||||
|
@ -222,13 +243,59 @@ public class Provider {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
} else if ("enable".equals(name)) {
|
||||||
|
// <enable visiturl="https://mail.google.com/mail/?ui=2&shva=1#settings/fwdandpop">
|
||||||
|
// <instruction>You need to enable IMAP access</instruction>
|
||||||
|
// </enable>
|
||||||
|
href = xml.getAttributeValue(null, "visiturl");
|
||||||
|
title = null;
|
||||||
|
|
||||||
|
} else if ("documentation".equals(name)) {
|
||||||
|
// <documentation url="http://mail.google.com/support/bin/answer.py?answer=13273">
|
||||||
|
// <descr>How to enable IMAP/POP3 in GMail</descr>
|
||||||
|
// </documentation>
|
||||||
|
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 += "<br />";
|
||||||
|
title += xml.getText();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (eventType == XmlPullParser.END_TAG) {
|
} else if (eventType == XmlPullParser.END_TAG) {
|
||||||
if ("incomingServer".equals(xml.getName()))
|
String name = xml.getName();
|
||||||
|
if ("incomingServer".equals(name))
|
||||||
imap = false;
|
imap = false;
|
||||||
else if ("outgoingServer".equals(xml.getName()))
|
|
||||||
|
else if ("outgoingServer".equals(name))
|
||||||
smtp = false;
|
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("<br /><br />");
|
||||||
|
|
||||||
|
provider.documentation
|
||||||
|
.append("<a href=\"").append(href).append("\">").append(title).append("</a>");
|
||||||
|
|
||||||
|
href = null;
|
||||||
|
title = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eventType = xml.next();
|
eventType = xml.next();
|
||||||
|
|
|
@ -77,6 +77,17 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tilPassword" />
|
app:layout_constraintTop_toBottomOf="@id/tilPassword" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvInstructions"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="provider instructions"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btnQuick" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorQuick"
|
android:id="@+id/vSeparatorQuick"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -84,7 +95,7 @@
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:background="?attr/colorSeparator"
|
android:background="?attr/colorSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btnQuick" />
|
app:layout_constraintTop_toBottomOf="@id/tvInstructions" />
|
||||||
|
|
||||||
<!-- account -->
|
<!-- account -->
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue