diff options
author | pacien | 2018-08-05 22:12:46 +0200 |
---|---|---|
committer | pacien | 2018-08-05 22:12:46 +0200 |
commit | 9012ef92ed810f4a08b5f01cd2c18430a277eacf (patch) | |
tree | 7e2dc8f9b61698e895fab07bc524575af5ec484b /app/src/main/java/org/pacien | |
parent | a9d1ac81374119e33871484c8749a94d11a71cae (diff) | |
download | tincapp-9012ef92ed810f4a08b5f01cd2c18430a277eacf.tar.gz |
Code style
Diffstat (limited to 'app/src/main/java/org/pacien')
16 files changed, 100 insertions, 84 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 3e2bebd..4b1cb91 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt | |||
@@ -78,7 +78,7 @@ abstract class BaseActivity : AppCompatActivity() { | |||
78 | resources.getString(R.string.app_license) + "\n\n" + | 78 | resources.getString(R.string.app_license) + "\n\n" + |
79 | AppInfo.all()) | 79 | AppInfo.all()) |
80 | .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) } | 80 | .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) } |
81 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }) | 81 | .setPositiveButton(R.string.action_close) { _, _ -> Unit } |
82 | .show() | 82 | .show() |
83 | } | 83 | } |
84 | 84 | ||
@@ -96,13 +96,13 @@ abstract class BaseActivity : AppCompatActivity() { | |||
96 | resources.getString(R.string.message_app_crash), | 96 | resources.getString(R.string.message_app_crash), |
97 | resources.getString(R.string.message_crash_logged, AppPaths.appLogFile().absolutePath) | 97 | resources.getString(R.string.message_crash_logged, AppPaths.appLogFile().absolutePath) |
98 | ).joinToString("\n\n")) | 98 | ).joinToString("\n\n")) |
99 | .setNeutralButton(R.string.action_send_report, { _, _ -> | 99 | .setNeutralButton(R.string.action_send_report) { _, _ -> |
100 | App.sendMail( | 100 | App.sendMail( |
101 | resources.getString(R.string.app_dev_email), | 101 | resources.getString(R.string.app_dev_email), |
102 | listOf(R.string.app_name, R.string.title_app_crash).joinToString(" / ", transform = resources::getString), | 102 | listOf(R.string.app_name, R.string.title_app_crash).joinToString(" / ", transform = resources::getString), |
103 | AppPaths.appLogFile().let { if (it.exists()) it.readText() else "" }) | 103 | AppPaths.appLogFile().let { if (it.exists()) it.readText() else "" }) |
104 | }) | 104 | } |
105 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }) | 105 | .setPositiveButton(R.string.action_close) { _, _ -> Unit } |
106 | .show() | 106 | .show() |
107 | } | 107 | } |
108 | 108 | ||
@@ -111,5 +111,5 @@ abstract class BaseActivity : AppCompatActivity() { | |||
111 | protected fun showProgressDialog(@StringRes msg: Int): AlertDialog = ProgressModal.show(this, getString(msg)) | 111 | protected fun showProgressDialog(@StringRes msg: Int): AlertDialog = ProgressModal.show(this, getString(msg)) |
112 | protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) | 112 | protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) |
113 | .setTitle(R.string.title_error).setMessage(msg) | 113 | .setTitle(R.string.title_error).setMessage(msg) |
114 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }).show() | 114 | .setPositiveButton(R.string.action_close) { _, _ -> Unit }.show() |
115 | } | 115 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt index 45a29bf..f823691 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt | |||
@@ -76,7 +76,7 @@ class ConfigureActivity : BaseActivity() { | |||
76 | genDialog.new_net_name.text.toString(), | 76 | genDialog.new_net_name.text.toString(), |
77 | genDialog.new_node_name.text.toString(), | 77 | genDialog.new_node_name.text.toString(), |
78 | genDialog.new_passphrase.text.toString()) | 78 | genDialog.new_passphrase.text.toString()) |
79 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() | 79 | }.setNegativeButton(R.string.action_cancel) { _, _ -> Unit }.show() |
80 | } | 80 | } |
81 | 81 | ||
82 | fun openJoinNetworkDialog(@Suppress("UNUSED_PARAMETER") v: View) { | 82 | fun openJoinNetworkDialog(@Suppress("UNUSED_PARAMETER") v: View) { |
@@ -87,7 +87,7 @@ class ConfigureActivity : BaseActivity() { | |||
87 | joinDialog!!.net_name.text.toString(), | 87 | joinDialog!!.net_name.text.toString(), |
88 | joinDialog!!.invitation_url.text.toString(), | 88 | joinDialog!!.invitation_url.text.toString(), |
89 | joinDialog!!.join_passphrase.text.toString()) | 89 | joinDialog!!.join_passphrase.text.toString()) |
90 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() | 90 | }.setNegativeButton(R.string.action_cancel) { _, _ -> Unit }.show() |
91 | } | 91 | } |
92 | 92 | ||
93 | fun openEncryptDecryptPrivateKeyDialog(@Suppress("UNUSED_PARAMETER") v: View) { | 93 | fun openEncryptDecryptPrivateKeyDialog(@Suppress("UNUSED_PARAMETER") v: View) { |
@@ -98,7 +98,7 @@ class ConfigureActivity : BaseActivity() { | |||
98 | encryptDecryptDialog!!.enc_dec_net_name.text.toString(), | 98 | encryptDecryptDialog!!.enc_dec_net_name.text.toString(), |
99 | encryptDecryptDialog.enc_dec_current_passphrase.text.toString(), | 99 | encryptDecryptDialog.enc_dec_current_passphrase.text.toString(), |
100 | encryptDecryptDialog.enc_dec_new_passphrase.text.toString()) | 100 | encryptDecryptDialog.enc_dec_new_passphrase.text.toString()) |
101 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() | 101 | }.setNegativeButton(R.string.action_cancel) { _, _ -> Unit }.show() |
102 | } | 102 | } |
103 | 103 | ||
104 | private fun writeContent() { | 104 | private fun writeContent() { |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt index fbcde81..4be1609 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | |||
@@ -68,7 +68,7 @@ class StartActivity : BaseActivity() { | |||
68 | } | 68 | } |
69 | 69 | ||
70 | override fun onRefresh() { | 70 | override fun onRefresh() { |
71 | val networks = AppPaths.confDir()?.list()?.toList() ?: emptyList() | 71 | val networks = AppPaths.confDir().list()?.toList() ?: emptyList() |
72 | runOnUiThread { | 72 | runOnUiThread { |
73 | networkListAdapter?.setElements(networks) | 73 | networkListAdapter?.setElements(networks) |
74 | setPlaceholderVisibility() | 74 | setPlaceholderVisibility() |
@@ -121,7 +121,7 @@ class StartActivity : BaseActivity() { | |||
121 | AlertDialog.Builder(this@StartActivity) | 121 | AlertDialog.Builder(this@StartActivity) |
122 | .setTitle(R.string.title_unlock_private_keys).setView(dialog) | 122 | .setTitle(R.string.title_unlock_private_keys).setView(dialog) |
123 | .setPositiveButton(R.string.action_unlock) { _, _ -> tryStart(passphrase = dialog.passphrase.text.toString()) } | 123 | .setPositiveButton(R.string.action_unlock) { _, _ -> tryStart(passphrase = dialog.passphrase.text.toString()) } |
124 | .setNegativeButton(R.string.action_cancel, { _, _ -> Unit }) | 124 | .setNegativeButton(R.string.action_cancel) { _, _ -> Unit } |
125 | .show() | 125 | .show() |
126 | } | 126 | } |
127 | } | 127 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt index cd64355..d5c3278 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt | |||
@@ -189,7 +189,7 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
189 | private const val NOW = 0L | 189 | private const val NOW = 0L |
190 | 190 | ||
191 | fun getNodeNames(): CompletableFuture<List<String>> = TincVpnService.getCurrentNetName()?.let { netName -> | 191 | fun getNodeNames(): CompletableFuture<List<String>> = TincVpnService.getCurrentNetName()?.let { netName -> |
192 | Tinc.dumpNodes(netName).thenApply<List<String>> { it.map { it.substringBefore(' ') } } | 192 | Tinc.dumpNodes(netName).thenApply<List<String>> { list -> list.map { it.substringBefore(' ') } } |
193 | } ?: Executor.supplyAsyncTask<List<String>> { emptyList() } | 193 | } ?: Executor.supplyAsyncTask<List<String>> { emptyList() } |
194 | } | 194 | } |
195 | } | 195 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt index 7630b61..9558b15 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt | |||
@@ -42,7 +42,7 @@ internal object Executor { | |||
42 | /** | 42 | /** |
43 | * @return FAILED (-1) on error, forked child PID otherwise | 43 | * @return FAILED (-1) on error, forked child PID otherwise |
44 | */ | 44 | */ |
45 | private external fun forkExec(argcv: Array<String>): Int | 45 | private external fun forkExec(args: Array<String>): Int |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * @return FAILED (-1) on error, the exit status of the process otherwise | 48 | * @return FAILED (-1) on error, the exit status of the process otherwise |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt b/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt index 86d2583..b55e9a1 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt | |||
@@ -31,7 +31,7 @@ object Tincd { | |||
31 | .withOption("pidfile", AppPaths.pidFile(netName).absolutePath) | 31 | .withOption("pidfile", AppPaths.pidFile(netName).absolutePath) |
32 | .withOption("logfile", AppPaths.logFile(netName).absolutePath) | 32 | .withOption("logfile", AppPaths.logFile(netName).absolutePath) |
33 | .withOption("option", "DeviceType=fd") | 33 | .withOption("option", "DeviceType=fd") |
34 | .withOption("option", "Device=" + deviceFd) | 34 | .withOption("option", "Device=$deviceFd") |
35 | .apply { if (ed25519PrivateKeyFd != null) withOption("option", "Ed25519PrivateKeyFile=/proc/self/fd/$ed25519PrivateKeyFd") } | 35 | .apply { if (ed25519PrivateKeyFd != null) withOption("option", "Ed25519PrivateKeyFile=/proc/self/fd/$ed25519PrivateKeyFd") } |
36 | .apply { if (rsaPrivateKeyFd != null) withOption("option", "PrivateKeyFile=/proc/self/fd/$rsaPrivateKeyFd") }) | 36 | .apply { if (rsaPrivateKeyFd != null) withOption("option", "PrivateKeyFile=/proc/self/fd/$rsaPrivateKeyFd") }) |
37 | } | 37 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/context/App.kt b/app/src/main/java/org/pacien/tincapp/context/App.kt index 89d1c73..2d9151e 100644 --- a/app/src/main/java/org/pacien/tincapp/context/App.kt +++ b/app/src/main/java/org/pacien/tincapp/context/App.kt | |||
@@ -66,7 +66,7 @@ class App : Application() { | |||
66 | AlertDialog.Builder(getContext(), R.style.Theme_AppCompat_Dialog) | 66 | AlertDialog.Builder(getContext(), R.style.Theme_AppCompat_Dialog) |
67 | .setTitle(title).setMessage(msg) | 67 | .setTitle(title).setMessage(msg) |
68 | .apply { if (manualLink != null) setNeutralButton(R.string.action_open_manual) { _, _ -> openURL(manualLink) } } | 68 | .apply { if (manualLink != null) setNeutralButton(R.string.action_open_manual) { _, _ -> openURL(manualLink) } } |
69 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }) | 69 | .setPositiveButton(R.string.action_close) { _, _ -> Unit } |
70 | .create().apply { window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR) }.show() | 70 | .create().apply { window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR) }.show() |
71 | } | 71 | } |
72 | 72 | ||
diff --git a/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt b/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt index a7f5439..76da98f 100644 --- a/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt +++ b/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt | |||
@@ -26,17 +26,17 @@ import org.pacien.tincapp.R | |||
26 | * @author pacien | 26 | * @author pacien |