From 957826db1e46bffcd99ee52f21101728279521b9 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 20 Aug 2018 16:52:49 +0200 Subject: Refactor start activity --- app/src/main/AndroidManifest.xml | 4 +- .../org/pacien/tincapp/activities/StartActivity.kt | 204 --------------------- .../tincapp/activities/start/ConnectionStarter.kt | 69 +++++++ .../activities/start/NetworkListFragment.kt | 84 +++++++++ .../activities/start/NetworkListLiveData.kt | 46 +++++ .../activities/start/NetworkListViewModel.kt | 28 +++ .../tincapp/activities/start/StartActivity.kt | 117 ++++++++++++ .../tincapp/activities/status/StatusActivity.kt | 2 +- .../activities/status/nodes/NodeListFragment.kt | 2 +- .../org/pacien/tincapp/service/TincVpnService.kt | 2 +- app/src/main/res/layout/fragment_list_item.xml | 28 --- app/src/main/res/layout/fragment_list_view.xml | 36 ---- .../res/layout/fragment_network_list_header.xml | 35 ---- app/src/main/res/layout/start_activity.xml | 32 ++++ app/src/main/res/layout/start_network_list.xml | 50 +++++ .../main/res/layout/start_network_list_header.xml | 24 +++ .../main/res/layout/start_network_list_item.xml | 27 +++ app/src/main/res/layout/status_node_list.xml | 2 +- app/src/main/res/layout/status_node_list_item.xml | 27 +++ app/src/main/res/menu/menu_start.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-nb-rNO/strings.xml | 2 +- app/src/main/res/values-zh-rCN/strings.xml | 4 +- app/src/main/res/values-zh-rHK/strings.xml | 4 +- app/src/main/res/values-zh-rTW/strings.xml | 4 +- app/src/main/res/values/strings.xml | 8 +- 26 files changed, 524 insertions(+), 321 deletions(-) delete mode 100644 app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt create mode 100644 app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt create mode 100644 app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt create mode 100644 app/src/main/java/org/pacien/tincapp/activities/start/NetworkListLiveData.kt create mode 100644 app/src/main/java/org/pacien/tincapp/activities/start/NetworkListViewModel.kt create mode 100644 app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt delete mode 100644 app/src/main/res/layout/fragment_list_item.xml delete mode 100644 app/src/main/res/layout/fragment_list_view.xml delete mode 100644 app/src/main/res/layout/fragment_network_list_header.xml create mode 100644 app/src/main/res/layout/start_activity.xml create mode 100644 app/src/main/res/layout/start_network_list.xml create mode 100644 app/src/main/res/layout/start_network_list_header.xml create mode 100644 app/src/main/res/layout/start_network_list_item.xml create mode 100644 app/src/main/res/layout/status_node_list_item.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 054438e..70839b7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,7 +34,7 @@ tools:ignore="GoogleAppIndexingWarning"> @@ -51,7 +51,7 @@ + android:parentActivityName=".activities.start.StartActivity"> . - */ - -package org.pacien.tincapp.activities - -import android.app.Activity -import android.content.Intent -import android.net.VpnService -import android.os.Bundle -import android.support.v4.widget.SwipeRefreshLayout -import android.support.v7.app.AlertDialog -import android.view.Menu -import android.view.MenuItem -import android.view.View -import android.widget.AdapterView -import android.widget.ArrayAdapter -import android.widget.TextView -import kotlinx.android.synthetic.main.base.* -import kotlinx.android.synthetic.main.dialog_decrypt_keys.view.* -import kotlinx.android.synthetic.main.fragment_list_view.* -import kotlinx.android.synthetic.main.fragment_network_list_header.* -import org.pacien.tincapp.R -import org.pacien.tincapp.activities.common.ProgressModal -import org.pacien.tincapp.activities.configure.ConfigureActivity -import org.pacien.tincapp.activities.status.StatusActivity -import org.pacien.tincapp.context.AppPaths -import org.pacien.tincapp.extensions.setElements -import org.pacien.tincapp.intent.Actions -import org.pacien.tincapp.intent.BroadcastMapper -import org.pacien.tincapp.service.TincVpnService -import org.pacien.tincapp.utils.TincKeyring - -/** - * @author pacien - */ -class StartActivity : BaseActivity() { - companion object { - private const val PERMISSION_REQUEST = 0 - } - - private val networkList = object : AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener { - private var networkListAdapter: ArrayAdapter? = null - - fun init() { - networkListAdapter = ArrayAdapter(this@StartActivity, R.layout.fragment_list_item) - layoutInflater.inflate(R.layout.fragment_list_view, main_content) - list_wrapper.setOnRefreshListener(this) - list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_list_header, list, false), null, false) - list.addFooterView(View(this@StartActivity), null, false) - list.adapter = networkListAdapter - list.onItemClickListener = this - } - - fun destroy() { - networkListAdapter = null - } - - override fun onRefresh() { - val networks = AppPaths.confDir().list()?.sorted() ?: emptyList() - runOnUiThread { - networkListAdapter?.setElements(networks) - setPlaceholderVisibility() - list_wrapper.isRefreshing = false - } - } - - override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { - connectionStarter.tryStart(netName = (view as TextView).text.toString(), displayStatus = true) - } - - private fun setPlaceholderVisibility() = if (networkListAdapter?.isEmpty != false) { - network_list_placeholder.text = getListPlaceholderText() - network_list_placeholder.visibility = View.VISIBLE - } else { - network_list_placeholder.visibility = View.GONE - } - - private fun getListPlaceholderText() = if (!AppPaths.storageAvailable()) { - getText(R.string.message_storage_unavailable) - } else { - getText(R.string.message_no_network_configuration_found) - } - } - - private val connectionStarter = object { - private var netName: String? = null - private var passphrase: String? = null - private var displayStatus = false - - fun displayStatus() = displayStatus - - fun tryStart(netName: String? = null, passphrase: String? = null, displayStatus: Boolean? = null) { - if (netName != null) this.netName = netName - this.passphrase = passphrase - if (displayStatus != null) this.displayStatus = displayStatus - - val permissionRequestIntent = VpnService.prepare(this@StartActivity) - if (permissionRequestIntent != null) - return startActivityForResult(permissionRequestIntent, PERMISSION_REQUEST) - - if (TincKeyring.needsPassphrase(this.netName!!) && this.passphrase == null) - return askForPassphrase() - - startVpn(this.netName!!, this.passphrase) - } - - private fun askForPassphrase() { - layoutInflater.inflate(R.layout.dialog_decrypt_keys, main_content, false).let { dialog -> - AlertDialog.Builder(this@StartActivity) - .setTitle(R.string.title_unlock_private_keys).setView(dialog) - .setPositiveButton(R.string.action_unlock) { _, _ -> tryStart(passphrase = dialog.passphrase.text.toString()) } - .setNegativeButton(R.string.action_cancel) { _, _ -> Unit } - .show() - } - } - - private fun startVpn(netName: String, passphrase: String? = null) { - connectDialog = ProgressModal.show(this@StartActivity, getString(R.string.message_starting_vpn)) - TincVpnService.connect(netName, passphrase) - } - } - - private val broadcastMapper = BroadcastMapper(mapOf( - Actions.EVENT_CONNECTED to this::onVpnStart, - Actions.EVENT_ABORTED to this::onVpnStartError)) - - private var connectDialog: AlertDialog? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - networkList.init() - - if (intent.action == Actions.ACTION_CONNECT && intent.data?.schemeSpecificPart != null) - connectionStarter.tryStart(intent.data.schemeSpecificPart, intent.data.fragment, false) - } - - override fun onCreateOptionsMenu(m: Menu): Boolean { - menuInflater.inflate(R.menu.menu_start, m) - return super.onCreateOptionsMenu(m) - } - - override fun onDestroy() { - networkList.destroy() - connectDialog?.dismiss() - super.onDestroy() - } - - override fun onStart() { - super.onStart() - networkList.onRefresh() - } - - override fun onResume() { - super.onResume() - if (TincVpnService.isConnected()) openStatusActivity(false) - broadcastMapper.register() - handleRecentCrash() - } - - override fun onPause() { - broadcastMapper.unregister() - super.onPause() - } - - override fun onActivityResult(request: Int, result: Int, data: Intent?): Unit = when (request) { - PERMISSION_REQUEST -> if (result == Activity.RESULT_OK) connectionStarter.tryStart() else Unit - else -> throw IllegalArgumentException("Result for unknown request received.") - } - - fun openConfigureActivity(@Suppress("UNUSED_PARAMETER") i: MenuItem) = - startActivity(Intent(this, ConfigureActivity::class.java)) - - private fun onVpnStart() { - connectDialog?.dismiss() - if (connectionStarter.displayStatus()) openStatusActivity() - finish() - } - - private fun onVpnStartError() { - connectDialog?.dismiss() - } - - private fun openStatusActivity(transition: Boolean = true) = - startActivity( - Intent(this, StatusActivity::class.java) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) - .apply { if (!transition) addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) }) -} diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt new file mode 100644 index 0000000..9e7e59d --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt @@ -0,0 +1,69 @@ +/* + * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon + * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.pacien.tincapp.activities.start + +import android.net.VpnService +import android.support.v7.app.AlertDialog +import kotlinx.android.synthetic.main.base.* +import kotlinx.android.synthetic.main.dialog_decrypt_keys.view.* +import org.pacien.tincapp.R +import org.pacien.tincapp.service.TincVpnService +import org.pacien.tincapp.utils.TincKeyring + +/** + * @author pacien + */ +class ConnectionStarter(private val parentActivity: StartActivity) { + private var netName: String? = null + private var passphrase: String? = null + private var displayStatus = false + + fun displayStatus() = displayStatus + + fun tryStart(netName: String? = null, passphrase: String? = null, displayStatus: Boolean? = null) { + if (netName != null) this.netName = netName + this.passphrase = passphrase + if (displayStatus != null) this.displayStatus = displayStatus + + val permissionRequestIntent = VpnService.prepare(parentActivity) + if (permissionRequestIntent != null) + return parentActivity.startActivityForResult(permissionRequestIntent, parentActivity.permissionRequestCode) + + if (TincKeyring.needsPassphrase(this.netName!!) && this.passphrase == null) + return askForPassphrase() + + startVpn(this.netName!!, this.passphrase) + } + + private fun askForPassphrase() { + val dialogView = parentActivity.layoutInflater.inflate(R.layout.dialog_decrypt_keys, parentActivity.main_content, false) + + AlertDialog.Builder(parentActivity) + .setTitle(R.string.title_unlock_private_keys) + .setView(dialogView) + .setPositiveButton(R.string.action_unlock) { _, _ -> tryStart(passphrase = dialogView.passphrase.text.toString()) } + .setNegativeButton(R.string.action_cancel) { _, _ -> Unit } + .show() + } + + private fun startVpn(netName: String, passphrase: String? = null) { + parentActivity.showConnectProgressDialog() + TincVpnService.connect(netName, passphrase) + } +} diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt new file mode 100644 index 0000000..f255f53 --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt @@ -0,0 +1,84 @@ +/* + * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon + * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.pacien.tincapp.activities.start + +import android.arch.lifecycle.Observer +import android.os.Bundle +import android.support.v4.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AdapterView +import android.widget.ArrayAdapter +import android.widget.TextView +import kotlinx.android.synthetic.main.start_network_list.* +import org.pacien.tincapp.R +import org.pacien.tincapp.context.AppPaths +import org.pacien.tincapp.extensions.hideBottomSeparator +import org.pacien.tincapp.extensions.setElements + +/** + * @author pacien + */ +class NetworkListFragment : Fragment() { + private val appPaths = AppPaths + private val networkListViewModel by lazy { NetworkListViewModel() } + private val networkListAdapter by lazy { ArrayAdapter(context, R.layout.start_network_list_item) } + var connectToNetworkAction = { _: String -> Unit } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + networkListViewModel.networkList.observe(this, Observer { updateNetworkList(it.orEmpty()) }) + } + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.start_network_list, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + val listHeaderView = layoutInflater.inflate(R.layout.start_network_list_header, start_network_list, false) + start_network_list.addHeaderView(listHeaderView, null, false) + start_network_list.hideBottomSeparator() + start_network_list.emptyView = start_network_list_placeholder + start_network_list.onItemClickListener = AdapterView.OnItemClickListener(this::onItemClick) + start_network_list.adapter = networkListAdapter + } + + @Suppress("UNUSED_PARAMETER") + private fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) = when (view) { + is TextView -> connectToNetworkAction(view.text.toString()) + else -> Unit + } + + private fun updateNetworkList(networks: List) { + networkListAdapter.setElements(networks) + if (networks.isEmpty()) updatePlaceholder() + } + + private fun updatePlaceholder() { + val placeholderTextResource = when (appPaths.storageAvailable()) { + true -> R.string.start_network_list_empty_none_found + false -> R.string.start_network_list_empty_storage_not_available + } + + start_network_list_placeholder.post { + start_network_list_placeholder_text.text = getString(placeholderTextResource) + } + } +} diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListLiveData.kt b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListLiveData.kt new file mode 100644 index 0000000..d0d39b8 --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListLiveData.kt @@ -0,0 +1,46 @@ +/* + * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon + * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.pacien.tincapp.activities.start + +import android.arch.lifecycle.LiveData +import org.pacien.tincapp.context.AppPaths +import java.util.* +import kotlin.concurrent.timer + +/** + * @author pacien + */ +class NetworkListLiveData : LiveData>() { + private val updateInterval = 2 * 1000L // in milliseconds + private val appPaths = AppPaths + private lateinit var updateTimer: Timer + + override fun onActive() { + updateTimer = timer(period = updateInterval, action = { updateNetworkList() }) + } + + override fun onInactive() { + updateTimer.apply { cancel() }.apply { purge() } + } + + private fun updateNetworkList() { + val networkList = appPaths.confDir().list()?.sorted() ?: emptyList() + postValue(networkList) + } +} diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListViewModel.kt b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListViewModel.kt new file mode 100644 index 0000000..419522d --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListViewModel.kt @@ -0,0 +1,28 @@ +/* + * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon + * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.pacien.tincapp.activities.start + +import android.arch.lifecycle.ViewModel + +/** + * @author pacien + */ +class NetworkListViewModel : ViewModel() { + val networkList by lazy { NetworkListLiveData() } +} diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt new file mode 100644 index 0000000..9cc6159 --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt @@ -0,0 +1,117 @@ +/* + * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon + * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.pacien.tincapp.activities.start + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.support.v7.app.AlertDialog +import android.view.Menu +import android.view.MenuItem +import kotlinx.android.synthetic.main.start_activity.* +import org.pacien.tincapp.R +import org.pacien.tincapp.activities.BaseActivity +import org.pacien.tincapp.activities.common.ProgressModal +import org.pacien.tincapp.activities.configure.ConfigureActivity +import org.pacien.tincapp.activities.status.StatusActivity +import org.pacien.tincapp.intent.Actions +import org.pacien.tincapp.intent.BroadcastMapper +import org.pacien.tincapp.service.TincVpnService + +/** + * @author pacien + */ +class StartActivity : BaseActivity() { + val permissionRequestCode = 0 + private val connectionStarter by lazy { ConnectionStarter(this) } + private val broadcastMapper = BroadcastMapper(mapOf( + Actions.EVENT_CONNECTED to this::onVpnStart, + Actions.EVENT_ABORTED to this::onVpnStartError + )) + + var connectDialog: AlertDialog? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.start_activity) + initNetworkListFragment() + + if (intent.action == Actions.ACTION_CONNECT && intent.data?.schemeSpecificPart != null) + connectionStarter.tryStart(intent.data.schemeSpecificPart, intent.data.fragment, false) + } + + private fun initNetworkListFragment() { + val fragment = start_activity_network_list_fragment as NetworkListFragment + fragment.connectToNetworkAction = { netName -> connectionStarter.tryStart(netName, displayStatus = true) } + } + + override fun onCreateOptionsMenu(m: Menu): Boolean { + menuInflater.inflate(R.menu.menu_start, m) + return super.onCreateOptionsMenu(m) + } + + override fun onDestroy() { + connectDialog?.dismiss() + super.onDestroy() + } + + override fun onResume() { + super.onResume() + if (TincVpnService.isConnected()) openStatusActivity(false) + broadcastMapper.register() + handleRecentCrash() + } + + override fun onPause() { + broadcastMapper.unregister() + super.onPause() + } + + override fun onActivityResult(request: Int, result: Int, data: Intent?): Unit = when (request) { + permissionRequestCode -> if (result == Activity.RESULT_OK) connectionStarter.tryStart() else Unit + else -> throw IllegalArgumentException("Result for unknown request received.") + } + + private fun onVpnStart() { + connectDialog?.dismiss() + if (connectionStarter.displayStatus()) openStatusActivity() + finish() + } + + private fun onVpnStartError() { + connectDialog?.dismiss() + } + + fun showConnectProgressDialog() { + connectDialog = ProgressModal.show(this, resources.getString(R.string.message_starting_vpn)) + } + + @Suppress("UNUSED_PARAMETER") + fun openConfigureActivity(m: MenuItem) = + startActivity(Intent(this, ConfigureActivity::class.java)) + + private fun openStatusActivity(transition: Boolean = true) { + val intent = Intent(this, StatusActivity::class.java) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) + .apply { if (!transition) addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) } + + startActivity(intent) + } +} diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt index 1ac0e54..6627b61 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt @@ -26,8 +26,8 @@ import android.view.MenuItem import kotlinx.android.synthetic.main.status_activity.* import org.pacien.tincapp.R import org.pacien.tincapp.activities.BaseActivity -import org.pacien.tincapp.activities.StartActivity import org.pacien.tincapp.activities.common.ProgressModal +import org.pacien.tincapp.activities.start.StartActivity import org.pacien.tincapp.activities.viewlog.ViewLogActivity import org.pacien.tincapp.intent.Actions import org.pacien.tincapp.intent.BroadcastMapper diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt index 1cfc0f5..115809e 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt @@ -47,7 +47,7 @@ class NodeListFragment : Fragment() { private val tincCtl = Tinc private val netName by lazy { vpnService.getCurrentNetName()!! } private val nodeListViewModel by lazy { ViewModelProviders.of(this).get(NodeListViewModel::class.java) } - private val nodeListAdapter by lazy { ArrayAdapter(context, R.layout.fragment_list_item) } + private val nodeListAdapter by lazy { ArrayAdapter(context, R.layout.status_node_list_item) } private val nodeListObserver by lazy { Observer> { nodeListAdapter.setElements(it) } } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt index 884229d..7176e25 100644 --- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt +++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt @@ -91,7 +91,7 @@ class TincVpnService : VpnService() { return reportError(resources.getString(R.string.message_passphrase_required)) if (!AppPaths.storageAvailable()) - return reportError(resources.getString(R.string.message_storage_unavailable)) + return reportError(resources.getString(R.string.start_network_list_empty_storage_not_available)) if (!AppPaths.confDir(netName).exists()) return reportError(resources.getString(R.string.message_no_configuration_for_network_format, netName), docTopic = "configuration") diff --git a/app/src/main/res/layout/fragment_list_item.xml b/app/src/main/res/layout/fragment_list_item.xml deleted file mode 100644 index 574dff7..0000000 --- a/app/src/main/res/layout/fragment_list_item.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - diff --git a/app/src/main/res/layout/fragment_list_view.xml b/app/src/main/res/layout/fragment_list_view.xml deleted file mode 100644 index 32dd361..0000000 --- a/app/src/main/res/layout/fragment_list_view.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_network_list_header.xml b/app/src/main/res/layout/fragment_network_list_header.xml deleted file mode 100644 index 1ce0490..0000000 --- a/app/src/main/res/layout/fragment_network_list_header.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/layout/start_activity.xml b/app/src/main/res/layout/start_activity.xml new file mode 100644 index 0000000..97283cb --- /dev/null +++ b/app/src/main/res/layout/start_activity.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/start_network_list.xml b/app/src/main/res/layout/start_network_list.xml new file mode 100644 index 0000000..02a78d1 --- /dev/null +++ b/app/src/main/res/layout/start_network_list.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/start_network_list_header.xml b/app/src/main/res/layout/start_network_list_header.xml new file mode 100644 index 0000000..5fc213a --- /dev/null +++ b/app/src/main/res/layout/start_network_list_header.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/app/src/main/res/layout/start_network_list_item.xml b/app/src/main/res/layout/start_network_list_item.xml new file mode 100644 index 0000000..dd1a842 --- /dev/null +++ b/app/src/main/res/layout/start_network_list_item.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/layout/status_node_list.xml b/app/src/main/res/layout/status_node_list.xml index d3c4831..923d20e 100644 --- a/app/src/main/res/layout/status_node_list.xml +++ b/app/src/main/res/layout/status_node_list.xml @@ -20,7 +20,7 @@ diff --git a/app/src/main/res/layout/status_node_list_item.xml b/app/src/main/res/layout/status_node_list_item.xml new file mode 100644 index 0000000..dd1a842 --- /dev/null +++ b/app/src/main/res/layout/status_node_list_item.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/menu/menu_start.xml b/app/src/main/res/menu/menu_start.xml index 9d2ba25..311c36a 100644 --- a/app/src/main/res/menu/menu_start.xml +++ b/app/src/main/res/menu/menu_start.xml @@ -21,7 +21,7 @@ + tools:context="org.pacien.tincapp.activities.start.StartActivity"> Tinc ネットワーク名 - ネットワークに接続 + ネットワークに接続 VPN 権限のリクエスト 閉じる diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 4952beb..2af33d2 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -34,7 +34,7 @@ Tinc-nettverksnavn - Koble til nettverk + Koble til nettverk Forespør VPN-tilganger Lukk diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index f9a2a7d..650e010 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -43,7 +43,7 @@ 密码(可选) 密码 - 连接到网络 + 连接到网络 请求 VPN 权限 路径信息 节点信息 @@ -82,7 +82,7 @@ 应用 加密或解密私钥 - 未找到网络配置。 + 未找到网络配置。 生成节点配置… 加入网络… 网络配置写入成功。 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 4804d29..13054fa 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -43,7 +43,7 @@ 密碼(可選) 密碼 - 連接到網絡 + 連接到網絡 請求 VPN 權限 路徑信息 節點信息 @@ -82,7 +82,7 @@ 應用 加密或解密私鑰 - 未找到網絡配置。 + 未找到網絡配置。 生成節點配置… 加入網絡… 網絡配置寫入成功。 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index a7e37d5..cbf3cca 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -43,7 +43,7 @@ 密碼(可選) 密碼 - 連線到網路 + 連線到網路 請求 VPN 許可權 路徑資訊 節點資訊 @@ -82,7 +82,7 @@ 應用 加密或解密私鑰 - 未找到網路配置。 + 未找到網路配置。 生成節點配置… 加入網路… 網路配置寫入成功。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9be3d5a..e5dc2f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -41,7 +41,6 @@ Passphrase - Connect to network Request VPN permissions Error Unable to start tinc @@ -60,14 +59,12 @@ Send e-mail Send report - No network configuration has been found. Network configuration successfully written. No network name has been provided. No configuration has been found for network \"%1$s\". Network configuration file not found at \"%1$s\". Invalid network configuration in network.conf:\n%1$s Could not decrypt private keys:\n%1$s - Storage directory is unavailable. Starting VPN… Disconnecting VPN… A passphrase is required to unlock the keyring. @@ -81,6 +78,11 @@ Could not read network interface configuration:\n%1$s Could not read tinc private keys:\n%1$s + + Connect to network + No network configuration has been found. + Storage directory is unavailable. + Path info Configuration directory -- cgit v1.2.3