aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorpacien2018-02-10 14:16:15 +0100
committerpacien2018-02-10 14:16:15 +0100
commit87ec3620d2259064831356c2f4000ae591756fd2 (patch)
tree9312da1d357fdd3790d5b80af221653696b23089 /app/src/main/java
parentd1c39ba87bb32308c2d3a7a749abffeb773541ef (diff)
downloadtincapp-87ec3620d2259064831356c2f4000ae591756fd2.tar.gz
Reformat code
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt52
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt190
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/LaunchActivity.kt118
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt100
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt212
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.kt30
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.kt48
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt70
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/TincApp.kt62
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.kt22
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/App.kt36
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.kt30
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.kt54
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt18
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/TincConfiguration.kt16
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt82
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/Android.kt20
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/ApacheConfiguration.kt8
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/Java.kt12
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/VpnServiceBuilder.kt74
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt210
-rw-r--r--app/src/main/java/org/pacien/tincapp/utils/PemUtils.kt82
22 files changed, 773 insertions, 773 deletions
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 4904a66..c092111 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -19,34 +19,34 @@ import org.pacien.tincapp.context.AppInfo
19 */ 19 */
20abstract class BaseActivity : AppCompatActivity() { 20abstract class BaseActivity : AppCompatActivity() {
21 21
22 override fun onCreate(savedInstanceState: Bundle?) { 22 override fun onCreate(savedInstanceState: Bundle?) {
23 super.onCreate(savedInstanceState) 23 super.onCreate(savedInstanceState)
24 setContentView(R.layout.base) 24 setContentView(R.layout.base)
25 setSupportActionBar(toolbar) 25 setSupportActionBar(toolbar)
26 } 26 }
27 27
28 override fun onCreateOptionsMenu(m: Menu): Boolean { 28 override fun onCreateOptionsMenu(m: Menu): Boolean {
29 menuInflater.inflate(R.menu.menu_base, m) 29 menuInflater.inflate(R.menu.menu_base, m)
30 return true 30 return true
31 } 31 }
32 32
33 fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) { 33 fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) {
34 AlertDialog.Builder(this) 34 AlertDialog.Builder(this)
35 .setTitle(BuildConfig.APPLICATION_ID) 35 .setTitle(BuildConfig.APPLICATION_ID)
36 .setMessage(resources.getString(R.string.app_short_desc) + "\n\n" + 36 .setMessage(resources.getString(R.string.app_short_desc) + "\n\n" +
37 resources.getString(R.string.app_copyright) + " " + 37 resources.getString(R.string.app_copyright) + " " +
38 resources.getString(R.string.app_license) + "\n\n" + 38 resources.getString(R.string.app_license) + "\n\n" +
39 AppInfo.all()) 39 AppInfo.all())
40 .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) } 40 .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) }
41 .setPositiveButton(R.string.action_close, App.dismissAction) 41 .setPositiveButton(R.string.action_close, App.dismissAction)
42 .show() 42 .show()
43 } 43 }
44 44
45 protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() 45 protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
46 protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() 46 protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
47 protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, false) 47 protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, false)
48 protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) 48 protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this)
49 .setTitle(R.string.title_error).setMessage(msg) 49 .setTitle(R.string.title_error).setMessage(msg)
50 .setPositiveButton(R.string.action_close, App.dismissAction).show() 50 .setPositiveButton(R.string.action_close, App.dismissAction).show()
51 51
52} 52}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
index 6c29a53..ec17c11 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
@@ -26,102 +26,102 @@ import org.pacien.tincapp.extensions.Java.exceptionallyAccept
26 */ 26 */
27class ConfigureActivity : BaseActivity() { 27class ConfigureActivity : BaseActivity() {
28 28
29 companion object { 29 companion object {
30 val REQUEST_SCAN = 0 30 val REQUEST_SCAN = 0
31 val SCAN_PROVIDER = "com.google.zxing.client.android" 31 val SCAN_PROVIDER = "com.google.zxing.client.android"
32 }
33
34 private var joinDialog: View? = null
35
36 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
37 super.onActivityResult(requestCode, resultCode, data)
38
39 if (requestCode == REQUEST_SCAN && resultCode == Activity.RESULT_OK)
40 joinDialog?.invitation_url?.setText(data!!.getStringExtra("SCAN_RESULT").trim())
41 }
42
43 override fun onCreate(savedInstanceState: Bundle?) {
44 super.onCreate(savedInstanceState)
45 supportActionBar!!.setDisplayHomeAsUpEnabled(true)
46 layoutInflater.inflate(R.layout.page_configure, main_content)
47 writeContent()
48 }
49
50 fun scanCode(@Suppress("UNUSED_PARAMETER") v: View) {
51 try {
52 startActivityForResult(Intent("$SCAN_PROVIDER.SCAN"), REQUEST_SCAN)
53 } catch (e: ActivityNotFoundException) {
54 AlertDialog.Builder(this).setTitle(R.string.action_scan_qr_code)
55 .setMessage(R.string.message_no_qr_code_scanner)
56 .setPositiveButton(R.string.action_install) { _, _ ->
57 startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$SCAN_PROVIDER")))
58 }.setNegativeButton(R.string.action_cancel, App.dismissAction).show()
32 } 59 }
33 60 }
34 private var joinDialog: View? = null 61
35 62 fun openGenerateConfDialog(@Suppress("UNUSED_PARAMETER") v: View) {
36 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 63 val genDialog = layoutInflater.inflate(R.layout.dialog_network_generate, main_content, false)
37 super.onActivityResult(requestCode, resultCode, data) 64 AlertDialog.Builder(this).setTitle(R.string.title_new_network).setView(genDialog)
38 65 .setPositiveButton(R.string.action_create) { _, _ ->
39 if (requestCode == REQUEST_SCAN && resultCode == Activity.RESULT_OK) 66 generateConf(
40 joinDialog?.invitation_url?.setText(data!!.getStringExtra("SCAN_RESULT").trim()) 67 genDialog.new_net_name.text.toString(),
41 } 68 genDialog.new_node_name.text.toString(),
42 69 genDialog.new_passphrase.text.toString())
43 override fun onCreate(savedInstanceState: Bundle?) { 70 }.setNegativeButton(R.string.action_cancel, App.dismissAction).show()
44 super.onCreate(savedInstanceState) 71 }
45 supportActionBar!!.setDisplayHomeAsUpEnabled(true) 72
46 layoutInflater.inflate(R.layout.page_configure, main_content) 73 fun openJoinNetworkDialog(@Suppress("UNUSED_PARAMETER") v: View) {
47 writeContent() 74 joinDialog = layoutInflater.inflate(R.layout.dialog_network_join, main_content, false)
48 } 75 AlertDialog.Builder(this).setTitle(R.string.title_join_network).setView(joinDialog)
49 76 .setPositiveButton(R.string.action_join) { _, _ ->
50 fun scanCode(@Suppress("UNUSED_PARAMETER") v: View) { 77 joinNetwork(
51 try { 78 joinDialog!!.net_name.text.toString(),
52 startActivityForResult(Intent("$SCAN_PROVIDER.SCAN"), REQUEST_SCAN) 79 joinDialog!!.invitation_url.text.toString(),
53 } catch (e: ActivityNotFoundException) { 80 joinDialog!!.join_passphrase.text.toString())
54 AlertDialog.Builder(this).setTitle(R.string.action_scan_qr_code) 81 }.setNegativeButton(R.string.action_cancel, App.dismissAction).show()
55 .setMessage(R.string.message_no_qr_code_scanner) 82 }
56 .setPositiveButton(R.string.action_install) { _, _ -> 83
57 startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$SCAN_PROVIDER"))) 84 fun openEncryptDecryptPrivateKeyDialog(@Suppress("UNUSED_PARAMETER") v: View) {
58 }.setNegativeButton(R.string.action_cancel, App.dismissAction).show() 85 val encryptDecryptDialog = layoutInflater.inflate(R.layout.dialog_encrypt_decrypt_keys, main_content, false)
59 } 86 AlertDialog.Builder(this).setTitle(R.string.title_private_keys_encryption).setView(encryptDecryptDialog)
60 } 87 .setPositiveButton(R.string.action_apply) { _, _ ->
61 88 encryptDecryptPrivateKeys(
62 fun openGenerateConfDialog(@Suppress("UNUSED_PARAMETER") v: View) { 89 encryptDecryptDialog!!.enc_dec_net_name.text.toString(),
63 val genDialog = layoutInflater.inflate(R.layout.dialog_network_generate, main_content, false) 90 encryptDecryptDialog.enc_dec_current_passphrase.text.toString(),
64 AlertDialog.Builder(this).setTitle(R.string.title_new_network).setView(genDialog) 91 encryptDecryptDialog.enc_dec_new_passphrase.text.toString())
65 .setPositiveButton(R.string.action_create) { _, _ -> 92 }.setNegativeButton(R.string.action_cancel, App.dismissAction).show()
66 generateConf( 93 }
67 genDialog.new_net_name.text.toString(), 94
68 genDialog.new_node_name.text.toString(), 95 private fun writeContent() {
69 genDialog.new_passphrase.text.toString())