Commit e367e568 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Some more cleanup

parent 7c4316eb
...@@ -174,6 +174,7 @@ class DnsRuleDialog(context: Context, dnsRule: DnsRule? = null, onRuleCreated: ( ...@@ -174,6 +174,7 @@ class DnsRuleDialog(context: Context, dnsRule: DnsRule? = null, onRuleCreated: (
view.ipv4Address.setText(dnsRule.target) view.ipv4Address.setText(dnsRule.target)
view.ipv6Address.setText(dnsRule.ipv6Target) view.ipv6Address.setText(dnsRule.ipv6Target)
} }
else -> {}
} }
isBlockHost = dnsRule.target == "0.0.0.0" && dnsRule.ipv6Target?.equalsAny("::1", "::") == true isBlockHost = dnsRule.target == "0.0.0.0" && dnsRule.ipv6Target?.equalsAny("::1", "::") == true
} }
......
...@@ -320,10 +320,6 @@ class NewServerDialog( ...@@ -320,10 +320,6 @@ class NewServerDialog(
R.string.dialog_doh_detect_type_title, R.string.dialog_doh_detect_type_title,
R.string.dialog_doh_detect_type_message R.string.dialog_doh_detect_type_message
) )
val httpClient = OkHttpClient.Builder()
.connectTimeout(1250, TimeUnit.MILLISECONDS)
.readTimeout(1250, TimeUnit.MILLISECONDS)
.build()
dialog.show() dialog.show()
GlobalScope.launch { GlobalScope.launch {
val availableTypes = mapOf( val availableTypes = mapOf(
......
...@@ -98,7 +98,7 @@ class ServerImportDialog(context: Context, loadedServers: List<DnsServerInformat ...@@ -98,7 +98,7 @@ class ServerImportDialog(context: Context, loadedServers: List<DnsServerInformat
private fun doImport() { private fun doImport() {
val prefs = context.getPreferences() val prefs = context.getPreferences()
prefs.edit { prefs.edit {
val servers = servers.filterIndexed { index, item -> val servers = servers.filterIndexed { index, _ ->
selectedServerPositions.contains(index) selectedServerPositions.contains(index)
} }
prefs.addUserServerConfiguration(servers) prefs.addUserServerConfiguration(servers)
...@@ -109,7 +109,7 @@ class ServerImportDialog(context: Context, loadedServers: List<DnsServerInformat ...@@ -109,7 +109,7 @@ class ServerImportDialog(context: Context, loadedServers: List<DnsServerInformat
val name: TextView = itemView.findViewById(R.id.name) val name: TextView = itemView.findViewById(R.id.name)
private val urls = itemView.findViewById<TextView>(R.id.urls) private val urls = itemView.findViewById<TextView>(R.id.urls)
private val capabilities = itemView.findViewById<TextView>(R.id.capabilities) private val capabilities = itemView.findViewById<TextView>(R.id.capabilities)
val selected = itemView.findViewById<CheckBox>(R.id.checkbox) val selected: CheckBox = itemView.findViewById(R.id.checkbox)
private val serverType = itemView.findViewById<TextView>(R.id.serverType) private val serverType = itemView.findViewById<TextView>(R.id.serverType)
override fun destroy() { override fun destroy() {
......
...@@ -213,9 +213,9 @@ class DnsRuleFragment : Fragment() { ...@@ -213,9 +213,9 @@ class DnsRuleFragment : Fragment() {
adapterDataSource = ListDataSource(sourceAdapterList) adapterDataSource = ListDataSource(sourceAdapterList)
var showUserRules = false var showUserRules = false
var userRuleCount = 0 var userRuleCount = 0
sourceAdapter = ModelAdapterBuilder.withModelAndViewHolder({ view, type -> sourceAdapter = ModelAdapterBuilder.withModelAndViewHolder({ itemView, type ->
when (type) { when (type) {
0 -> SourceViewHolder(view, deleteSource = { 0 -> SourceViewHolder(itemView, deleteSource = {
showInfoTextDialog(requireContext(), showInfoTextDialog(requireContext(),
getString(R.string.dialog_deletehostsource_title, it.name), getString(R.string.dialog_deletehostsource_title, it.name),
getString(R.string.dialog_deletehostsource_message, it.name), getString(R.string.dialog_deletehostsource_message, it.name),
...@@ -268,7 +268,7 @@ class DnsRuleFragment : Fragment() { ...@@ -268,7 +268,7 @@ class DnsRuleFragment : Fragment() {
refreshProgressShown = true refreshProgressShown = true
}) })
1 -> CustomRulesViewHolder( 1 -> CustomRulesViewHolder(
view, itemView,
changeSourceStatus = { changeSourceStatus = {
getPreferences().customHostsEnabled = it getPreferences().customHostsEnabled = it
}, },
...@@ -364,7 +364,7 @@ class DnsRuleFragment : Fragment() { ...@@ -364,7 +364,7 @@ class DnsRuleFragment : Fragment() {
} }
}).show() }).show()
}) })
else -> CustomRuleHostViewHolder(view, deleteRule = { else -> CustomRuleHostViewHolder(itemView, deleteRule = {
val index = userDnsRules.indexOf(it) val index = userDnsRules.indexOf(it)
userDnsRules.remove(it) userDnsRules.remove(it)
getDatabase().dnsRuleRepository().removeAsync(it) getDatabase().dnsRuleRepository().removeAsync(it)
......
...@@ -310,7 +310,7 @@ class MainFragment : Fragment() { ...@@ -310,7 +310,7 @@ class MainFragment : Fragment() {
} }
private fun updatePrivacyPolicyLink(serverInfo: DnsServerInformation<*>) { private fun updatePrivacyPolicyLink(serverInfo: DnsServerInformation<*>) {
activity?.let { activity -> activity?.let { _ ->
if (!serverInfo.specification.privacyPolicyURL.isNullOrBlank()) { if (!serverInfo.specification.privacyPolicyURL.isNullOrBlank()) {
launchWithLifecycle { launchWithLifecycle {
val url = URL(serverInfo.specification.privacyPolicyURL) val url = URL(serverInfo.specification.privacyPolicyURL)
......
...@@ -228,7 +228,7 @@ class ConfigureActivity : BaseActivity() { ...@@ -228,7 +228,7 @@ class ConfigureActivity : BaseActivity() {
} }
}) })
editText.setOnFocusChangeListener { _, hasFocus -> editText.setOnFocusChangeListener { _, _ ->
setHints() setHints()
} }
} }
......
...@@ -86,6 +86,7 @@ class DnsSpeedTest(context:Context, ...@@ -86,6 +86,7 @@ class DnsSpeedTest(context:Context,
for (i in 0 until passes) { for (i in 0 until passes) {
when(server.type) { when(server.type) {
ServerType.DOT -> { ServerType.DOT -> {
@Suppress("UNCHECKED_CAST")
(server as DnsServerInformation<TLSUpstreamAddress>).servers.forEach { (server as DnsServerInformation<TLSUpstreamAddress>).servers.forEach {
if(firstPass) testTls(it.address) if(firstPass) testTls(it.address)
latencies += testTls(it.address) ?: 0 latencies += testTls(it.address) ?: 0
...@@ -105,6 +106,7 @@ class DnsSpeedTest(context:Context, ...@@ -105,6 +106,7 @@ class DnsSpeedTest(context:Context,
} }
} }
ServerType.DOQ -> { ServerType.DOQ -> {
@Suppress("UNCHECKED_CAST")
(server as DnsServerInformation<QuicUpstreamAddress>).servers.forEach { (server as DnsServerInformation<QuicUpstreamAddress>).servers.forEach {
if(cronetEngine != null) { if(cronetEngine != null) {
if(firstPass) testQuic(it.address) if(firstPass) testQuic(it.address)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment