diff options
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 @@ | |||
19 | apply plugin: 'com.android.application' | 19 | apply plugin: 'com.android.application' |
20 | apply plugin: 'kotlin-android' | 20 | apply plugin: 'kotlin-android' |
21 | apply plugin: 'kotlin-android-extensions' | 21 | apply plugin: 'kotlin-android-extensions' |
22 | apply plugin: 'kotlin-kapt' | ||
22 | apply plugin: 'com.github.triplet.play' | 23 | apply plugin: 'com.github.triplet.play' |
23 | 24 | ||
24 | def keystorePropertiesFile = rootProject.file("keystore.properties") | 25 | def 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 | ||
68 | dependencies { | 73 | dependencies { |
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 @@ | |||
19 | package org.pacien.tincapp.activities | 19 | package org.pacien.tincapp.activities |
20 | 20 | ||
21 | import android.os.Bundle | 21 | import android.os.Bundle |
22 | import android.support.annotation.LayoutRes | ||
22 | import android.support.annotation.StringRes | 23 | import android.support.annotation.StringRes |
23 | import android.support.design.widget.Snackbar | 24 | import android.support.design.widget.Snackbar |
24 | import android.support.v7.app.AlertDialog | 25 | import android.support.v7.app.AlertDialog |
25 | import android.support.v7.app.AppCompatActivity | 26 | import android.support.v7.app.AppCompatActivity |
26 | import android.view.Menu | 27 | import android.view.* |
27 | import android.view.MenuItem | ||
28 | import kotlinx.android.synthetic.main.base.* | 28 | import kotlinx.android.synthetic.main.base.* |
29 | import org.pacien.tincapp.R | 29 | import org.pacien.tincapp.R |
30 | import org.pacien.tincapp.context.App | 30 | import org.pacien.tincapp.context.App |
31 | import org.pacien.tincapp.context.AppInfo | 31 | import org.pacien.tincapp.context.AppInfo |
32 | import org.pacien.tincapp.context.AppPaths | 32 | import org.pacien.tincapp.context.AppPaths |
33 | import org.pacien.tincapp.context.CrashRecorder | 33 | import org.pacien.tincapp.context.CrashRecorder |
34 | import 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 | |||
19 | package org.pacien.tincapp.activities | ||
20 | |||
21 | import android.content.Intent | ||
22 | import android.os.Bundle | ||
23 | import android.support.annotation.StringRes | ||
24 | import android.support.v7.app.AlertDialog | ||
25 | import android.view.View | ||
26 | import com.google.zxing.integration.android.IntentIntegrator | ||
27 | import com.google.zxing.integration.android.IntentResult | ||
28 | import java8.util.concurrent.CompletableFuture | ||
29 | import kotlinx.android.synthetic.main.base.* | ||
30 | import kotlinx.android.synthetic.main.dialog_encrypt_decrypt_keys.view.* | ||
31 | import kotlinx.android.synthetic.main.dialog_network_generate.view.* | ||
32 | import kotlinx.android.synthetic.main.dialog_network_join.view.* | ||
33 | import kotlinx.android.synthetic.main.page_configure.* | ||
34 | import org.pacien.tincapp.R | ||
35 | import org.pacien.tincapp.commands.Tinc | ||
36 | import org.pacien.tincapp.commands.TincApp | ||
37 | import org.pacien.tincapp.context.AppPaths | ||
38 | import org.pacien.tincapp.extensions.Java.exceptionallyAccept | ||
39 | import java.util.regex.Pattern | ||
40 | |||
41 | /** | ||
42 | * @author pacien | ||
43 | */ | ||
44 | class 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 | } | ||