From b83eb6047f7ec5523b72ec45245b1bff2cab85e4 Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 5 Aug 2017 14:30:41 +0200 Subject: Add missing node name field in new config generation dialog --- .../java/org/pacien/tincapp/activities/ConfigureActivity.kt | 11 ++++++++--- app/src/main/java/org/pacien/tincapp/commands/Tinc.kt | 4 ++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 11 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() { netNameField.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT) netNameField.setHint(R.string.field_net_name) + val nodeNameField = EditText(this) + nodeNameField.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT) + nodeNameField.setHint(R.string.field_node_name) + val dialogFrame = layoutInflater.inflate(R.layout.dialog_frame, main_content, false) as ViewGroup dialogFrame.addView(netNameField) + dialogFrame.addView(nodeNameField) AlertDialog.Builder(this).setTitle(R.string.title_new_network).setView(dialogFrame) - .setPositiveButton(R.string.action_create) { _, _ -> generateConf(netNameField.text.toString()) } + .setPositiveButton(R.string.action_create) { _, _ -> generateConf(netNameField.text.toString(), nodeNameField.text.toString()) } .setNegativeButton(R.string.action_cancel, dismiss).show() } @@ -65,9 +70,9 @@ class ConfigureActivity : BaseActivity() { text_tinc_binary.text = AppPaths.tinc().absolutePath } - private fun generateConf(netName: String) = execAction( + private fun generateConf(netName: String, nodeName: String) = execAction( R.string.message_generating_configuration, - Tinc.init(netName) + Tinc.init(netName, nodeName) .thenCompose { TincApp.removeScripts(netName) }) 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 { Executor.call(newCommand(netName).withArguments("info", node)) .thenApply { it.joinToString("\n") } - fun init(netName: String): CompletableFuture = + fun init(netName: String, nodeName: String): CompletableFuture = Executor.call(Command(AppPaths.tinc().absolutePath) .withOption("config", AppPaths.confDir(netName).absolutePath) - .withArguments("init", netName)) + .withArguments("init", nodeName)) .thenApply { it.joinToString("\n") } fun join(netName: String, invitationUrl: String): CompletableFuture = diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1bb6192..85b5172 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,6 +15,7 @@ Disconnect Tinc network name + Name of this node Invitation URL Connect to network -- cgit v1.2.3