diff options
author | Pacien TRAN-GIRARD | 2017-07-03 15:45:50 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2017-07-03 15:45:50 +0200 |
commit | 328ad552b0b508e08072ebcd9409f6214c748a0d (patch) | |
tree | b7093ce3d6c839d5f89b8d05a42a0e8b5d42090b | |
parent | d221543bb9d6bc9b7344cc96f010a501ff35bb7f (diff) | |
download | tincapp-328ad552b0b508e08072ebcd9409f6214c748a0d.tar.gz |
Add configure activity, displaying various paths
-rw-r--r-- | app/src/main/AndroidManifest.xml | 6 | ||||
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt | 19 | ||||
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt | 31 | ||||
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | 18 | ||||
-rw-r--r-- | app/src/main/res/drawable/horizontal_line.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_build_black_24dp.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/layout/base.xml | 12 | ||||
-rw-r--r-- | app/src/main/res/layout/page_configure.xml | 81 | ||||
-rw-r--r-- | app/src/main/res/layout/page_start.xml | 18 | ||||
-rw-r--r-- | app/src/main/res/menu/menu_start.xml | 14 | ||||
-rw-r--r-- | app/src/main/res/values-ja/strings.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/values-nb-rNO/strings.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/values/colors.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 12 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 45 |
15 files changed, 215 insertions, 66 deletions
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 @@ | |||
23 | </intent-filter> | 23 | </intent-filter> |
24 | </activity> | 24 | </activity> |
25 | 25 | ||
26 | <activity | ||
27 | android:name=".activities.ConfigureActivity" | ||
28 | android:parentActivityName=".activities.StartActivity" | ||
29 | android:theme="@style/AppTheme.NoActionBar"> | ||
30 | </activity> | ||
31 | |||
26 | <service | 32 | <service |
27 | android:name="org.pacien.tincapp.service.TincVpnService" | 33 | android:name="org.pacien.tincapp.service.TincVpnService" |
28 | android:permission="android.permission.BIND_VPN_SERVICE"> | 34 | android:permission="android.permission.BIND_VPN_SERVICE"> |
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 @@ | |||
1 | package org.pacien.tincapp.activities | 1 | package org.pacien.tincapp.activities |
2 | 2 | ||
3 | import android.content.ClipData | ||
4 | import android.content.ClipboardManager | ||
5 | import android.content.Context | ||
6 | import android.content.Intent | 3 | import android.content.Intent |
7 | import android.net.Uri | 4 | import android.net.Uri |
8 | import android.os.Bundle | 5 | import android.os.Bundle |
@@ -45,18 +42,8 @@ abstract class BaseActivity : AppCompatActivity() { | |||
45 | .show() | 42 | .show() |
46 | } | 43 | } |
47 | 44 | ||
48 | protected fun openWebsite(@StringRes url: Int) { | 45 | protected fun openWebsite(@StringRes url: Int) = startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(resources.getString(url)))) |
49 | startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(resources.getString(url)))) | 46 | protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() |
50 | } | 47 | protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() |
51 | |||
52 | protected fun notify(@StringRes msg: Int) { | ||
53 | Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() | ||
54 | } | ||
55 | |||
56 | protected fun copyIntoClipboard(label: String, str: String) { | ||
57 | val c = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager | ||
58 | c.primaryClip = ClipData.newPlainText(label, str) | ||
59 | notify(R.string.message_text_copied) | ||
60 | } | ||
61 | 48 | ||
62 | } | 49 | } |
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 @@ | |||
1 | package org.pacien.tincapp.activities | ||
2 | |||
3 | import android.os.Bundle | ||
4 | import android.view.View | ||
5 | import kotlinx.android.synthetic.main.base.* | ||
6 | import kotlinx.android.synthetic.main.page_configure.* | ||
7 | import org.pacien.tincapp.R | ||
8 | import org.pacien.tincapp.context.AppPaths | ||
9 | |||
10 | /** | ||
11 | * @author pacien | ||
12 | */ | ||
13 | class ConfigureActivity : BaseActivity() { | ||
14 | |||
15 | override fun onCreate(savedInstanceState: Bundle?) { | ||
16 | super.onCreate(savedInstanceState) | ||
17 | supportActionBar!!.setDisplayHomeAsUpEnabled(true) | ||
18 | layoutInflater.inflate(R.layout.page_configure, main_content) | ||
19 | writeContent() | ||
20 | } | ||
21 | |||
22 | private fun writeContent() { | ||
23 | text_configuration_directories.text = AppPaths.Storage.values().map { AppPaths.confDir(it) }.joinToString("\n") | ||
24 | text_log_directories.text = AppPaths.Storage.values().map { AppPaths.cacheDir(it) }.joinToString("\n") | ||
25 | text_tinc_binaries.text = listOf(AppPaths.tinc(), AppPaths.tincd()).joinToString("\n") | ||
26 | } | ||
27 | |||
28 | fun generateConf(@Suppress("UNUSED_PARAMETER") v: View) = notify("Not implemented yet") | ||
29 | fun joinNetwork(@Suppress("UNUSED_PARAMETER") v: View) = notify("Not implemented yet") | ||
30 | |||
31 | } | ||
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 | |||
6 | import android.net.VpnService | 6 | import android.net.VpnService |
7 | import android.os.Bundle | 7 | import android.os.Bundle |
8 | import android.support.v7.app.AlertDialog | 8 | import android.support.v7.app.AlertDialog |
9 | import android.view.Menu | ||
10 | import android.view.MenuItem | ||
9 | import android.view.View | 11 | import android.view.View |
10 | import android.view.ViewGroup | 12 | import android.view.ViewGroup |
11 | import android.widget.EditText | 13 | import android.widget.EditText |
@@ -26,6 +28,11 @@ class StartActivity : BaseActivity() { | |||
26 | layoutInflater.inflate(R.layout.page_start, main_content) | 28 | layoutInflater.inflate(R.layout.page_start, main_content) |
27 | } | 29 | } |
28 | 30 | ||
31 | override fun onCreateOptionsMenu(m: Menu): Boolean { | ||
32 | menuInflater.inflate(R.menu.menu_start, m) | ||
33 | return super.onCreateOptionsMenu(m) | ||
34 | } | ||
35 | |||
29 | override fun onActivityResult(request: Int, result: Int, data: Intent?) { | 36 | override fun onActivityResult(request: Int, result: Int, data: Intent?) { |
30 | notify(if (result == Activity.RESULT_OK) R.string.message_vpn_permissions_granted else R.string.message_vpn_permissions_denied) | 37 | notify(if (result == Activity.RESULT_OK) R.string.message_vpn_permissions_granted else R.string.message_vpn_permissions_denied) |
31 | } | 38 | } |
@@ -45,7 +52,7 @@ class StartActivity : BaseActivity() { | |||
45 | i.setHint(R.string.field_net_name) | 52 | i.setHint(R.string.field_net_name) |
46 | 53 | ||
47 | @SuppressLint("InflateParams") | 54 | @SuppressLint("InflateParams") |
48 | val vg = layoutInflater.inflate(R.layout.dialog_frame, null) as ViewGroup | 55 | val vg = layoutInflater.inflate(R.layout.dialog_frame, main_content, false) as ViewGroup |
49 | vg.addView(i) | 56 | vg.addView(i) |
50 | 57 | ||
51 | AlertDialog.Builder(this) | 58 | AlertDialog.Builder(this) |
@@ -56,14 +63,7 @@ class StartActivity : BaseActivity() { | |||
56 | .show() | 63 | .show() |
57 | } | 64 | } |
58 | 65 | ||
59 | fun confDirDialog(@Suppress("UNUSED_PARAMETER") v: View) { | 66 | fun openConfigureActivity(@Suppress("UNUSED_PARAMETER") i: MenuItem) = startActivity(Intent(this, ConfigureActivity::class.java)) |
60 | AlertDialog.Builder(this) | ||
61 | .setTitle(R.string.title_tinc_config_dir) | ||
62 | .setMessage("Internal: " + AppPaths.confDir(AppPaths.Storage.INTERNAL) + "\n\n" + | ||
63 | "External: " + AppPaths.confDir(AppPaths.Storage.EXTERNAL)) | ||
64 | .setPositiveButton(R.string.action_close) { _, _ -> /* nop */ } | ||
65 | .show() | ||
66 | } | ||
67 | 67 | ||
68 | private fun startVpn(netName: String) { | 68 | private fun startVpn(netName: String) { |
69 | startService(Intent(this, TincVpnService::class.java).putExtra(TincVpnService.INTENT_EXTRA_NET_CONF, | 69 | 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 @@ | |||
1 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
2 | <size android:height="1dp"/> | ||
3 | <solid android:color="@color/colorPrimaryLighter"/> | ||
4 | </shape> | ||
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 @@ | |||
1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | android:width="24dp" | ||
3 | android:height="24dp" | ||
4 | android:viewportWidth="24.0" | ||
5 | android:viewportHeight="24.0"> | ||
6 | <path | ||
7 | android:fillColor="@color/textPrimary" | ||
8 | android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/> | ||
9 | </vector> | ||
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 @@ | |||
27 | </android.support.design.widget.AppBarLayout> | 27 | </android.support.design.widget.AppBarLayout> |
28 | 28 | ||
29 | <ScrollView | 29 | <ScrollView |
30 | android:id="@+id/main_content" | ||
30 | android:layout_width="match_parent" | 31 | android:layout_width="match_parent" |
31 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
32 | app:layout_behavior="@string/appbar_scrolling_view_behavior"> | 33 | app:layout_behavior="@string/appbar_scrolling_view_behavior"> |
33 | 34 | ||
34 | <FrameLayout | ||
35 | android:id="@+id/main_content" | ||
36 | android:layout_width="match_parent" | ||
37 | android:layout_height="wrap_content" | ||
38 | android:paddingBottom="@dimen/activity_vertical_margin" | ||
39 | android:paddingLeft="@dimen/activity_horizontal_margin" | ||
40 | android:paddingRight="@dimen/activity_horizontal_margin" | ||
41 | android:paddingTop="@dimen/activity_vertical_margin"> | ||
42 | |||