diff options
Diffstat (limited to 'app')
17 files changed, 7 insertions, 53 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 c092111..44f3210 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt | |||
@@ -18,7 +18,6 @@ import org.pacien.tincapp.context.AppInfo | |||
18 | * @author pacien | 18 | * @author pacien |
19 | */ | 19 | */ |
20 | abstract class BaseActivity : AppCompatActivity() { | 20 | abstract class BaseActivity : AppCompatActivity() { |
21 | |||
22 | override fun onCreate(savedInstanceState: Bundle?) { | 21 | override fun onCreate(savedInstanceState: Bundle?) { |
23 | super.onCreate(savedInstanceState) | 22 | super.onCreate(savedInstanceState) |
24 | setContentView(R.layout.base) | 23 | setContentView(R.layout.base) |
@@ -38,7 +37,7 @@ abstract class BaseActivity : AppCompatActivity() { | |||
38 | resources.getString(R.string.app_license) + "\n\n" + | 37 | resources.getString(R.string.app_license) + "\n\n" + |
39 | AppInfo.all()) | 38 | AppInfo.all()) |
40 | .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) } | 39 | .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) } |
41 | .setPositiveButton(R.string.action_close, App.dismissAction) | 40 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }) |
42 | .show() | 41 | .show() |
43 | } | 42 | } |
44 | 43 | ||
@@ -47,6 +46,5 @@ abstract class BaseActivity : AppCompatActivity() { | |||
47 | protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, false) | 46 | protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, false) |
48 | protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) | 47 | protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) |
49 | .setTitle(R.string.title_error).setMessage(msg) | 48 | .setTitle(R.string.title_error).setMessage(msg) |
50 | .setPositiveButton(R.string.action_close, App.dismissAction).show() | 49 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }).show() |
51 | |||
52 | } | 50 | } |
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 ec17c11..a67887c 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt | |||
@@ -17,7 +17,6 @@ import kotlinx.android.synthetic.main.page_configure.* | |||
17 | import org.pacien.tincapp.R | 17 | import org.pacien.tincapp.R |
18 | import org.pacien.tincapp.commands.Tinc | 18 | import org.pacien.tincapp.commands.Tinc |
19 | import org.pacien.tincapp.commands.TincApp | 19 | import org.pacien.tincapp.commands.TincApp |
20 | import org.pacien.tincapp.context.App | ||
21 | import org.pacien.tincapp.context.AppPaths | 20 | import org.pacien.tincapp.context.AppPaths |
22 | import org.pacien.tincapp.extensions.Java.exceptionallyAccept | 21 | import org.pacien.tincapp.extensions.Java.exceptionallyAccept |
23 | 22 | ||
@@ -25,7 +24,6 @@ import org.pacien.tincapp.extensions.Java.exceptionallyAccept | |||
25 | * @author pacien | 24 | * @author pacien |
26 | */ | 25 | */ |
27 | class ConfigureActivity : BaseActivity() { | 26 | class ConfigureActivity : BaseActivity() { |
28 | |||
29 | companion object { | 27 | companion object { |
30 | val REQUEST_SCAN = 0 | 28 | val REQUEST_SCAN = 0 |
31 | val SCAN_PROVIDER = "com.google.zxing.client.android" | 29 | val SCAN_PROVIDER = "com.google.zxing.client.android" |
@@ -55,7 +53,7 @@ class ConfigureActivity : BaseActivity() { | |||
55 | .setMessage(R.string.message_no_qr_code_scanner) | 53 | .setMessage(R.string.message_no_qr_code_scanner) |
56 | .setPositiveButton(R.string.action_install) { _, _ -> | 54 | .setPositiveButton(R.string.action_install) { _, _ -> |
57 | startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$SCAN_PROVIDER"))) | 55 | startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$SCAN_PROVIDER"))) |
58 | }.setNegativeButton(R.string.action_cancel, App.dismissAction).show() | 56 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() |
59 | } | 57 | } |
60 | } | 58 | } |
61 | 59 | ||
@@ -67,7 +65,7 @@ class ConfigureActivity : BaseActivity() { | |||
67 | genDialog.new_net_name.text.toString(), | 65 | genDialog.new_net_name.text.toString(), |
68 | genDialog.new_node_name.text.toString(), | 66 | genDialog.new_node_name.text.toString(), |
69 | genDialog.new_passphrase.text.toString()) | 67 | genDialog.new_passphrase.text.toString()) |
70 | }.setNegativeButton(R.string.action_cancel, App.dismissAction).show() | 68 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() |
71 | } | 69 | } |
72 | 70 | ||
73 | fun openJoinNetworkDialog(@Suppress("UNUSED_PARAMETER") v: View) { | 71 | fun openJoinNetworkDialog(@Suppress("UNUSED_PARAMETER") v: View) { |
@@ -78,7 +76,7 @@ class ConfigureActivity : BaseActivity() { | |||
78 | joinDialog!!.net_name.text.toString(), | 76 | joinDialog!!.net_name.text.toString(), |
79 | joinDialog!!.invitation_url.text.toString(), | 77 | joinDialog!!.invitation_url.text.toString(), |
80 | joinDialog!!.join_passphrase.text.toString()) | 78 | joinDialog!!.join_passphrase.text.toString()) |
81 | }.setNegativeButton(R.string.action_cancel, App.dismissAction).show() | 79 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() |
82 | } | 80 | } |
83 | 81 | ||
84 | fun openEncryptDecryptPrivateKeyDialog(@Suppress("UNUSED_PARAMETER") v: View) { | 82 | fun openEncryptDecryptPrivateKeyDialog(@Suppress("UNUSED_PARAMETER") v: View) { |
@@ -89,7 +87,7 @@ class ConfigureActivity : BaseActivity() { | |||
89 | encryptDecryptDialog!!.enc_dec_net_name.text.toString(), | 87 | encryptDecryptDialog!!.enc_dec_net_name.text.toString(), |
90 | encryptDecryptDialog.enc_dec_current_passphrase.text.toString(), | 88 | encryptDecryptDialog.enc_dec_current_passphrase.text.toString(), |
91 | encryptDecryptDialog.enc_dec_new_passphrase.text.toString()) | 89 | encryptDecryptDialog.enc_dec_new_passphrase.text.toString()) |
92 | }.setNegativeButton(R.string.action_cancel, App.dismissAction).show() | 90 | }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show() |
93 | } | 91 | } |
94 | 92 | ||
95 | private fun writeContent() { | 93 | private fun writeContent() { |
@@ -123,5 +121,4 @@ class ConfigureActivity : BaseActivity() { | |||
123 | .exceptionallyAccept { runOnUiThread { showErrorDialog(it.cause!!.localizedMessage) } } | 121 | .exceptionallyAccept { runOnUiThread { showErrorDialog(it.cause!!.localizedMessage) } } |
124 | } | 122 | } |
125 | } | 123 | } |
126 | |||
127 | } | 124 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Command.kt b/app/src/main/java/org/pacien/tincapp/commands/Command.kt index cb95619..ccb5f10 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Command.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Command.kt | |||
@@ -6,7 +6,6 @@ import java.util.* | |||
6 | * @author pacien | 6 | * @author pacien |
7 | */ | 7 | */ |
8 | internal class Command(private val cmd: String) { | 8 | internal class Command(private val cmd: String) { |
9 | |||
10 | private data class Option(val key: String, val value: String?) { | 9 | private data class Option(val key: String, val value: String?) { |
11 | fun toCommandLineOption(): String = if (value != null) "--$key=$value" else "--$key" | 10 | fun toCommandLineOption(): String = if (value != null) "--$key=$value" else "--$key" |
12 | } | 11 | } |
@@ -25,7 +24,5 @@ internal class Command(private val cmd: String) { | |||
25 | } | 24 | } |
26 | 25 | ||
27 | fun asList(): List<String> = listOf(cmd) + opts.map { it.toCommandLineOption() } + args | 26 | fun asList(): List<String> = listOf(cmd) + opts.map { it.toCommandLineOption() } + args |
28 | |||
29 | fun asArray(): Array<String> = this.asList().toTypedArray() | 27 | fun asArray(): Array<String> = this.asList().toTypedArray() |
30 | |||
31 | } | 28 | } |
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 a3b5cea..eb04f6d 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt | |||
@@ -12,7 +12,6 @@ import java.io.InputStreamReader | |||
12 | * @author pacien | 12 | * @author pacien |
13 | */ | 13 | */ |
14 | internal object Executor { | 14 | internal object Executor { |
15 | |||
16 | private const val FAILED = -1 | 15 | private const val FAILED = -1 |
17 | 16 | ||
18 | class CommandExecutionException(msg: String) : Exception(msg) | 17 | class CommandExecutionException(msg: String) : Exception(msg) |
@@ -56,5 +55,4 @@ internal object Executor { | |||
56 | 55 | ||
57 | fun runAsyncTask(r: () -> Unit) = CompletableFuture.runAsync(Runnable(r), AsyncTask.THREAD_POOL_EXECUTOR)!! | 56 | fun runAsyncTask(r: () -> Unit) = CompletableFuture.runAsync(Runnable(r), AsyncTask.THREAD_POOL_EXECUTOR)!! |
58 | fun <U> supplyAsyncTask(s: () -> U) = CompletableFuture.supplyAsync(Supplier(s), AsyncTask.THREAD_POOL_EXECUTOR)!! | 57 | fun <U> supplyAsyncTask(s: () -> U) = CompletableFuture.supplyAsync(Supplier(s), AsyncTask.THREAD_POOL_EXECUTOR)!! |
59 | |||
60 | } | 58 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt index e0cdb12..556288a 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt | |||
@@ -7,7 +7,6 @@ import org.pacien.tincapp.context.AppPaths | |||
7 | * @author pacien | 7 | * @author pacien |
8 | */ | 8 | */ |
9 | object Tinc { | 9 | object Tinc { |
10 | |||
11 | private fun newCommand(netName: String): Command = | 10 | private fun newCommand(netName: String): Command = |
12 | Command(AppPaths.tinc().absolutePath) | 11 | Command(AppPaths.tinc().absolutePath) |
13 | .withOption("config", AppPaths.confDir(netName).absolutePath) | 12 | .withOption("config", AppPaths.confDir(netName).absolutePath) |
@@ -47,5 +46,4 @@ object Tinc { | |||
47 | .withOption("config", AppPaths.confDir(netName).absolutePath) | 46 | .withOption("config", AppPaths.confDir(netName).absolutePath) |
48 | .withArguments("join", invitationUrl)) | 47 | .withArguments("join", invitationUrl)) |
49 | .thenApply<String> { it.joinToString("\n") } | 48 | .thenApply<String> { it.joinToString("\n") } |