Browse Source

Added option to prefer IPv4 addresses, improvements

main
M66B 6 years ago
parent
commit
84ad3865b0
5 changed files with 29 additions and 14 deletions
  1. +0
    -3
      app/src/main/java/eu/faircode/email/DaoMessage.java
  2. +13
    -9
      app/src/main/java/eu/faircode/email/FragmentOptions.java
  3. +4
    -1
      app/src/main/java/eu/faircode/email/MessageHelper.java
  4. +11
    -1
      app/src/main/res/layout/fragment_options.xml
  5. +1
    -0
      app/src/main/res/values/strings.xml

+ 0
- 3
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -209,9 +209,6 @@ public interface DaoMessage {
@Query("UPDATE message SET avatar = :avatar WHERE id = :id") @Query("UPDATE message SET avatar = :avatar WHERE id = :id")
int setMessageAvatar(long id, String avatar); int setMessageAvatar(long id, String avatar);
@Query("UPDATE message SET avatar = NULL")
void clearMessageAvatars();
@Query("DELETE FROM message WHERE id = :id") @Query("DELETE FROM message WHERE id = :id")
int deleteMessage(long id); int deleteMessage(long id);


+ 13
- 9
app/src/main/java/eu/faircode/email/FragmentOptions.java View File

@ -22,7 +22,6 @@ package eu.faircode.email;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -36,6 +35,7 @@ public class FragmentOptions extends FragmentEx {
private CheckBox cbCompressImap; 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
@ -49,6 +49,7 @@ public class FragmentOptions extends FragmentEx {
cbCompressImap = view.findViewById(R.id.cbCompressImap); 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
@ -60,6 +61,7 @@ public class FragmentOptions extends FragmentEx {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("compress", checked).apply(); prefs.edit().putBoolean("compress", checked).apply();
ServiceSynchronize.reload(getContext(), "compress=" + checked);
} }
}); });
@ -68,14 +70,6 @@ public class FragmentOptions extends FragmentEx {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("avatars", checked).apply(); prefs.edit().putBoolean("avatars", checked).apply();
if (!checked)
new Thread(new Runnable() {
@Override
public void run() {
Log.i(Helper.TAG, "Clearing avatars");
DB.getInstance(getContext()).message().clearMessageAvatars();
}
}).start();
} }
}); });
@ -87,11 +81,21 @@ 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
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("debug", checked).apply(); prefs.edit().putBoolean("debug", checked).apply();
ServiceSynchronize.reload(getContext(), "debug=" + checked);
} }
}); });


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

@ -140,7 +140,10 @@ 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");
//System.setProperty("java.net.preferIPv4Stack", "true");
if (prefs.getBoolean("ipv4", false)) {
Log.i(Helper.TAG, "Prefering IPv4");
System.setProperty("java.net.preferIPv4Stack", "true");
}
// https://javaee.github.io/javamail/OAuth2 // https://javaee.github.io/javamail/OAuth2
Log.i(Helper.TAG, "Auth type=" + auth_type); Log.i(Helper.TAG, "Auth type=" + auth_type);


+ 11
- 1
app/src/main/res/layout/fragment_options.xml View File

@ -41,6 +41,16 @@
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"
@ -49,6 +59,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/cbLight" />
app:layout_constraintTop_toBottomOf="@id/cbIpV4" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

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

@ -79,6 +79,7 @@
<string name="title_advanced_compress_imap">Compress IMAP data</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</string> <string name="title_advanced_debug">Debug</string>
<string name="title_select">Select &#8230;</string> <string name="title_select">Select &#8230;</string>


Loading…
Cancel
Save