aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorpacien2020-09-08 20:21:26 +0200
committerpacien2020-09-08 20:21:55 +0200
commit31dcb2c5dd6a0546209f74dab49f5282f0a5bda4 (patch)
treed0374561df8bc14ba7cb69ad1a82ffa7156cc7c2 /app
parent9d72cf6bbf426b9b8fa9f94d98d60f62f6081ed8 (diff)
downloadtincapp-31dcb2c5dd6a0546209f74dab49f5282f0a5bda4.tar.gz
treewide: fix trivial null assertion warnings
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt6
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt22
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/TincApp.kt7
5 files changed, 22 insertions, 21 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt b/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt
index 7603fa7..3c17afd 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2019 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@ class FragmentListPagerAdapter(private val pages: List<Pair<Int, BaseFragment>>,
32 32
33 private val resources by lazy { App.getResources() } 33 private val resources by lazy { App.getResources() }
34 34
35 override fun getPageTitle(position: Int) = resources.getString(pages[position].first)!! 35 override fun getPageTitle(position: Int) = resources.getString(pages[position].first)
36 override fun getItem(position: Int) = pages[position].second 36 override fun getItem(position: Int) = pages[position].second
37 override fun getCount() = pages.size 37 override fun getCount() = pages.size
38} 38}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt
index cfb365c..d95a1f7 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2019 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ import java.util.regex.Pattern
33 * @author pacien 33 * @author pacien
34 */ 34 */
35abstract class ConfigurationToolDialogFragment : BaseDialogFragment() { 35abstract class ConfigurationToolDialogFragment : BaseDialogFragment() {
36 private val networkNamePattern by lazy { Pattern.compile("^[^\\x00/]*$")!! } 36 private val networkNamePattern by lazy { Pattern.compile("^[^\\x00/]*$") }
37 37
38 protected fun makeDialog(@LayoutRes layout: Int, @StringRes title: Int, @StringRes applyButton: Int, applyAction: (View) -> Unit) = 38 protected fun makeDialog(@LayoutRes layout: Int, @StringRes title: Int, @StringRes applyButton: Int, applyAction: (View) -> Unit) =
39 makeDialog(inflate(layout), title, applyButton, applyAction) 39 makeDialog(inflate(layout), title, applyButton, applyAction)
@@ -51,7 +51,7 @@ abstract class ConfigurationToolDialogFragment : BaseDialogFragment() {
51 action 51 action
52 .whenComplete { _, _ -> progressDialog.dismiss() } 52 .whenComplete { _, _ -> progressDialog.dismiss() }
53 .thenAccept { parentActivity.notify(R.string.configure_tools_message_network_configuration_written) } 53 .thenAccept { parentActivity.notify(R.string.configure_tools_message_network_configuration_written) }
54 .exceptionallyAccept { parentActivity.runOnUiThread { parentActivity.showErrorDialog(it.cause!!.localizedMessage) } } 54 .exceptionallyAccept { parentActivity.runOnUiThread { parentActivity.showErrorDialog(it.cause!!.localizedMessage!!) } }
55 } 55 }
56 } 56 }
57 57
diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt b/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt
index 2956cb4..dcab449 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2018 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ object VpnInterfaceConfigurationFormatter {
30 30
31 fun formatList(list: List<Any>?) = when { 31 fun formatList(list: List<Any>?) = when {
32 list != null && list.isNotEmpty() -> list.joinToString("\n", transform = this::formatListElement) 32 list != null && list.isNotEmpty() -> list.joinToString("\n", transform = this::formatListElement)
33 else -> resources.getString(R.string.status_network_info_value_none)!! 33 else -> resources.getString(R.string.status_network_info_value_none)
34 } 34 }
35 35
36 private fun formatListElement(element: Any) = when (element) { 36 private fun formatListElement(element: Any) = when (element) {
diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt
index 06725dc..6523250 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2018 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -80,18 +80,18 @@ data class NodeInfo(val name: String,
80 id = matcher[2], 80 id = matcher[2],
81 ip = matcher[3], 81 ip = matcher[3],
82 port = matcher[4], 82 port = matcher[4],
83 cipher = matcher[5].toInt(), 83 cipher = matcher[5]!!.toInt(),
84 digest = matcher[6].toInt(), 84 digest = matcher[6]!!.toInt(),
85 macLength = matcher[7].toInt(), 85 macLength = matcher[7]!!.toInt(),
86 compression = matcher[8].toInt(), 86 compression = matcher[8]!!.toInt(),
87 options = matcher[9].toInt(16), 87 options = matcher[9]!!.toInt(16),
88 status = matcher[10].toInt(16), 88 status = matcher[10]!!.toInt(16),
89 nextHop = matcher[11], 89 nextHop = matcher[11],
90 via = matcher[12], 90 via = matcher[12],
91 distance = matcher[13].toInt(), 91 distance = matcher[13]!!.toInt(),
92 pMtu = matcher[14].toInt(), 92 pMtu = matcher[14]!!.toInt(),
93 minMtu = matcher[15].toInt(), 93 minMtu = matcher[15]!!.toInt(),
94 maxMtu = matcher[16].toInt() 94 maxMtu = matcher[16]!!.toInt()
95 ) 95 )
96 96
97 private operator fun Matcher.get(index: Int) = group(index) 97 private operator fun Matcher.get(index: Int) = group(index)
diff --git a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt
index e7ad8e5..032b20e 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2018 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -34,8 +34,9 @@ object TincApp {
34 private val SCRIPT_SUFFIXES = listOf("-up", "-down", "-created", "-accepted") 34 private val SCRIPT_SUFFIXES = listOf("-up", "-down", "-created", "-accepted")
35 private val STATIC_SCRIPTS = listOf("tinc", "host", "subnet", "invitation").flatMap { s -> SCRIPT_SUFFIXES.map { s + it } } 35 private val STATIC_SCRIPTS = listOf("tinc", "host", "subnet", "invitation").flatMap { s -> SCRIPT_SUFFIXES.map { s + it } }
36 36
37 private fun listScripts(netName: String) = AppPaths.confDir(netName).listFiles { f -> f.name in STATIC_SCRIPTS } + 37 private fun listScripts(netName: String) =
38 AppPaths.hostsDir(netName).listFiles { f -> SCRIPT_SUFFIXES.any { f.name.endsWith(it) } } 38 AppPaths.confDir(netName).listFiles { f -> f.name in STATIC_SCRIPTS }!! +
39 AppPaths.hostsDir(netName).listFiles { f -> SCRIPT_SUFFIXES.any { f.name.endsWith(it) } }!!
39 40
40 fun listPrivateKeys(netName: String) = try { 41 fun listPrivateKeys(netName: String) = try {
41 TincConfiguration.fromTincConfiguration(AppPaths.existing(AppPaths.tincConfFile(netName))).let { 42 TincConfiguration.fromTincConfiguration(AppPaths.existing(AppPaths.tincConfFile(netName))).let {