aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt34
-rw-r--r--app/src/main/res/layout/dialog_node_details.xml3
2 files changed, 23 insertions, 14 deletions
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 8ea62cb..a7a1853 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt
@@ -113,19 +113,9 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef
113 refreshTimer?.schedule(timerTask { updateView() }, NOW) 113 refreshTimer?.schedule(timerTask { updateView() }, NOW)
114 } 114 }
115 115
116 override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { 116 override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) = when (view) {
117 val nodeName = (view as TextView).text.toString() 117 is TextView -> showNodeInfo(view.text.toString())
118 val dialogTextView = layoutInflater.inflate(R.layout.dialog_node_details, main_content, false) 118 else -> Unit
119 Tinc.info(TincVpnService.getCurrentNetName()!!, nodeName).thenAccept {
120 runOnUiThread {
121 dialogTextView.dialog_node_details.text = it
122 AlertDialog.Builder(this)
123 .setTitle(R.string.title_node_info)
124 .setView(dialogTextView)
125 .setPositiveButton(R.string.action_close) { _, _ -> Unit }
126 .show()
127 }
128 }
129 } 119 }
130 120
131 private fun onVpnShutdown() { 121 private fun onVpnShutdown() {
@@ -167,6 +157,24 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef
167 getNodeNames().thenAccept { nodeList -> runOnUiThread { writeNodeList(nodeList) } } 157 getNodeNames().thenAccept { nodeList -> runOnUiThread { writeNodeList(nodeList) } }
168 } 158 }
169 159
160 private fun showNodeInfo(nodeName: String) {
161 val dialogTextView = layoutInflater.inflate(R.layout.dialog_node_details, main_content, false)
162
163 runOnUiThread {
164 AlertDialog.Builder(this)
165 .setTitle(R.string.title_node_info)
166 .setView(dialogTextView)
167 .setPositiveButton(R.string.action_close) { _, _ -> Unit }
168 .show()
169 }
170
171 TincVpnService.getCurrentNetName()?.let { netName ->
172 Tinc.info(netName, nodeName).thenAccept { nodeInfo ->
173 runOnUiThread { dialogTextView.dialog_node_details.text = nodeInfo }
174 }
175 }
176 }
177
170 private fun updateView() = when { 178 private fun updateView() = when {
171 TincVpnService.isConnected() -> updateNodeList() 179 TincVpnService.isConnected() -> updateNodeList()
172 else -> openStartActivity() 180 else -> openStartActivity()
diff --git a/app/src/main/res/layout/dialog_node_details.xml b/app/src/main/res/layout/dialog_node_details.xml
index 5d8a5f7..75d8f4c 100644
--- a/app/src/main/res/layout/dialog_node_details.xml
+++ b/app/src/main/res/layout/dialog_node_details.xml
@@ -28,6 +28,7 @@
28 android:id="@+id/dialog_node_details" 28 android:id="@+id/dialog_node_details"
29 android:layout_width="match_parent" 29 android:layout_width="match_parent"
30 android:layout_height="wrap_content" 30 android:layout_height="wrap_content"
31 android:fontFamily="monospace"/> 31 android:fontFamily="monospace"
32 android:text="@string/message_loading"/>
32 33
33</ScrollView> 34</ScrollView>