aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreuxane2024-09-18 23:41:13 +0200
committereuxane2024-09-18 23:41:13 +0200
commit286bd6c17baa050854f4354c502f89b2e16e59bd (patch)
treee91f1f83099eef924f90e617750fdc5cec40bd5e
parent58f563a79867ae5973d5d45dba265f1b293bb0c3 (diff)
downloadtincapp-286bd6c17baa050854f4354c502f89b2e16e59bd.tar.gz
treewide: apply trivial lints
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseDialogFragment.kt2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/common/RecentCrashHandler.kt2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/start/ErrorNotificationFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt7
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/subnets/SubnetListFragment.kt2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/viewlog/ViewLogActivity.kt2
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt6
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt2
13 files changed, 21 insertions, 22 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
index 6f18565..4e9f983 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -87,7 +87,7 @@ abstract class BaseActivity : AppCompatActivity() {
87 resources.getString(R.string.about_app_license) + "\n\n" + 87 resources.getString(R.string.about_app_license) + "\n\n" +
88 AppInfo.all()) 88 AppInfo.all())
89 .setNeutralButton(R.string.about_app_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.about_app_website_url)) } 89 .setNeutralButton(R.string.about_app_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.about_app_website_url)) }
90 .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit } 90 .setPositiveButton(R.string.generic_action_close) { _, _ -> }
91 .show() 91 .show()
92 } 92 }
93 93
@@ -104,7 +104,7 @@ abstract class BaseActivity : AppCompatActivity() {
104 fun showErrorDialog(msg: String, docTopic: String? = null): AlertDialog = 104 fun showErrorDialog(msg: String, docTopic: String? = null): AlertDialog =
105 AlertDialog.Builder(this) 105 AlertDialog.Builder(this)
106 .setTitle(R.string.generic_title_error).setMessage(msg) 106 .setTitle(R.string.generic_title_error).setMessage(msg)
107 .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit } 107 .setPositiveButton(R.string.generic_action_close) { _, _ -> }
108 .apply { 108 .apply {
109 if (docTopic != null) 109 if (docTopic != null)
110 setNeutralButton(R.string.notification_error_action_open_manual) { _, _ -> 110 setNeutralButton(R.string.notification_error_action_open_manual) { _, _ ->
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseDialogFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseDialogFragment.kt
index 4888cd0..05eadd5 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseDialogFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseDialogFragment.kt
@@ -28,5 +28,5 @@ import android.view.LayoutInflater
28abstract class BaseDialogFragment : DialogFragment() { 28abstract class BaseDialogFragment : DialogFragment() {
29 protected val parentActivity by lazy { activity as BaseActivity } 29 protected val parentActivity by lazy { activity as BaseActivity }
30 // getLayoutInflater() calls onCreateDialog. See https://stackoverflow.com/a/15152788 30 // getLayoutInflater() calls onCreateDialog. See https://stackoverflow.com/a/15152788
31 protected val dialogLayoutInflater by lazy { activity!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater } 31 protected val dialogLayoutInflater by lazy { requireActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater }
32} 32}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/common/RecentCrashHandler.kt b/app/src/main/java/org/pacien/tincapp/activities/common/RecentCrashHandler.kt
index 8f53e08..92f82c2 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/common/RecentCrashHandler.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/common/RecentCrashHandler.kt
@@ -42,7 +42,7 @@ class RecentCrashHandler(private val parentActivity: BaseActivity) {
42 .setTitle(R.string.crash_modal_title) 42 .setTitle(R.string.crash_modal_title)
43 .setMessage(makeMessage()) 43 .setMessage(makeMessage())
44 .setNeutralButton(R.string.crash_modal_action_send_report) { _, _ -> sendReportMail() } 44 .setNeutralButton(R.string.crash_modal_action_send_report) { _, _ -> sendReportMail() }
45 .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit } 45 .setPositiveButton(R.string.generic_action_close) { _, _ -> }
46 .show() 46 .show()
47 } 47 }
48 48
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 533faa9..c146c24 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
@@ -39,8 +39,8 @@ abstract class ConfigurationToolDialogFragment : BaseDialogFragment() {
39 .setTitle(title) 39 .setTitle(title)
40 .setView(viewBinding.root) 40 .setView(viewBinding.root)
41 .setPositiveButton(applyButton) { _, _ -> applyAction(viewBinding) } 41 .setPositiveButton(applyButton) { _, _ -> applyAction(viewBinding) }
42 .setNegativeButton(R.string.generic_action_cancel) { _, _ -> Unit } 42 .setNegativeButton(R.string.generic_action_cancel) { _, _ -> }
43 .create()!! 43 .create()
44 44
45 protected fun execAction(@StringRes label: Int, action: CompletableFuture<Unit>) { 45 protected fun execAction(@StringRes label: Int, action: CompletableFuture<Unit>) {
46 ProgressModal.show(parentActivity, getString(label)).let { progressDialog -> 46 ProgressModal.show(parentActivity, getString(label)).let { progressDialog ->
diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt
index 05df357..ef94489 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt
@@ -59,7 +59,7 @@ class ConnectionStarter(private val parentActivity: StartActivity) {
59 .setTitle(R.string.decrypt_key_modal_title) 59 .setTitle(R.string.decrypt_key_modal_title)
60 .setView(dialogViewBinding.root) 60 .setView(dialogViewBinding.root)
61 .setPositiveButton(R.string.decrypt_key_modal_action_unlock) { _, _ -> tryStart(passphrase = dialogViewBinding.passphrase.text.toString()) } 61 .setPositiveButton(R.string.decrypt_key_modal_action_unlock) { _, _ -> tryStart(passphrase = dialogViewBinding.passphrase.text.toString()) }
62 .setNegativeButton(R.string.decrypt_key_modal_action_cancel) { _, _ -> Unit } 62 .setNegativeButton(R.string.decrypt_key_modal_action_cancel) { _, _ -> }
63 .create() 63 .create()
64 64
65 dialogViewBinding.passphrase.on(EditorInfo.IME_ACTION_DONE) { 65 dialogViewBinding.passphrase.on(EditorInfo.IME_ACTION_DONE) {
diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/ErrorNotificationFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/start/ErrorNotificationFragment.kt
index fdfa8f6..08dab8d 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/start/ErrorNotificationFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/start/ErrorNotificationFragment.kt
@@ -32,11 +32,11 @@ import org.pacien.tincapp.databinding.StartErrorNotificationBinding
32 * @author euxane 32 * @author euxane
33 */ 33 */
34class ErrorNotificationFragment : BaseFragment() { 34class ErrorNotificationFragment : BaseFragment() {
35 private val notificationManager by lazy { AppNotificationManager(context!!) } 35 private val notificationManager by lazy { AppNotificationManager(requireContext()) }
36 private val notificationListener = OnSharedPreferenceChangeListener { _, _ -> updateView() } 36 private val notificationListener = OnSharedPreferenceChangeListener { _, _ -> updateView() }
37 private lateinit var viewBinding: StartErrorNotificationBinding 37 private lateinit var viewBinding: StartErrorNotificationBinding
38 38
39 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 39 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
40 viewBinding = StartErrorNotificationBinding.inflate(inflater, container, false) 40 viewBinding = StartErrorNotificationBinding.inflate(inflater, container, false)
41 updateView() 41 updateView()
42 return viewBinding.root 42 return viewBinding.root
diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt
index fc5b6ff..988e877 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt
@@ -18,7 +18,6 @@
18 18
19package org.pacien.tincapp.activities.start 19package org.pacien.tincapp.activities.start
20 20
21import androidx.lifecycle.Observer
22import android.os.Bundle 21import android.os.Bundle
23import android.view.LayoutInflater 22import android.view.LayoutInflater
24import android.view.View 23import android.view.View
@@ -40,14 +39,14 @@ class NetworkListFragment : BaseFragment() {
40 private val networkListViewModel by lazy { NetworkListViewModel() } 39 private val networkListViewModel by lazy { NetworkListViewModel() }
41 private val networkListAdapter by lazy { ArrayAdapter<String>(requireContext(), R.layout.start_network_list_item) } 40 private val networkListAdapter by lazy { ArrayAdapter<String>(requireContext(), R.layout.start_network_list_item) }
42 private lateinit var startNetworkListBinding: StartNetworkListBinding 41 private lateinit var startNetworkListBinding: StartNetworkListBinding
43 var connectToNetworkAction = { _: String -> Unit } 42 var connectToNetworkAction = { _: String -> }
44 43
45 override fun onCreate(savedInstanceState: Bundle?) { 44 override fun onCreate(savedInstanceState: Bundle?) {
46 super.onCreate(savedInstanceState) 45 super.onCreate(savedInstanceState)
47 networkListViewModel.networkList.observe(this, Observer { updateNetworkList(it.orEmpty()) }) 46 networkListViewModel.networkList.observe(this) { updateNetworkList(it.orEmpty()) }
48 } 47 }
49 48
50 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 49 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
51 startNetworkListBinding = StartNetworkListBinding.inflate(inflater, container, false) 50 startNetworkListBinding = StartNetworkListBinding.inflate(inflater, container, false)
52 return startNetworkListBinding.root 51 return startNetworkListBinding.root
53 } 52 }
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 92d6312..c8a6c0e 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
@@ -29,7 +29,7 @@ object VpnInterfaceConfigurationFormatter {
29 private val resources by lazy { App.getResources() } 29 private val resources by lazy { App.getResources() }
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.isNullOrEmpty() -> 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
diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt
index b96e5fb..627cae4 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt
@@ -42,7 +42,7 @@ class NodeListFragment : BaseFragment() {
42 private val vpnService = TincVpnService 42 private val vpnService = TincVpnService
43 private val tincCtl = Tinc 43 private val tincCtl = Tinc
44 private val netName by lazy { vpnService.getCurrentNetName()!! } 44 private val netName by lazy { vpnService.getCurrentNetName()!! }
45 private val nodeListViewModel by lazy { ViewModelProvider(this).get(NodeListViewModel::class.java) } 45 private val nodeListViewModel by lazy { ViewModelProvider(this)[NodeListViewModel::class.java] }
46 private val nodeListAdapter by lazy { NodeInfoArrayAdapter(requireContext(), this::onItemClick) } 46 private val nodeListAdapter by lazy { NodeInfoArrayAdapter(requireContext(), this::onItemClick) }
47 private lateinit var statusNodeListFragmentBinding: StatusNodeListFragmentBinding