diff --git a/build.gradle b/build.gradle index 336b4abcb..f53ca2e8c 100644 --- a/build.gradle +++ b/build.gradle @@ -150,8 +150,8 @@ android { defaultConfig { minSdkVersion 23 targetSdkVersion 34 - versionCode 180 - versionName "2.0.3" + versionCode 181 + versionName "2.0.4" applicationId "de.monocles.chat" def appName = "monocles chat" resValue "string", "app_name", appName diff --git a/src/main/java/eu/siacs/conversations/AppSettings.java b/src/main/java/eu/siacs/conversations/AppSettings.java index bbb4e49b6..f225f2e20 100644 --- a/src/main/java/eu/siacs/conversations/AppSettings.java +++ b/src/main/java/eu/siacs/conversations/AppSettings.java @@ -52,6 +52,7 @@ public class AppSettings { private static final String ACCEPT_INVITES_FROM_STRANGERS = "accept_invites_from_strangers"; private static final String INSTALLATION_ID = "im.conversations.android.install_id"; public static final String SECURE_TLS = "secure_tls"; + public static final String PREFER_IPV6 = "prefer_ipv6"; private final Context context; @@ -128,6 +129,10 @@ public class AppSettings { return getBooleanPreference(SECURE_TLS, R.bool.secure_tls); } + public boolean preferIPv6() { + return getBooleanPreference(PREFER_IPV6, R.bool.prefer_ipv6); + } + public boolean isCallIntegration() { return getBooleanPreference(CALL_INTEGRATION, R.bool.call_integration); } diff --git a/src/main/java/eu/siacs/conversations/ui/fragment/settings/ConnectionSettingsFragment.java b/src/main/java/eu/siacs/conversations/ui/fragment/settings/ConnectionSettingsFragment.java index 8b0180d7e..49dd5bb54 100644 --- a/src/main/java/eu/siacs/conversations/ui/fragment/settings/ConnectionSettingsFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/fragment/settings/ConnectionSettingsFragment.java @@ -88,7 +88,7 @@ public class ConnectionSettingsFragment extends XmppPreferenceFragment { reconnectAccounts(); requireService().reinitializeMuclumbusService(); } - case AppSettings.SHOW_CONNECTION_OPTIONS -> { + case AppSettings.SHOW_CONNECTION_OPTIONS, AppSettings.PREFER_IPV6 -> { reconnectAccounts(); } } diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index ee70cd579..f9f21f684 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -20,6 +20,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import eu.siacs.conversations.AppSettings; import eu.siacs.conversations.Config; import eu.siacs.conversations.Conversations; import eu.siacs.conversations.xmpp.Jid; @@ -38,6 +39,7 @@ import org.minidns.record.SRV; import java.io.IOException; import java.net.Inet4Address; +import java.net.Inet6Address; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -86,11 +88,21 @@ public class Resolver { if (left.ip == null && right.ip == null) { return 0; } else if (left.ip != null && right.ip != null) { - if (left.ip instanceof Inet4Address - && right.ip instanceof Inet4Address) { - return 0; + final var appSettings = new AppSettings(Conversations.getContext()); + if (appSettings.preferIPv6()) { + if (left.ip instanceof Inet6Address + && right.ip instanceof Inet6Address) { + return 0; + } else { + return left.ip instanceof Inet6Address ? -1 : 1; + } } else { - return left.ip instanceof Inet4Address ? -1 : 1; + if (left.ip instanceof Inet4Address + && right.ip instanceof Inet4Address) { + return 0; + } else { + return left.ip instanceof Inet4Address ? -1 : 1; + } } } else { return left.ip != null ? -1 : 1; diff --git a/src/main/res/drawable/rounded_commit_24.xml b/src/main/res/drawable/rounded_commit_24.xml new file mode 100644 index 000000000..26a441c83 --- /dev/null +++ b/src/main/res/drawable/rounded_commit_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/res/values/bools.xml b/src/main/res/values/bools.xml index 9c4a6e7eb..9a36c38f0 100644 --- a/src/main/res/values/bools.xml +++ b/src/main/res/values/bools.xml @@ -12,4 +12,5 @@ false false false + false diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 23cc77113..12f3f7662 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1404,4 +1404,6 @@ Hide received and sent media from system gallery views Use only securest TLS ciphers including post quantum key agreement if available on server Use secure TLS Ciphers only + Prefers IPv6 when connecting + Prefer IPv6 \ No newline at end of file diff --git a/src/main/res/xml/preferences_connection.xml b/src/main/res/xml/preferences_connection.xml index 37e6d5c90..132189059 100644 --- a/src/main/res/xml/preferences_connection.xml +++ b/src/main/res/xml/preferences_connection.xml @@ -14,6 +14,12 @@ android:key="use_tor" android:summary="@string/pref_use_tor_summary" android:title="@string/pref_use_tor" /> +