Improvements, fixes

This commit is contained in:
M66B 2018-08-27 15:08:23 +00:00
parent bc30dee6a1
commit 4d7c3e9c88
4 changed files with 46 additions and 10 deletions

View File

@ -30,7 +30,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -163,9 +163,6 @@ public class FragmentAccount extends FragmentEx {
Provider provider = (Provider) adapterView.getSelectedItem();
tvLink.setText(Html.fromHtml("<a href=\"" + provider.link + "\">" + provider.link + "</a>"));
grpInstructions.setVisibility(provider.link == null ? View.GONE : View.VISIBLE);
if (provider.imap_port > 0) {
etName.setText(provider.name);
etHost.setText(provider.imap_host);
@ -183,6 +180,9 @@ public class FragmentAccount extends FragmentEx {
}
} else
btnAuthorize.setVisibility(View.VISIBLE);
tvLink.setText(Html.fromHtml("<a href=\"" + provider.link + "\">" + provider.link + "</a>"));
grpInstructions.setVisibility(provider.link == null ? View.GONE : View.VISIBLE);
}
@Override
@ -254,7 +254,6 @@ public class FragmentAccount extends FragmentEx {
// Check IMAP server / get folders
List<EntityFolder> folders = new ArrayList<>();
Properties props = MessageHelper.getSessionProperties(auth_type);
Session isession = Session.getInstance(props, null);
isession.setDebug(true);
IMAPStore istore = null;
@ -476,6 +475,7 @@ public class FragmentAccount extends FragmentEx {
// Check IMAP server
if (synchronize) {
Session isession = Session.getInstance(MessageHelper.getSessionProperties(auth_type), null);
isession.setDebug(true);
IMAPStore istore = null;
try {
istore = (IMAPStore) isession.getStore("imaps");
@ -683,20 +683,37 @@ public class FragmentAccount extends FragmentEx {
return;
once = true;
spProvider.setTag(0);
spProvider.setSelection(0);
if (account != null) {
for (int pos = 1; pos < providers.size(); pos++)
if (providers.get(pos).imap_host.equals(account.host)) {
spProvider.setTag(pos);
spProvider.setSelection(pos);
break;
}
}
etName.setText(account == null ? null : account.name);
etHost.setText(account == null ? null : account.host);
etPort.setText(account == null ? null : Long.toString(account.port));
etUser.setText(account == null ? null : account.user);
tilPassword.getEditText().setText(account == null ? null : account.password);
auth_type = (account == null ? Helper.AUTH_TYPE_PASSWORD : account.auth_type);
cbSynchronize.setChecked(account == null ? true : account.synchronize);
cbPrimary.setChecked(account == null ? true : account.primary);
etInterval.setText(account == null ? "9" : Integer.toString(account.poll_interval));
} else {
int provider = savedInstanceState.getInt("provider");
auth_type = savedInstanceState.getInt("auth_type");
spProvider.setTag(provider);
spProvider.setSelection(provider);
tilPassword.getEditText().setText(savedInstanceState.getString("password"));
auth_type = savedInstanceState.getInt("auth_type");
grpInstructions.setVisibility(savedInstanceState.getInt("instructions"));
}

View File

@ -177,14 +177,14 @@ public class FragmentIdentity extends FragmentEx {
Provider provider = (Provider) adapterView.getSelectedItem();
tvLink.setText(Html.fromHtml("<a href=\"" + provider.link + "\">" + provider.link + "</a>"));
grpInstructions.setVisibility(provider.link == null ? View.GONE : View.VISIBLE);
if (provider.smtp_port != 0) {
if (provider.smtp_port > 0) {
etHost.setText(provider.smtp_host);
etPort.setText(Integer.toString(provider.smtp_port));
cbStartTls.setChecked(provider.starttls);
}
tvLink.setText(Html.fromHtml("<a href=\"" + provider.link + "\">" + provider.link + "</a>"));
grpInstructions.setVisibility(provider.link == null ? View.GONE : View.VISIBLE);
}
@Override
@ -271,6 +271,7 @@ public class FragmentIdentity extends FragmentEx {
if (synchronize) {
Properties props = MessageHelper.getSessionProperties(auth_type);
Session isession = Session.getInstance(props, null);
isession.setDebug(true);
Transport itransport = isession.getTransport(starttls ? "smtp" : "smtps");
try {
itransport.connect(host, Integer.parseInt(port), user, password);
@ -470,9 +471,25 @@ public class FragmentIdentity extends FragmentEx {
spProvider.setAdapter(adapterProfile);
if (savedInstanceState == null) {
spProvider.setTag(0);
spProvider.setSelection(0);
if (identity != null)
for (int pos = 1; pos < providers.size(); pos++)
if (providers.get(pos).smtp_host.equals(identity.host)) {
spProvider.setTag(pos);
spProvider.setSelection(pos);
break;
}
spAccount.setTag(0);
spAccount.setSelection(0);
for (int pos = 0; pos < accounts.size(); pos++)
if (accounts.get(pos).id == (identity == null ? -1 : identity.account)) {
spAccount.setTag(pos);
spAccount.setSelection(pos);
// OAuth token could be updated
if (accounts.get(pos).auth_type != Helper.AUTH_TYPE_PASSWORD)
tilPassword.getEditText().setText(accounts.get(pos).password);
break;
}
} else {

View File

@ -98,9 +98,11 @@ public class MessageHelper {
props.put("mail.mime.decodetext.strict", "false");
// https://javaee.github.io/javamail/OAuth2
Log.i(Helper.TAG, "Auth type=" + auth_type);
if (auth_type == Helper.AUTH_TYPE_GMAIL) {
props.put("mail.imaps.auth.mechanisms", "XOAUTH2");
props.put("mail.smtps.auth.mechanisms", "XOAUTH2");
props.put("mail.smtp.auth.mechanisms", "XOAUTH2");
}
return props;