forked from mirror/monocles_chat_clean
Add option to prefer IPv6
This commit is contained in:
parent
d39b72513b
commit
f2825612c3
8 changed files with 38 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,12 +88,22 @@ public class Resolver {
|
|||
if (left.ip == null && right.ip == null) {
|
||||
return 0;
|
||||
} else if (left.ip != null && right.ip != null) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
|
5
src/main/res/drawable/rounded_commit_24.xml
Normal file
5
src/main/res/drawable/rounded_commit_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?colorControlNormal" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M480,680Q407,680 352.5,634.5Q298,589 284,520L120,520Q103,520 91.5,508.5Q80,497 80,480Q80,463 91.5,451.5Q103,440 120,440L284,440Q298,371 352.5,325.5Q407,280 480,280Q553,280 607.5,325.5Q662,371 676,440L840,440Q857,440 868.5,451.5Q880,463 880,480Q880,497 868.5,508.5Q857,520 840,520L676,520Q662,589 607.5,634.5Q553,680 480,680ZM480,600Q530,600 565,565Q600,530 600,480Q600,430 565,395Q530,360 480,360Q430,360 395,395Q360,430 360,480Q360,530 395,565Q430,600 480,600Z"/>
|
||||
|
||||
</vector>
|
|
@ -12,4 +12,5 @@
|
|||
<bool name="showtextformatting">false</bool>
|
||||
<bool name="app_lock_enabled">false</bool>
|
||||
<bool name="secure_tls">false</bool>
|
||||
<bool name="prefer_ipv6">false</bool>
|
||||
</resources>
|
||||
|
|
|
@ -1404,4 +1404,6 @@
|
|||
<string name="pref_hide_media_summary">Hide received and sent media from system gallery views</string>
|
||||
<string name="pref_secure_tls_summary">Use only securest TLS ciphers including post quantum key agreement if available on server</string>
|
||||
<string name="pref_secure_tls">Use secure TLS Ciphers only</string>
|
||||
<string name="pref_prefer_ipv6_summary">Prefers IPv6 when connecting</string>
|
||||
<string name="pref_prefer_ipv6">Prefer IPv6</string>
|
||||
</resources>
|
|
@ -14,6 +14,12 @@
|
|||
android:key="use_tor"
|
||||
android:summary="@string/pref_use_tor_summary"
|
||||
android:title="@string/pref_use_tor" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="@bool/prefer_ipv6"
|
||||
android:icon="@drawable/rounded_commit_24"
|
||||
android:key="prefer_ipv6"
|
||||
android:summary="@string/pref_prefer_ipv6_summary"
|
||||
android:title="@string/pref_prefer_ipv6" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/default_dns_server_ipv4"
|
||||
android:icon="@drawable/outline_dns_24"
|
||||
|
|
Loading…
Reference in a new issue