Improvements, fixes

pull/72/head
M66B 7 years ago
parent bc30dee6a1
commit 4d7c3e9c88

@ -30,7 +30,7 @@
</value> </value>
</option> </option>
</component> </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" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

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

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

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

Loading…
Cancel
Save