aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org
diff options
context:
space:
mode:
authorpacien2017-08-05 14:30:41 +0200
committerpacien2017-08-05 14:30:41 +0200
commitb83eb6047f7ec5523b72ec45245b1bff2cab85e4 (patch)
treef7cb74bd1fc856f9063f532172fab3b3c3058435 /app/src/main/java/org
parentbcfb54fb1a8cd350d78e7dae4f634f769c8f0d87 (diff)
downloadtincapp-b83eb6047f7ec5523b72ec45245b1bff2cab85e4.tar.gz
Add missing node name field in new config generation dialog
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt11
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt4
2 files changed, 10 insertions, 5 deletions
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 d11809c..b030a85 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
@@ -33,11 +33,16 @@ class ConfigureActivity : BaseActivity() {
33 netNameField.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT) 33 netNameField.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
34 netNameField.setHint(R.string.field_net_name) 34 netNameField.setHint(R.string.field_net_name)
35 35
36 val nodeNameField = EditText(this)
37 nodeNameField.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
38 nodeNameField.setHint(R.string.field_node_name)
39
36 val dialogFrame = layoutInflater.inflate(R.layout.dialog_frame, main_content, false) as ViewGroup 40 val dialogFrame = layoutInflater.inflate(R.layout.dialog_frame, main_content, false) as ViewGroup
37 dialogFrame.addView(netNameField) 41 dialogFrame.addView(netNameField)
42 dialogFrame.addView(nodeNameField)
38 43
39 AlertDialog.Builder(this).setTitle(R.string.title_new_network).setView(dialogFrame) 44 AlertDialog.Builder(this).setTitle(R.string.title_new_network).setView(dialogFrame)
40 .setPositiveButton(R.string.action_create) { _, _ -> generateConf(netNameField.text.toString()) } 45 .setPositiveButton(R.string.action_create) { _, _ -> generateConf(netNameField.text.toString(), nodeNameField.text.toString()) }
41 .setNegativeButton(R.string.action_cancel, dismiss).show() 46 .setNegativeButton(R.string.action_cancel, dismiss).show()
42 } 47 }
43 48
@@ -65,9 +70,9 @@ class ConfigureActivity : BaseActivity() {
65 text_tinc_binary.text = AppPaths.tinc().absolutePath 70 text_tinc_binary.text = AppPaths.tinc().absolutePath
66 } 71 }
67 72
68 private fun generateConf(netName: String) = execAction( 73 private fun generateConf(netName: String, nodeName: String) = execAction(
69 R.string.message_generating_configuration, 74 R.string.message_generating_configuration,
70 Tinc.init(netName) 75 Tinc.init(netName, nodeName)
71 .thenCompose { TincApp.removeScripts(netName) }) 76 .thenCompose { TincApp.removeScripts(netName) })
72 77
73 private fun joinNetwork(netName: String, url: String) = execAction( 78 private fun joinNetwork(netName: String, url: String) = execAction(
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 120525d..0bb1da4 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
@@ -26,10 +26,10 @@ object Tinc {
26 Executor.call(newCommand(netName).withArguments("info", node)) 26 Executor.call(newCommand(netName).withArguments("info", node))
27 .thenApply<String> { it.joinToString("\n") } 27 .thenApply<String> { it.joinToString("\n") }
28 28
29 fun init(netName: String): CompletableFuture<String> = 29 fun init(netName: String, nodeName: String): CompletableFuture<String> =
30 Executor.call(Command(AppPaths.tinc().absolutePath) 30 Executor.call(Command(AppPaths.tinc().absolutePath)
31 .withOption("config", AppPaths.confDir(netName).absolutePath) 31 .withOption("config", AppPaths.confDir(netName).absolutePath)
32 .withArguments("init", netName)) 32 .withArguments("init", nodeName))
33 .thenApply<String> { it.joinToString("\n") } 33 .thenApply<String> { it.joinToString("\n") }
34 34
35 fun join(netName: String, invitationUrl: String): CompletableFuture<String> = 35 fun join(netName: String, invitationUrl: String): CompletableFuture<String> =