Browse Source

Removed compress / prever IPv4 options

main
M66B 6 years ago
parent
commit
a1b2f99983
9 changed files with 13 additions and 61 deletions
  1. +1
    -1
      app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java
  2. +2
    -2
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  3. +2
    -2
      app/src/main/java/eu/faircode/email/FragmentFolder.java
  4. +1
    -1
      app/src/main/java/eu/faircode/email/FragmentIdentity.java
  5. +0
    -22
      app/src/main/java/eu/faircode/email/FragmentOptions.java
  6. +3
    -7
      app/src/main/java/eu/faircode/email/MessageHelper.java
  7. +2
    -2
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java
  8. +2
    -22
      app/src/main/res/layout/fragment_options.xml
  9. +0
    -2
      app/src/main/res/values/strings.xml

+ 1
- 1
app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java View File

@ -147,7 +147,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
EntityAccount account = db.account().getAccount(folder.account); EntityAccount account = db.account().getAccount(folder.account);
if (imessages == null) { if (imessages == null) {
Properties props = MessageHelper.getSessionProperties(context, account.auth_type);
Properties props = MessageHelper.getSessionProperties(account.auth_type);
props.setProperty("mail.imap.throwsearchexception", "true"); props.setProperty("mail.imap.throwsearchexception", "true");
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);


+ 2
- 2
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -467,7 +467,7 @@ 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(context, 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;
@ -712,7 +712,7 @@ public class FragmentAccount extends FragmentEx {
// Check IMAP server // Check IMAP server
if (synchronize) { if (synchronize) {
Session isession = Session.getInstance(MessageHelper.getSessionProperties(context, auth_type), null);
Session isession = Session.getInstance(MessageHelper.getSessionProperties(auth_type), null);
isession.setDebug(true); isession.setDebug(true);
IMAPStore istore = null; IMAPStore istore = null;
try { try {


+ 2
- 2
app/src/main/java/eu/faircode/email/FragmentFolder.java View File

@ -133,7 +133,7 @@ public class FragmentFolder extends FragmentEx {
if (folder == null || !folder.name.equals(name)) { if (folder == null || !folder.name.equals(name)) {
EntityAccount account = db.account().getAccount(folder == null ? aid : folder.account); EntityAccount account = db.account().getAccount(folder == null ? aid : folder.account);
Properties props = MessageHelper.getSessionProperties(context, account.auth_type);
Properties props = MessageHelper.getSessionProperties(account.auth_type);
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
istore = (IMAPStore) isession.getStore("imaps"); istore = (IMAPStore) isession.getStore("imaps");
Helper.connect(context, istore, account); Helper.connect(context, istore, account);
@ -236,7 +236,7 @@ public class FragmentFolder extends FragmentEx {
EntityFolder folder = db.folder().getFolder(id); EntityFolder folder = db.folder().getFolder(id);
EntityAccount account = db.account().getAccount(folder.account); EntityAccount account = db.account().getAccount(folder.account);
Properties props = MessageHelper.getSessionProperties(context, account.auth_type);
Properties props = MessageHelper.getSessionProperties(account.auth_type);
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
istore = (IMAPStore) isession.getStore("imaps"); istore = (IMAPStore) isession.getStore("imaps");
Helper.connect(context, istore, account); Helper.connect(context, istore, account);


+ 1
- 1
app/src/main/java/eu/faircode/email/FragmentIdentity.java View File

@ -338,7 +338,7 @@ public class FragmentIdentity extends FragmentEx {
// Check SMTP server // Check SMTP server
if (synchronize) { if (synchronize) {
Properties props = MessageHelper.getSessionProperties(context, 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);
Transport itransport = isession.getTransport(starttls ? "smtp" : "smtps"); Transport itransport = isession.getTransport(starttls ? "smtp" : "smtps");


+ 0
- 22
app/src/main/java/eu/faircode/email/FragmentOptions.java View File

@ -32,10 +32,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
public class FragmentOptions extends FragmentEx { public class FragmentOptions extends FragmentEx {
private CheckBox cbCompressImap;
private CheckBox cbAvatars; private CheckBox cbAvatars;
private CheckBox cbLight; private CheckBox cbLight;
private CheckBox cbIpV4;
private CheckBox cbDebug; private CheckBox cbDebug;
@Override @Override
@ -46,25 +44,14 @@ public class FragmentOptions extends FragmentEx {
View view = inflater.inflate(R.layout.fragment_options, container, false); View view = inflater.inflate(R.layout.fragment_options, container, false);
// Get controls // Get controls
cbCompressImap = view.findViewById(R.id.cbCompressImap);
cbAvatars = view.findViewById(R.id.cbAvatars); cbAvatars = view.findViewById(R.id.cbAvatars);
cbLight = view.findViewById(R.id.cbLight); cbLight = view.findViewById(R.id.cbLight);
cbIpV4 = view.findViewById(R.id.cbIpV4);
cbDebug = view.findViewById(R.id.cbDebug); cbDebug = view.findViewById(R.id.cbDebug);
// Wire controls // Wire controls
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
cbCompressImap.setChecked(prefs.getBoolean("compress", true));
cbCompressImap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("compress", checked).apply();
ServiceSynchronize.reload(getContext(), "compress=" + checked);
}
});
cbAvatars.setChecked(prefs.getBoolean("avatars", true)); cbAvatars.setChecked(prefs.getBoolean("avatars", true));
cbAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -81,15 +68,6 @@ public class FragmentOptions extends FragmentEx {
} }
}); });
cbIpV4.setChecked(prefs.getBoolean("ipv4", false));
cbIpV4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("ipv4", checked).apply();
ServiceSynchronize.reload(getContext(), "IPv4=" + checked);
}
});
cbDebug.setChecked(prefs.getBoolean("debug", false)); cbDebug.setChecked(prefs.getBoolean("debug", false));
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override


+ 3
- 7
app/src/main/java/eu/faircode/email/MessageHelper.java View File

@ -20,8 +20,6 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
@ -63,11 +61,9 @@ public class MessageHelper {
final static int NETWORK_TIMEOUT = 60 * 1000; // milliseconds final static int NETWORK_TIMEOUT = 60 * 1000; // milliseconds
static Properties getSessionProperties(Context context, int auth_type) {
static Properties getSessionProperties(int auth_type) {
Properties props = new Properties(); Properties props = new Properties();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.html#properties // https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.html#properties
props.put("mail.imaps.ssl.checkserveridentity", "true"); props.put("mail.imaps.ssl.checkserveridentity", "true");
props.put("mail.imaps.ssl.trust", "*"); props.put("mail.imaps.ssl.trust", "*");
@ -85,7 +81,7 @@ public class MessageHelper {
// https://tools.ietf.org/html/rfc4978 // https://tools.ietf.org/html/rfc4978
// https://docs.oracle.com/javase/8/docs/api/java/util/zip/Deflater.html // https://docs.oracle.com/javase/8/docs/api/java/util/zip/Deflater.html
if (prefs.getBoolean("compress", true)) {
if (false) {
Log.i(Helper.TAG, "IMAP compress enabled"); Log.i(Helper.TAG, "IMAP compress enabled");
props.put("mail.imaps.compress.enable", "true"); props.put("mail.imaps.compress.enable", "true");
//props.put("mail.imaps.compress.level", "-1"); //props.put("mail.imaps.compress.level", "-1");
@ -140,7 +136,7 @@ public class MessageHelper {
System.setProperty("mail.mime.multipart.ignoremissingboundaryparameter", "true"); // javax.mail.internet.ParseException: In parameter list System.setProperty("mail.mime.multipart.ignoremissingboundaryparameter", "true"); // javax.mail.internet.ParseException: In parameter list
System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true"); System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true");
if (prefs.getBoolean("ipv4", false)) {
if (false) {
Log.i(Helper.TAG, "Prefering IPv4"); Log.i(Helper.TAG, "Prefering IPv4");
System.setProperty("java.net.preferIPv4Stack", "true"); System.setProperty("java.net.preferIPv4Stack", "true");
} }


+ 2
- 2
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -561,7 +561,7 @@ public class ServiceSynchronize extends LifecycleService {
System.setProperty("mail.socket.debug", Boolean.toString(debug)); System.setProperty("mail.socket.debug", Boolean.toString(debug));
// Create session // Create session
Properties props = MessageHelper.getSessionProperties(this, account.auth_type);
Properties props = MessageHelper.getSessionProperties(account.auth_type);
final Session isession = Session.getInstance(props, null); final Session isession = Session.getInstance(props, null);
isession.setDebug(debug); isession.setDebug(debug);
// adb -t 1 logcat | grep "fairemail\|System.out" // adb -t 1 logcat | grep "fairemail\|System.out"
@ -1243,7 +1243,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
// Create session // Create session
Properties props = MessageHelper.getSessionProperties(this, ident.auth_type);
Properties props = MessageHelper.getSessionProperties(ident.auth_type);
final Session isession = Session.getInstance(props, null); final Session isession = Session.getInstance(props, null);
// Create message // Create message


+ 2
- 22
app/src/main/res/layout/fragment_options.xml View File

@ -11,16 +11,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<CheckBox
android:id="@+id/cbCompressImap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_compress_imap"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox <CheckBox
android:id="@+id/cbAvatars" android:id="@+id/cbAvatars"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -29,7 +19,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_avatars" android:text="@string/title_advanced_avatars"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbCompressImap" />
app:layout_constraintTop_toTopOf="parent" />
<CheckBox <CheckBox
android:id="@+id/cbLight" android:id="@+id/cbLight"
@ -41,16 +31,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" /> app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
<CheckBox
android:id="@+id/cbIpV4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_ipv4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLight" />
<CheckBox <CheckBox
android:id="@+id/cbDebug" android:id="@+id/cbDebug"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -59,6 +39,6 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_debug" android:text="@string/title_advanced_debug"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbIpV4" />
app:layout_constraintTop_toBottomOf="@id/cbLight" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

+ 0
- 2
app/src/main/res/values/strings.xml View File

@ -76,10 +76,8 @@
<string name="title_setup_dark_theme">Dark theme</string> <string name="title_setup_dark_theme">Dark theme</string>
<string name="title_advanced">Advanced options</string> <string name="title_advanced">Advanced options</string>
<string name="title_advanced_compress_imap">Compress IMAP data</string>
<string name="title_advanced_avatars">Show contact photos</string> <string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_light">Use notification light</string> <string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_ipv4">Prefer IPv4 connections</string>
<string name="title_advanced_debug">Debug mode</string> <string name="title_advanced_debug">Debug mode</string>
<string name="title_select">Select &#8230;</string> <string name="title_select">Select &#8230;</string>


Loading…
Cancel
Save