From 328ad552b0b508e08072ebcd9409f6214c748a0d Mon Sep 17 00:00:00 2001
From: Pacien TRAN-GIRARD
Date: Mon, 3 Jul 2017 15:45:50 +0200
Subject: Add configure activity, displaying various paths
---
app/src/main/AndroidManifest.xml | 6 ++
.../org/pacien/tincapp/activities/BaseActivity.kt | 19 +----
.../pacien/tincapp/activities/ConfigureActivity.kt | 31 +++++++++
.../org/pacien/tincapp/activities/StartActivity.kt | 18 ++---
app/src/main/res/drawable/horizontal_line.xml | 4 ++
app/src/main/res/drawable/ic_build_black_24dp.xml | 9 +++
app/src/main/res/layout/base.xml | 12 +---
app/src/main/res/layout/page_configure.xml | 81 ++++++++++++++++++++++
app/src/main/res/layout/page_start.xml | 18 +----
app/src/main/res/menu/menu_start.xml | 14 ++++
app/src/main/res/values-ja/strings.xml | 4 --
app/src/main/res/values-nb-rNO/strings.xml | 4 --
app/src/main/res/values/colors.xml | 4 +-
app/src/main/res/values/strings.xml | 12 ++--
app/src/main/res/values/styles.xml | 45 ++++++++++++
15 files changed, 215 insertions(+), 66 deletions(-)
create mode 100644 app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
create mode 100644 app/src/main/res/drawable/horizontal_line.xml
create mode 100644 app/src/main/res/drawable/ic_build_black_24dp.xml
create mode 100644 app/src/main/res/layout/page_configure.xml
create mode 100644 app/src/main/res/menu/menu_start.xml
(limited to 'app')
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8321208..4866800 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -23,6 +23,12 @@
+
+
+
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
index 2146cec..274e1ba 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -1,8 +1,5 @@
package org.pacien.tincapp.activities
-import android.content.ClipData
-import android.content.ClipboardManager
-import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
@@ -45,18 +42,8 @@ abstract class BaseActivity : AppCompatActivity() {
.show()
}
- protected fun openWebsite(@StringRes url: Int) {
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(resources.getString(url))))
- }
-
- protected fun notify(@StringRes msg: Int) {
- Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
- }
-
- protected fun copyIntoClipboard(label: String, str: String) {
- val c = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
- c.primaryClip = ClipData.newPlainText(label, str)
- notify(R.string.message_text_copied)
- }
+ protected fun openWebsite(@StringRes url: Int) = startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(resources.getString(url))))
+ protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
+ protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
new file mode 100644
index 0000000..69408d8
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
@@ -0,0 +1,31 @@
+package org.pacien.tincapp.activities
+
+import android.os.Bundle
+import android.view.View
+import kotlinx.android.synthetic.main.base.*
+import kotlinx.android.synthetic.main.page_configure.*
+import org.pacien.tincapp.R
+import org.pacien.tincapp.context.AppPaths
+
+/**
+ * @author pacien
+ */
+class ConfigureActivity : BaseActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ supportActionBar!!.setDisplayHomeAsUpEnabled(true)
+ layoutInflater.inflate(R.layout.page_configure, main_content)
+ writeContent()
+ }
+
+ private fun writeContent() {
+ text_configuration_directories.text = AppPaths.Storage.values().map { AppPaths.confDir(it) }.joinToString("\n")
+ text_log_directories.text = AppPaths.Storage.values().map { AppPaths.cacheDir(it) }.joinToString("\n")
+ text_tinc_binaries.text = listOf(AppPaths.tinc(), AppPaths.tincd()).joinToString("\n")
+ }
+
+ fun generateConf(@Suppress("UNUSED_PARAMETER") v: View) = notify("Not implemented yet")
+ fun joinNetwork(@Suppress("UNUSED_PARAMETER") v: View) = notify("Not implemented yet")
+
+}
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 910b36f..709989b 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt
@@ -6,6 +6,8 @@ import android.content.Intent
import android.net.VpnService
import android.os.Bundle
import android.support.v7.app.AlertDialog
+import android.view.Menu
+import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
@@ -26,6 +28,11 @@ class StartActivity : BaseActivity() {
layoutInflater.inflate(R.layout.page_start, main_content)
}
+ override fun onCreateOptionsMenu(m: Menu): Boolean {
+ menuInflater.inflate(R.menu.menu_start, m)
+ return super.onCreateOptionsMenu(m)
+ }
+
override fun onActivityResult(request: Int, result: Int, data: Intent?) {
notify(if (result == Activity.RESULT_OK) R.string.message_vpn_permissions_granted else R.string.message_vpn_permissions_denied)
}
@@ -45,7 +52,7 @@ class StartActivity : BaseActivity() {
i.setHint(R.string.field_net_name)
@SuppressLint("InflateParams")
- val vg = layoutInflater.inflate(R.layout.dialog_frame, null) as ViewGroup
+ val vg = layoutInflater.inflate(R.layout.dialog_frame, main_content, false) as ViewGroup
vg.addView(i)
AlertDialog.Builder(this)
@@ -56,14 +63,7 @@ class StartActivity : BaseActivity() {
.show()
}
- fun confDirDialog(@Suppress("UNUSED_PARAMETER") v: View) {
- AlertDialog.Builder(this)
- .setTitle(R.string.title_tinc_config_dir)
- .setMessage("Internal: " + AppPaths.confDir(AppPaths.Storage.INTERNAL) + "\n\n" +
- "External: " + AppPaths.confDir(AppPaths.Storage.EXTERNAL))
- .setPositiveButton(R.string.action_close) { _, _ -> /* nop */ }
- .show()
- }
+ fun openConfigureActivity(@Suppress("UNUSED_PARAMETER") i: MenuItem) = startActivity(Intent(this, ConfigureActivity::class.java))
private fun startVpn(netName: String) {
startService(Intent(this, TincVpnService::class.java).putExtra(TincVpnService.INTENT_EXTRA_NET_CONF,
diff --git a/app/src/main/res/drawable/horizontal_line.xml b/app/src/main/res/drawable/horizontal_line.xml
new file mode 100644
index 0000000..76386bb
--- /dev/null
+++ b/app/src/main/res/drawable/horizontal_line.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_build_black_24dp.xml b/app/src/main/res/drawable/ic_build_black_24dp.xml
new file mode 100644
index 0000000..b099a5c
--- /dev/null
+++ b/app/src/main/res/drawable/ic_build_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/base.xml b/app/src/main/res/layout/base.xml
index 11df049..f2a8f49 100644
--- a/app/src/main/res/layout/base.xml
+++ b/app/src/main/res/layout/base.xml
@@ -27,21 +27,11 @@
-
-
-
-
diff --git a/app/src/main/res/layout/page_configure.xml b/app/src/main/res/layout/page_configure.xml
new file mode 100644
index 0000000..3ecdaa6
--- /dev/null
+++ b/app/src/main/res/layout/page_configure.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/page_start.xml b/app/src/main/res/layout/page_start.xml
index 8ead05b..d470dc0 100644
--- a/app/src/main/res/layout/page_start.xml
+++ b/app/src/main/res/layout/page_start.xml
@@ -1,6 +1,6 @@
-
-
-
-
-
-
diff --git a/app/src/main/res/menu/menu_start.xml b/app/src/main/res/menu/menu_start.xml
new file mode 100644
index 0000000..4f455d1
--- /dev/null
+++ b/app/src/main/res/menu/menu_start.xml
@@ -0,0 +1,14 @@
+
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index c27f2d1..3f7c75a 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -11,20 +11,16 @@
デバイス ABI: %1$s
このアプリについて
- 設定ディレクトリを表示
Tinc ネットワーク名
- Tinc 設定ディレクトリ
ネットワークに接続
VPN 権限のリクエスト
閉じる
- コピー
プロジェクト Web サイト
接続
- テキストをクリップボードにコピーしました。
VPN 権限を付与しました。
VPN 権限が拒否されました。
diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml
index 95f1267..be696ef 100644
--- a/app/src/main/res/values-nb-rNO/strings.xml
+++ b/app/src/main/res/values-nb-rNO/strings.xml
@@ -11,20 +11,16 @@
Enhets-binærkompabilitet: %1$s
Om
- Vis oppsettsmappe
Tinc-nettverksnavn
- Oppsettsmappe for Tinc
Koble til nettverk
Forespør VPN-tilganger
Lukk
- Kopier
Prosjektets nettside
Koble til
- Tekst kopiert til utklippstavle.
VPN-tilganger gitt.
VPN-tilganger nektet.
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 5e30dc2..cc0489b 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,5 +3,7 @@
#FFFFFFFF
#424242
#212121
- #FBC02D
+ #757575
+ #d9d9d9
+ #f9a825
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4e5faea..3bcf701 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,20 +11,24 @@
Device ABIs: %1$s
About this app
- Show configuration directory
+ Configure
Tinc network name
- Tinc config directory
Connect to network
Request VPN permissions
+ Path info
+ Tools
+ Configuration directories
+ Log directories
+ Tinc binaries
Close
- Copy
Project website
Connect
+ Generate node configuration and keys
+ Join network via invitation URL
- Text copied to clipboard.
VPN permissions granted.
VPN permissions denied.
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 6b849c8..9f0eb8e 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,4 +1,5 @@
+
+
+
+
+
+
+
+
+
+
+
--
cgit v1.2.3