diff options
Diffstat (limited to 'app/src/main')
15 files changed, 356 insertions, 239 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ed9ddf0..2536db4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml | |||
@@ -55,7 +55,7 @@ | |||
55 | </activity> | 55 | </activity> |
56 | 56 | ||
57 | <activity | 57 | <activity |
58 | android:name=".activities.StatusActivity" | 58 | android:name=".activities.status.StatusActivity" |
59 | android:configChanges="orientation|screenSize"> | 59 | android:configChanges="orientation|screenSize"> |
60 | <intent-filter> | 60 | <intent-filter> |
61 | <action android:name="org.pacien.tincapp.intent.action.DISCONNECT"/> | 61 | <action android:name="org.pacien.tincapp.intent.action.DISCONNECT"/> |
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 70302e5..84adc7f 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | |||
@@ -37,6 +37,7 @@ import kotlinx.android.synthetic.main.fragment_network_list_header.* | |||
37 | import org.pacien.tincapp.R | 37 | import org.pacien.tincapp.R |
38 | import org.pacien.tincapp.activities.common.ProgressModal | 38 | import org.pacien.tincapp.activities.common.ProgressModal |
39 | import org.pacien.tincapp.activities.configure.ConfigureActivity | 39 | import org.pacien.tincapp.activities.configure.ConfigureActivity |
40 | import org.pacien.tincapp.activities.status.StatusActivity | ||
40 | import org.pacien.tincapp.context.AppPaths | 41 | import org.pacien.tincapp.context.AppPaths |
41 | import org.pacien.tincapp.extensions.Android.setElements | 42 | import org.pacien.tincapp.extensions.Android.setElements |
42 | import org.pacien.tincapp.intent.Actions | 43 | import org.pacien.tincapp.intent.Actions |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/NetworkInfoFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/status/NetworkInfoFragment.kt new file mode 100644 index 0000000..385f996 --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/status/NetworkInfoFragment.kt | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon | ||
3 | * Copyright (C) 2017-2018 Pacien TRAN-GIRARD | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 3 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | package org.pacien.tincapp.activities.status | ||
20 | |||
21 | import android.app.Fragment | ||
22 | import android.os.Bundle | ||
23 | import android.view.LayoutInflater | ||
24 | import android.view.View | ||
25 | import android.view.ViewGroup | ||
26 | import org.pacien.tincapp.databinding.StatusNetworkInfoFragmentBinding | ||
27 | import org.pacien.tincapp.service.TincVpnService | ||
28 | |||
29 | /** | ||
30 | * @author pacien | ||
31 | */ | ||
32 | class NetworkInfoFragment : Fragment() { | ||
33 | private val vpnService by lazy { TincVpnService } | ||
34 | private val netName by lazy { vpnService.getCurrentNetName() } | ||
35 | private val interfaceConfiguration by lazy { vpnService.getCurrentInterfaceCfg() } | ||
36 | private val listFormatter = VpnInterfaceConfigurationFormatter | ||
37 | |||
38 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
39 | val binding = StatusNetworkInfoFragmentBinding.inflate(inflater, container, false) | ||
40 | binding.netName = netName | ||
41 | binding.vpnInterfaceConfiguration = interfaceConfiguration | ||
42 | binding.listFormatter = listFormatter | ||
43 | return binding.root | ||
44 | } | ||
45 | } | ||
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt index 88ce222..2bf42ce 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt | |||
@@ -16,7 +16,7 @@ | |||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | package org.pacien.tincapp.activities | 19 | package org.pacien.tincapp.activities.status |
20 | 20 | ||
21 | import android.content.Intent | 21 | import android.content.Intent |
22 | import android.os.Bundle | 22 | import android.os.Bundle |
@@ -30,16 +30,17 @@ import android.widget.ArrayAdapter | |||
30 | import android.widget.TextView | 30 | import android.widget.TextView |
31 | import java8.util.concurrent.CompletableFuture | 31 | import java8.util.concurrent.CompletableFuture |
32 | import kotlinx.android.synthetic.main.base.* | 32 | import kotlinx.android.synthetic.main.base.* |
33 | import kotlinx.android.synthetic.main.dialog_node_details.view.* | ||
34 | import kotlinx.android.synthetic.main.fragment_list_view.* | 33 | import kotlinx.android.synthetic.main.fragment_list_view.* |
35 | import kotlinx.android.synthetic.main.fragment_network_status_header.* | 34 | import kotlinx.android.synthetic.main.status_activity_list_header.* |
35 | import kotlinx.android.synthetic.main.status_node_info_dialog.view.* | ||
36 | import org.pacien.tincapp.R | 36 | import org.pacien.tincapp.R |
37 | import org.pacien.tincapp.activities.BaseActivity | ||
38 | import org.pacien.tincapp.activities.StartActivity | ||
39 | import org.pacien.tincapp.activities.ViewLogActivity | ||
37 | import org.pacien.tincapp.activities.common.ProgressModal | 40 | import org.pacien.tincapp.activities.common.ProgressModal |
38 | import org.pacien.tincapp.commands.Executor | 41 | import org.pacien.tincapp.commands.Executor |
39 | import org.pacien.tincapp.commands.Tinc | 42 | import org.pacien.tincapp.commands.Tinc |
40 | import org.pacien.tincapp.data.VpnInterfaceConfiguration | ||
41 | import org.pacien.tincapp.extensions.Android.setElements | 43 | import org.pacien.tincapp.extensions.Android.setElements |
42 | import org.pacien.tincapp.extensions.Android.setText | ||
43 | import org.pacien.tincapp.intent.Actions | 44 | import org.pacien.tincapp.intent.Actions |
44 | import org.pacien.tincapp.intent.BroadcastMapper | 45 | import org.pacien.tincapp.intent.BroadcastMapper |
45 | import org.pacien.tincapp.service.TincVpnService | 46 | import org.pacien.tincapp.service.TincVpnService |
@@ -62,7 +63,7 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
62 | 63 | ||
63 | layoutInflater.inflate(R.layout.fragment_list_view, main_content) | 64 | layoutInflater.inflate(R.layout.fragment_list_view, main_content) |
64 | list_wrapper.setOnRefreshListener(this) | 65 | list_wrapper.setOnRefreshListener(this) |
65 | list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_status_header, list, false), null, false) | 66 | list.addHeaderView(layoutInflater.inflate(R.layout.status_activity_list_header, list, false), null, false) |
66 | list.addFooterView(View(this), null, false) | 67 | list.addFooterView(View(this), null, false) |
67 | list.onItemClickListener = this | 68 | list.onItemClickListener = this |
68 | list.adapter = nodeListAdapter | 69 | list.adapter = nodeListAdapter |
@@ -90,7 +91,6 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
90 | super.onStart() | 91 | super.onStart() |
91 | refreshTimer = Timer(true) | 92 | refreshTimer = Timer(true) |
92 | refreshTimer?.schedule(timerTask { updateView() }, NOW, REFRESH_RATE) | 93 | refreshTimer?.schedule(timerTask { updateView() }, NOW, REFRESH_RATE) |
93 | writeNetworkInfo(TincVpnService.getCurrentInterfaceCfg() ?: VpnInterfaceConfiguration()) | ||
94 | } | 94 | } |
95 | 95 | ||
96 | override fun onStop() { | 96 | override fun onStop() { |
@@ -135,22 +135,9 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
135 | fun openLogViewer(@Suppress("UNUSED_PARAMETER") i: MenuItem) = | 135 | fun openLogViewer(@Suppress("UNUSED_PARAMETER") i: MenuItem) = |
136 | startActivity(Intent(this, ViewLogActivity::class.java)) | 136 | startActivity(Intent(this, ViewLogActivity::class.java)) |
137 | 137 | ||
138 | private fun writeNetworkInfo(cfg: VpnInterfaceConfiguration) { | ||
139 | text_network_name.text = TincVpnService.getCurrentNetName() ?: getString(R.string.value_none) | ||
140 | text_network_ip_addresses.setText(cfg.addresses.map { it.toSlashSeparated() }) | ||
141 | text_network_routes.setText(cfg.routes.map { it.toSlashSeparated() }) | ||
142 | text_network_dns_servers.setText(cfg.dnsServers) | ||
143 | text_network_search_domains.setText(cfg.searchDomains) | ||
144 | text_network_allow_bypass.text = getString(if (cfg.allowBypass) R.string.value_yes else R.string.value_no) | ||
145 | block_network_allowed_applications.visibility = if (cfg.allowedApplications.isNotEmpty()) View.VISIBLE else View.GONE | ||
146 | text_network_allowed_applications.setText(cfg.allowedApplications) | ||
147 | block_network_disallowed_applications.visibility = if (cfg.disallowedApplications.isNotEmpty()) View.VISIBLE else View.GONE | ||
148 | text_network_disallowed_applications.setText(cfg.disallowedApplications) | ||
149 | } | ||
150 | |||
151 | private fun writeNodeList(nodeList: List<String>) { | 138 | private fun writeNodeList(nodeList: List<String>) { |
152 | nodeListAdapter?.setElements(nodeList) | 139 | nodeListAdapter?.setElements(nodeList) |
153 | node_list_placeholder.visibility = View.GONE | 140 | status_activity_node_list_placeholder.visibility = View.GONE |
154 | list_wrapper.isRefreshing = false | 141 | list_wrapper.isRefreshing = false |
155 | } | 142 | } |
156 | 143 | ||
@@ -159,13 +146,13 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
159 | } | 146 | } |
160 | 147 | ||
161 | private fun showNodeInfo(nodeName: String) { | 148 | private fun showNodeInfo(nodeName: String) { |
162 | val dialogTextView = layoutInflater.inflate(R.layout.dialog_node_details, main_content, false) | 149 | val dialogTextView = layoutInflater.inflate(R.layout.status_node_info_dialog, main_content, false) |
163 | 150 | ||
164 | runOnUiThread { | 151 | runOnUiThread { |
165 | AlertDialog.Builder(this) | 152 | AlertDialog.Builder(this) |
166 | .setTitle(R.string.t |