Auto prefix providers, sort most used providers on top

pull/147/head
M66B 6 years ago
parent c391f9c9f7
commit fd74c7e659

@ -247,6 +247,7 @@ public class FragmentAccount extends FragmentEx {
tilPassword.getEditText().setText(null); tilPassword.getEditText().setText(null);
etName.setText(position > 1 ? provider.name : null); etName.setText(position > 1 ? provider.name : null);
etPrefix.setText(provider.prefix);
grpFolders.setVisibility(View.GONE); grpFolders.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE); btnSave.setVisibility(View.GONE);

@ -34,8 +34,10 @@ import java.util.Locale;
public class Provider { public class Provider {
public String name; public String name;
public int order;
public String link; public String link;
public String type; public String type;
public String prefix;
public String imap_host; public String imap_host;
public boolean imap_starttls; public boolean imap_starttls;
public int imap_port; public int imap_port;
@ -63,8 +65,10 @@ public class Provider {
else if ("provider".equals(xml.getName())) { else if ("provider".equals(xml.getName())) {
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.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");
} else if ("imap".equals(xml.getName())) { } else if ("imap".equals(xml.getName())) {
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);
@ -93,7 +97,11 @@ public class Provider {
Collections.sort(result, new Comparator<Provider>() { Collections.sort(result, new Comparator<Provider>() {
@Override @Override
public int compare(Provider p1, Provider p2) { public int compare(Provider p1, Provider p2) {
return collator.compare(p1.name, p2.name); int o = Integer.compare(p1.order, p2.order);
if (o == 0)
return collator.compare(p1.name, p2.name);
else
return o;
} }
}); });

@ -3,6 +3,8 @@
<provider <provider
name="Gmail" name="Gmail"
link="https://support.google.com/mail/answer/7126229" link="https://support.google.com/mail/answer/7126229"
order="1"
prefix="[Gmail]"
type="com.google"> type="com.google">
<imap <imap
host="imap.gmail.com" host="imap.gmail.com"
@ -15,7 +17,8 @@
</provider> </provider>
<provider <provider
name="Outlook" name="Outlook"
link="https://support.office.com/en-us/article/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040"> link="https://support.office.com/en-us/article/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040"
order="2">
<imap <imap
host="imap-mail.outlook.com" host="imap-mail.outlook.com"
port="993" port="993"

Loading…
Cancel
Save