aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorpacien2018-08-09 00:09:39 +0200
committerpacien2018-08-09 00:09:39 +0200
commit0a7f8f489625d90b8969f112d80059d6757d5e8d (patch)
treed256bd8fc25dbbcfa6ba900137ab752547338227 /app
parentfaad43be437d857ad35570abe334cc333a6df00e (diff)
downloadtincapp-0a7f8f489625d90b8969f112d80059d6757d5e8d.tar.gz
Refactor configuration activity
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle5
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt16
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt145
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt3
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/common/ProgressModal.kt (renamed from app/src/main/java/org/pacien/tincapp/utils/ProgressModal.kt)2
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/ConfigureActivity.kt35
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/PathInfoFragment.kt40
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/ToolsFragment.kt53
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationTool.kt64
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/EncryptDecryptPrivateKeysTool.kt49
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/GenerateConfigTool.kt51
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/JoinNetworkTool.kt83
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.kt12
-rw-r--r--app/src/main/res/layout/configure_activity.xml53
-rw-r--r--app/src/main/res/layout/configure_tools_dialog_encrypt_decrypt_keys.xml (renamed from app/src/main/res/layout/dialog_encrypt_decrypt_keys.xml)6
-rw-r--r--app/src/main/res/layout/configure_tools_dialog_network_generate.xml (renamed from app/src/main/res/layout/dialog_network_generate.xml)6
-rw-r--r--app/src/main/res/layout/configure_tools_dialog_network_join.xml78
-rw-r--r--app/src/main/res/layout/configure_tools_fragment.xml73
-rw-r--r--app/src/main/res/layout/configure_tools_path_info_fragment.xml74
-rw-r--r--app/src/main/res/layout/dialog_network_join.xml66
-rw-r--r--app/src/main/res/layout/page_configure.xml121
-rw-r--r--app/src/main/res/values-ja/strings.xml2
-rw-r--r--app/src/main/res/values-nb-rNO/strings.xml2
-rw-r--r--app/src/main/res/values-zh-rCN/strings.xml48
-rw-r--r--app/src/main/res/values-zh-rHK/strings.xml48
-rw-r--r--app/src/main/res/values-zh-rTW/strings.xml48
-rw-r--r--app/src/main/res/values/strings.xml55
29 files changed, 792 insertions, 452 deletions
diff --git a/app/build.gradle b/app/build.gradle
index ade3cba..d475102 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -19,6 +19,7 @@
19apply plugin: 'com.android.application' 19apply plugin: 'com.android.application'
20apply plugin: 'kotlin-android' 20apply plugin: 'kotlin-android'
21apply plugin: 'kotlin-android-extensions' 21apply plugin: 'kotlin-android-extensions'
22apply plugin: 'kotlin-kapt'
22apply plugin: 'com.github.triplet.play' 23apply plugin: 'com.github.triplet.play'
23 24
24def keystorePropertiesFile = rootProject.file("keystore.properties") 25def keystorePropertiesFile = rootProject.file("keystore.properties")
@@ -63,6 +64,10 @@ android {
63 path 'CMakeLists.txt' 64 path 'CMakeLists.txt'
64 } 65 }
65 } 66 }
67
68 dataBinding {
69 enabled = true
70 }
66} 71}
67 72
68dependencies { 73dependencies {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 517097e..ed9ddf0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -49,7 +49,7 @@
49 </activity> 49 </activity>
50 50
51 <activity 51 <activity
52 android:name=".activities.ConfigureActivity" 52 android:name=".activities.configure.ConfigureActivity"
53 android:configChanges="orientation|screenSize" 53 android:configChanges="orientation|screenSize"
54 android:parentActivityName=".activities.StartActivity"> 54 android:parentActivityName=".activities.StartActivity">
55 </activity> 55 </activity>
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 4dc2381..af71544 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -19,19 +19,18 @@
19package org.pacien.tincapp.activities 19package org.pacien.tincapp.activities
20 20
21import android.os.Bundle 21import android.os.Bundle
22import android.support.annotation.LayoutRes
22import android.support.annotation.StringRes 23import android.support.annotation.StringRes
23import android.support.design.widget.Snackbar 24import android.support.design.widget.Snackbar
24import android.support.v7.app.AlertDialog 25import android.support.v7.app.AlertDialog
25import android.support.v7.app.AppCompatActivity 26import android.support.v7.app.AppCompatActivity
26import android.view.Menu 27import android.view.*
27import android.view.MenuItem
28import kotlinx.android.synthetic.main.base.* 28import kotlinx.android.synthetic.main.base.*
29import org.pacien.tincapp.R 29import org.pacien.tincapp.R
30import org.pacien.tincapp.context.App 30import org.pacien.tincapp.context.App
31import org.pacien.tincapp.context.AppInfo 31import org.pacien.tincapp.context.AppInfo
32import org.pacien.tincapp.context.AppPaths 32import org.pacien.tincapp.context.AppPaths
33import org.pacien.tincapp.context.CrashRecorder 33import org.pacien.tincapp.context.CrashRecorder
34import org.pacien.tincapp.utils.ProgressModal
35 34
36/** 35/**
37 * @author pacien 36 * @author pacien
@@ -105,10 +104,13 @@ abstract class BaseActivity : AppCompatActivity() {
105 .show() 104 .show()
106 } 105 }
107 106
108 protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() 107 fun inflate(@LayoutRes layout: Int) = layoutInflater.inflate(layout, main_content, false)!!
109 protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() 108 fun inflate(inflateFunc: (LayoutInflater, ViewGroup, Boolean) -> View) = inflateFunc(layoutInflater, main_content, false)
110 protected fun showProgressDialog(@StringRes msg: Int): AlertDialog = ProgressModal.show(this, getString(msg)) 109
111 protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) 110 fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
111 fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
112
113 fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this)
112 .setTitle(R.string.title_error).setMessage(msg) 114 .setTitle(R.string.title_error).setMessage(msg)
113 .setPositiveButton(R.string.action_close) { _, _ -> Unit }.show() 115 .setPositiveButton(R.string.action_close) { _, _ -> Unit }.show()
114} 116}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
deleted file mode 100644
index 2aab304..0000000
--- a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
+++ /dev/null
@@ -1,145 +0,0 @@
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
19package org.pacien.tincapp.activities
20
21import android.content.Intent
22import android.os.Bundle
23import android.support.annotation.StringRes
24import android.support.v7.app.AlertDialog
25import android.view.View
26import com.google.zxing.integration.android.IntentIntegrator
27import com.google.zxing.integration.android.IntentResult
28import java8.util.concurrent.CompletableFuture
29import kotlinx.android.synthetic.main.base.*
30import kotlinx.android.synthetic.main.dialog_encrypt_decrypt_keys.view.*
31import kotlinx.android.synthetic.main.dialog_network_generate.view.*
32import kotlinx.android.synthetic.main.dialog_network_join.view.*
33import kotlinx.android.synthetic.main.page_configure.*
34import org.pacien.tincapp.R
35import org.pacien.tincapp.commands.Tinc
36import org.pacien.tincapp.commands.TincApp
37import org.pacien.tincapp.context.AppPaths
38import org.pacien.tincapp.extensions.Java.exceptionallyAccept
39import java.util.regex.Pattern
40
41/**
42 * @author pacien
43 */
44class ConfigureActivity : BaseActivity() {
45 companion object {
46 private val NETWORK_NAME_PATTERN = Pattern.compile("^[^\\x00/]*$")
47 }
48
49 private var joinDialog: View? = null
50
51 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
52 super.onActivityResult(requestCode, resultCode, data)
53
54 IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
55 ?.let(IntentResult::getContents)
56 ?.let(String::trim)
57 ?.let { joinDialog?.invitation_url?.setText(it) }
58 }
59
60 override fun onCreate(savedInstanceState: Bundle?) {
61 super.onCreate(savedInstanceState)
62 supportActionBar!!.setDisplayHomeAsUpEnabled(true)
63 layoutInflater.inflate(R.layout.page_configure, main_content)
64 writeContent()
65 }
66
67 fun scanCode(@Suppress("UNUSED_PARAMETER") v: View) {
68 IntentIntegrator(this).initiateScan()
69 }
70