mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-01 12:08:46 +00:00
DNS: backward compatibility
This commit is contained in:
parent
788b02f104
commit
3d54182e2b
3 changed files with 32 additions and 28 deletions
|
@ -104,6 +104,7 @@ public class DnsHelper {
|
|||
@NonNull
|
||||
private static DnsRecord[] _lookup(Context context, String name, String type, int timeout) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean dns_custom = prefs.getBoolean("dns_custom", false);
|
||||
boolean dns_secure = prefs.getBoolean("dns_secure", false);
|
||||
|
||||
String filter = null;
|
||||
|
@ -141,7 +142,7 @@ public class DnsHelper {
|
|||
ResolverApi resolver = DnssecResolverApi.INSTANCE;
|
||||
AbstractDnsClient client = resolver.getClient();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && !dns_custom)
|
||||
client.setDataSource(new AbstractDnsDataSource() {
|
||||
private IOException ex;
|
||||
private DnsQueryResult result;
|
||||
|
|
|
@ -94,8 +94,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
private SwitchCompat swPreferIp4;
|
||||
private SwitchCompat swBindSocket;
|
||||
private SwitchCompat swStandaloneVpn;
|
||||
private EditText etDns;
|
||||
private SwitchCompat swDnsCustom;
|
||||
private EditText etDnsExtra;
|
||||
private SwitchCompat swDnsSecure;
|
||||
private SwitchCompat swTcpKeepAlive;
|
||||
private SwitchCompat swSslUpdate;
|
||||
|
@ -162,8 +162,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
swPreferIp4 = view.findViewById(R.id.swPreferIp4);
|
||||
swBindSocket = view.findViewById(R.id.swBindSocket);
|
||||
swStandaloneVpn = view.findViewById(R.id.swStandaloneVpn);
|
||||
etDns = view.findViewById(R.id.etDns);
|
||||
swDnsCustom = view.findViewById(R.id.swDnsCustom);
|
||||
etDnsExtra = view.findViewById(R.id.etDnsExtra);
|
||||
swDnsSecure = view.findViewById(R.id.swDnsSecure);
|
||||
swTcpKeepAlive = view.findViewById(R.id.swTcpKeepAlive);
|
||||
swSslUpdate = view.findViewById(R.id.swSslUpdate);
|
||||
|
@ -343,7 +343,17 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
}
|
||||
});
|
||||
|
||||
etDns.addTextChangedListener(new TextWatcher() {
|
||||
swDnsCustom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
|
||||
DnsHelper.clear(buttonView.getContext());
|
||||
prefs.edit().putBoolean("dns_custom", checked).apply();
|
||||
etDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);
|
||||
swDnsSecure.setEnabled(checked);
|
||||
}
|
||||
});
|
||||
|
||||
etDnsExtra.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// Do nothing
|
||||
|
@ -360,15 +370,6 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
}
|
||||
});
|
||||
|
||||
swDnsCustom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
|
||||
DnsHelper.clear(buttonView.getContext());
|
||||
prefs.edit().putBoolean("dns_custom", checked).apply();
|
||||
swDnsSecure.setEnabled(checked);
|
||||
}
|
||||
});
|
||||
|
||||
swDnsSecure.setVisibility(debug || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
swDnsSecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
@ -759,8 +760,9 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
swPreferIp4.setChecked(prefs.getBoolean("prefer_ip4", true));
|
||||
swBindSocket.setChecked(prefs.getBoolean("bind_socket", false));
|
||||
swStandaloneVpn.setChecked(prefs.getBoolean("standalone_vpn", false));
|
||||
etDns.setText(prefs.getString("dns_extra", null));
|
||||
swDnsCustom.setChecked(prefs.getBoolean("dns_custom", false));
|
||||
etDnsExtra.setText(prefs.getString("dns_extra", null));
|
||||
etDnsExtra.setEnabled(swDnsCustom.isEnabled() || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);
|
||||
swDnsSecure.setChecked(prefs.getBoolean("dns_secure", false));
|
||||
swDnsSecure.setEnabled(swDnsCustom.isChecked());
|
||||
swTcpKeepAlive.setChecked(prefs.getBoolean("tcp_keep_alive", false));
|
||||
|
|
|
@ -423,10 +423,22 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swBindSocket"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDnsCustom"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_dns_custom"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swStandaloneVpn"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDns"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_dns"
|
||||
|
@ -434,10 +446,10 @@
|
|||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swStandaloneVpn" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swDnsCustom" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etDns"
|
||||
android:id="@+id/etDnsExtra"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="48dp"
|
||||
|
@ -448,17 +460,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDns" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDnsCustom"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_dns_custom"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etDns"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDnsSecure"
|
||||
android:layout_width="0dp"
|
||||
|
@ -468,7 +469,7 @@
|
|||
android:text="@string/title_advanced_dns_secure"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDnsCustom"
|
||||
app:layout_constraintTop_toBottomOf="@id/etDnsExtra"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
Loading…
Reference in a new issue