Commit 21238f87 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Lint suggestions

parent a0e0b1b2
......@@ -65,8 +65,8 @@ class QueryImportActivity: AppCompatActivity() {
val source = if(split[5].equals("false", true) || split[5].equals("true", true)) {
if (split[5].toBoolean()) QueryListener.Source.CACHE
else QueryListener.Source.UPSTREAM
} else QueryListener.Source.values().find {
it.name.equals(split[5], true)
} else QueryListener.Source.values().find { source ->
source.name.equals(split[5], true)
} ?: QueryListener.Source.UPSTREAM
queries.add(DnsQuery(
name=split[0],
......
......@@ -148,12 +148,12 @@ class ServerImportActivity : BaseActivity() {
else reader.skipValue()
}
if (reader.readJsonArray {
if (!reader.readJsonArray {
val previousSize = serverTypes.size
if (reader.readJsonObject(block = readServerType) && serverTypes.size == previousSize) serverTypes.add(
true
)
}) else {
}){
val previousSize = serverTypes.size
if (reader.readJsonObject(block = readServerType) && serverTypes.size == previousSize) serverTypes.add(true)
}
......
......@@ -146,16 +146,16 @@ class DnsRuleDialog(context: Context, dnsRule: DnsRule? = null, onRuleCreated: (
view.ipv6Til.visibility = View.GONE
} else {
view.host.setText(printableHost(dnsRule.host))
when {
dnsRule.type == Record.TYPE.A -> {
when (dnsRule.type) {
Record.TYPE.A -> {
view.ipv4Address.setText(dnsRule.target)
view.ipv6Address.text = null
}
dnsRule.type == Record.TYPE.AAAA -> {
Record.TYPE.AAAA -> {
view.ipv4Address.text = null
view.ipv6Address.setText(dnsRule.target)
}
dnsRule.type == Record.TYPE.ANY -> {
Record.TYPE.ANY -> {
view.ipv4Address.setText(dnsRule.target)
view.ipv6Address.setText(dnsRule.ipv6Target)
}
......
@file:Suppress("BlockingMethodInNonBlockingContext")
package com.frostnerd.smokescreen.dialog
import android.content.Context
......@@ -369,7 +371,7 @@ class QueryGeneratorDialog(context: Context):AlertDialog(context, context.getPre
}
val restartVpn = view.restartVpn.isChecked
val runCount = iterations.text.toString().toIntOrNull() ?: 1
job = generatorScope!!.launch {
job = generatorScope.launch {
context.log("Generating queries for ${urlsToUse.size} urls $runCount times", "[QueryGenerator]")
val logFileWriter = BufferedWriter(FileWriter(File(context.filesDir, "querygenlog.txt"), true))
val callWithChrome = useChrome.isChecked
......@@ -392,7 +394,7 @@ class QueryGeneratorDialog(context: Context):AlertDialog(context, context.getPre
}
}
job = null
generatorScope?.cancel()
generatorScope.cancel()
loadingDialog?.cancel()
}
showLoadingDialog()
......
......@@ -229,12 +229,12 @@ class DnsRuleFragment : Fragment() {
this.name = newSource.name
this.source = newSource.source
this.whitelistSource = newSource.whitelistSource
}?.also {
getDatabase().hostSourceDao().update(it)
}?.also { source ->
getDatabase().hostSourceDao().update(source)
val index = sourceAdapterList.indexOf(hostSource).takeIf { it >= 0 } ?: sourceAdapterList.indexOfFirst { it.id == hostSource.id }
sourceAdapterList[index] = it
sourceRuleCount[it] = sourceRuleCount[hostSource]
sourceAdapterList[index] = source
sourceRuleCount[source] = sourceRuleCount[hostSource]
sourceRuleCount.remove(hostSource)
sourceAdapter.notifyItemChanged(index)
}
......
......@@ -173,14 +173,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
exportQueries.summary =
getString(R.string.summary_export_queries, requireContext().getDatabase().dnsQueryDao().getCount())
exportQueries.setOnPreferenceClickListener {
val loadingDialog: LoadingDialog?
if (requireContext().getDatabase().dnsQueryDao().getCount() >= 100) {
loadingDialog = LoadingDialog(
val loadingDialog: LoadingDialog? = if (requireContext().getDatabase().dnsQueryDao().getCount() >= 100) {
LoadingDialog(
requireContext(),
R.string.dialog_query_export_title,
R.string.dialog_query_export_message
)
} else loadingDialog = null
} else null
loadingDialog?.show()
requireContext().getDatabase().dnsQueryRepository().exportQueriesAsCsvAsync(requireContext(), { file ->
if (!isDetached && !isRemoving) {
......
......@@ -150,9 +150,9 @@ class QueryLogDetailFragment : Fragment() {
query.askedServer!!.startsWith("https") -> getString(R.string.fragment_querydetail_mode_doh)
else -> getString(R.string.fragment_querydetail_mode_dot)
}
resolvedBy.text = when {
query.responseSource == QueryListener.Source.CACHE -> getString(R.string.windows_querylogging_usedserver_cache)
query.responseSource == QueryListener.Source.LOCALRESOLVER -> getString(R.string.windows_querylogging_usedserver_dnsrules)
resolvedBy.text = when (query.responseSource) {
QueryListener.Source.CACHE -> getString(R.string.windows_querylogging_usedserver_cache)
QueryListener.Source.LOCALRESOLVER -> getString(R.string.windows_querylogging_usedserver_dnsrules)
else -> query.askedServer?.replace("tls::", "")?.replace("https::", "") ?: "-"
}
responses.text = query.getParsedResponses().joinToString(separator = "\n") {
......
......@@ -881,7 +881,7 @@ class DnsVpnService : VpnService(), Runnable {
if (address is Inet6Address && useIpv6) {
log("Adding route for Ipv6 $address")
builder.addRoute(address, 128)
} else if (address is Inet4Address && useIpv4 && !address.hostAddress.equals("1.1.1.1")) {
} else if (address is Inet4Address && useIpv4 && address.hostAddress != "1.1.1.1") {
log("Adding route for Ipv4 $address")
builder.addRoute(address, 32)
}
......
......@@ -126,17 +126,17 @@ class Notifications {
}
object RequestCodes {
val max = 20
const val max = 20
val CRASH_NOTIFICATION = 1
val CRASH_NOTIFICATION_SEND_LOGS = 2
val MAIN_NOTIFICATION = 3
val MAIN_NOTIFICATION_STOP = 4
val MAIN_NOTIFICATION_PAUSE = 5
val VPN_CONFIGURE = 6
val RULE_IMPORT_ABORT = 7
val RULE_EXPORT_ABORT = 8
val PIN_NOTIFICATION = 9
val REQUEST_CODE_IGNORE_SERVICE_KILLED = 10
val RESTART_AFTER_REVOKE = 11
const val CRASH_NOTIFICATION = 1
const val CRASH_NOTIFICATION_SEND_LOGS = 2
const val MAIN_NOTIFICATION = 3
const val MAIN_NOTIFICATION_STOP = 4
const val MAIN_NOTIFICATION_PAUSE = 5
const val VPN_CONFIGURE = 6
const val RULE_IMPORT_ABORT = 7
const val RULE_EXPORT_ABORT = 8
const val PIN_NOTIFICATION = 9
const val REQUEST_CODE_IGNORE_SERVICE_KILLED = 10
const val RESTART_AFTER_REVOKE = 11
}
\ No newline at end of file
......@@ -27,7 +27,7 @@ import java.net.InetAddress
* You can contact the developer at daniel.wolf@frostnerd.com.
*/
class ProxyHttpsHandler(
val ownAddresses:List<String>,
private val ownAddresses:List<String>,
serverConfigurations: List<ServerConfiguration>,
connectTimeout: Long,
val queryCountCallback: (() -> Unit)? = null,
......
......@@ -39,7 +39,7 @@ import javax.net.ssl.SSLSession
*/
class ProxyTlsHandler(
val ownAddresses:List<String>,
private val ownAddresses:List<String>,
private val upstreamAddresses: List<TLSUpstreamAddress>,
connectTimeout: Int,
val queryCountCallback: (() -> Unit)? = null,
......
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