mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-09 10:33:41 +02:00
Generalize setup help
This commit is contained in:
@@ -55,10 +55,10 @@ import java.util.concurrent.Future;
|
||||
|
||||
public class EmailProvider {
|
||||
public String name;
|
||||
public int order;
|
||||
public int keepalive;
|
||||
public String link;
|
||||
public int order;
|
||||
public String type;
|
||||
public int keepalive;
|
||||
public String imap_host;
|
||||
public boolean imap_starttls;
|
||||
public int imap_port;
|
||||
@@ -66,8 +66,7 @@ public class EmailProvider {
|
||||
public int smtp_port;
|
||||
public boolean smtp_starttls;
|
||||
public UserType user = UserType.EMAIL;
|
||||
public String helpUrl = null;
|
||||
public StringBuilder documentation = null; // html
|
||||
public StringBuilder documentation; // html
|
||||
|
||||
enum UserType {LOCAL, EMAIL}
|
||||
|
||||
@@ -117,7 +116,6 @@ public class EmailProvider {
|
||||
throw new IllegalAccessException(name);
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if ("provider".equals(xml.getName())) {
|
||||
addSpecials(context, provider);
|
||||
result.add(provider);
|
||||
provider = null;
|
||||
}
|
||||
@@ -146,9 +144,11 @@ public class EmailProvider {
|
||||
}
|
||||
|
||||
static EmailProvider fromDomain(Context context, String domain) throws IOException {
|
||||
EmailProvider autoconfig = fromDomainInternal(context, domain);
|
||||
EmailProvider autoconfig = _fromDomain(context, domain);
|
||||
|
||||
// Always prefer built-in profiles (ISPDB is not always correct)
|
||||
// Always prefer built-in profiles
|
||||
// - ISPDB is not always correct
|
||||
// - documentation links
|
||||
List<EmailProvider> providers = loadProfiles(context);
|
||||
for (EmailProvider provider : providers)
|
||||
if (provider.imap_host.equals(autoconfig.imap_host) ||
|
||||
@@ -160,23 +160,23 @@ public class EmailProvider {
|
||||
return autoconfig;
|
||||
}
|
||||
|
||||
private static EmailProvider fromDomainInternal(Context context, String domain) throws IOException {
|
||||
private static EmailProvider _fromDomain(Context context, String domain) throws IOException {
|
||||
try {
|
||||
// Assume the provider knows best
|
||||
Log.i("Provider from DNS domain=" + domain);
|
||||
return addSpecials(context, fromDNS(context, domain));
|
||||
return fromDNS(context, domain);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
try {
|
||||
// Check ISPDB
|
||||
Log.i("Provider from ISPDB domain=" + domain);
|
||||
return addSpecials(context, fromISPDB(context, domain));
|
||||
return fromISPDB(context, domain);
|
||||
} catch (Throwable ex1) {
|
||||
Log.w(ex1);
|
||||
try {
|
||||
// Scan ports
|
||||
Log.i("Provider from template domain=" + domain);
|
||||
return addSpecials(context, fromTemplate(context, domain));
|
||||
return fromTemplate(context, domain);
|
||||
} catch (Throwable ex2) {
|
||||
Log.w(ex2);
|
||||
throw new UnknownHostException(context.getString(R.string.title_setup_no_settings, domain));
|
||||
@@ -501,20 +501,6 @@ public class EmailProvider {
|
||||
provider.documentation.append("<a href=\"").append(href).append("\">").append(title).append("</a>");
|
||||
}
|
||||
|
||||
private static EmailProvider addSpecials(Context context, EmailProvider provider) {
|
||||
if ("imap.gmail.com".equals(provider.imap_host))
|
||||
provider.helpUrl = Helper.FAQ_URI + "#user-content-faq6";
|
||||
|
||||
if (provider.imap_host.endsWith("office365.com") ||
|
||||
provider.imap_host.endsWith("live.com"))
|
||||
provider.helpUrl = Helper.FAQ_URI + "#user-content-faq14";
|
||||
|
||||
if (provider.imap_host.endsWith("yahoo.com"))
|
||||
provider.helpUrl = Helper.FAQ_URI + "#user-content-faq88";
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
private static SRVRecord lookup(Context context, String record) throws TextParseException, UnknownHostException {
|
||||
Lookup lookup = new Lookup(record, Type.SRV);
|
||||
|
||||
|
||||
@@ -1077,8 +1077,8 @@ public class FragmentAccount extends FragmentBase {
|
||||
tvError.setVisibility(View.VISIBLE);
|
||||
|
||||
final EmailProvider provider = (EmailProvider) spProvider.getSelectedItem();
|
||||
if (provider != null && provider.helpUrl != null) {
|
||||
Uri uri = Uri.parse(provider.helpUrl);
|
||||
if (provider != null && provider.link != null) {
|
||||
Uri uri = Uri.parse(provider.link);
|
||||
btnHelp.setTag(uri);
|
||||
btnHelp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ public class FragmentAccount extends FragmentBase {
|
||||
public void run() {
|
||||
if (provider != null && provider.documentation != null)
|
||||
scroll.smoothScrollTo(0, tvInstructions.getBottom());
|
||||
else if (provider != null && provider.helpUrl != null)
|
||||
else if (provider != null && provider.link != null)
|
||||
scroll.smoothScrollTo(0, btnHelp.getBottom());
|
||||
else
|
||||
scroll.smoothScrollTo(0, tvError.getBottom());
|
||||
|
||||
@@ -769,8 +769,8 @@ public class FragmentIdentity extends FragmentBase {
|
||||
tvError.setVisibility(View.VISIBLE);
|
||||
|
||||
final EmailProvider provider = (EmailProvider) spProvider.getSelectedItem();
|
||||
if (provider != null && provider.helpUrl != null) {
|
||||
Uri uri = Uri.parse(provider.helpUrl);
|
||||
if (provider != null && provider.link != null) {
|
||||
Uri uri = Uri.parse(provider.link);
|
||||
btnHelp.setTag(uri);
|
||||
btnHelp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@@ -785,7 +785,7 @@ public class FragmentIdentity extends FragmentBase {
|
||||
public void run() {
|
||||
if (provider != null && provider.documentation != null)
|
||||
scroll.smoothScrollTo(0, tvInstructions.getBottom());
|
||||
else if (provider != null && provider.helpUrl != null)
|
||||
else if (provider != null && provider.link != null)
|
||||
scroll.smoothScrollTo(0, btnHelp.getBottom());
|
||||
else
|
||||
scroll.smoothScrollTo(0, tvError.getBottom());
|
||||
|
||||
@@ -238,8 +238,8 @@ public class FragmentQuickSetup extends FragmentBase {
|
||||
String[] dparts = email.split("@");
|
||||
EmailProvider provider = EmailProvider.fromDomain(context, dparts[1]);
|
||||
|
||||
if (provider.helpUrl != null)
|
||||
args.putString("help", provider.helpUrl);
|
||||
if (provider.link != null)
|
||||
args.putString("link", provider.link);
|
||||
if (provider.documentation != null)
|
||||
args.putString("documentation", provider.documentation.toString());
|
||||
|
||||
@@ -442,8 +442,8 @@ public class FragmentQuickSetup extends FragmentBase {
|
||||
tvError.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (args.containsKey("help")) {
|
||||
Uri uri = Uri.parse(args.getString("help"));
|
||||
if (args.containsKey("link")) {
|
||||
Uri uri = Uri.parse(args.getString("link"));
|
||||
btnHelp.setTag(uri);
|
||||
btnHelp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@@ -458,7 +458,7 @@ public class FragmentQuickSetup extends FragmentBase {
|
||||
public void run() {
|
||||
if (args.containsKey("documentation"))
|
||||
scroll.smoothScrollTo(0, tvInstructions.getBottom());
|
||||
else if (args.containsKey("help"))
|
||||
else if (args.containsKey("link"))
|
||||
scroll.smoothScrollTo(0, btnHelp.getBottom());
|
||||
else if (tvError.getVisibility() == View.VISIBLE)
|
||||
scroll.smoothScrollTo(0, tvError.getBottom());
|
||||
|
||||
Reference in New Issue
Block a user