aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/build.gradle15
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java71
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt62
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.java82
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt82
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.java67
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.kt36
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.java44
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.kt43
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.java34
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.kt20
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.java60
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt49
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.java28
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.kt25
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.java42
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.kt32
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.java75
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.kt43
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.java51
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt49
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.java81
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.kt52
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnServiceBuilderExtensions.kt45
-rw-r--r--app/src/main/java/org/pacien/tincapp/util/Function.java28
-rw-r--r--build.gradle5
26 files changed, 548 insertions, 673 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 33514ea..840289d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,5 +1,6 @@
1apply plugin: 'com.android.application' 1apply plugin: 'com.android.application'
2apply plugin: 'me.tatarka.retrolambda' 2apply plugin: 'kotlin-android'
3apply plugin: 'kotlin-android-extensions'
3 4
4android { 5android {
5 compileSdkVersion 25 6 compileSdkVersion 25
@@ -7,10 +8,9 @@ android {
7 defaultConfig { 8 defaultConfig {
8 applicationId "org.pacien.tincapp" 9 applicationId "org.pacien.tincapp"
9 minSdkVersion 21 10 minSdkVersion 21
10 targetSdkVersion 25 11 targetSdkVersion 21
11 versionCode 1 12 versionCode 1
12 versionName "0.1-preview" 13 versionName "0.1-preview"
13 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 } 14 }
15 buildTypes { 15 buildTypes {
16 release { 16 release {
@@ -18,10 +18,6 @@ android {
18 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 } 19 }
20 } 20 }
21 compileOptions {
22 sourceCompatibility JavaVersion.VERSION_1_8
23 targetCompatibility JavaVersion.VERSION_1_8
24 }
25 externalNativeBuild { 21 externalNativeBuild {
26 cmake { 22 cmake {
27 path "CMakeLists.txt" 23 path "CMakeLists.txt"
@@ -45,5 +41,8 @@ dependencies {
45 exclude group: 'commons-logging', module: 'commons-logging' 41 exclude group: 'commons-logging', module: 'commons-logging'
46 } 42 }
47 43
48 compile 'com.annimon:stream:1.1.5' 44 compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
45}
46repositories {
47 mavenCentral()
49} 48}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java
deleted file mode 100644
index 0e6cb95..0000000
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java
+++ /dev/null
@@ -1,71 +0,0 @@
1package org.pacien.tincapp.activities;
2
3import android.content.ClipData;
4import android.content.ClipboardManager;
5import android.content.Context;
6import android.content.Intent;
7import android.net.Uri;
8import android.os.Bundle;
9import android.support.annotation.StringRes;
10import android.support.design.widget.Snackbar;
11import android.support.v7.app.AlertDialog;
12import android.support.v7.app.AppCompatActivity;
13import android.support.v7.widget.Toolbar;
14import android.view.Menu;
15import android.view.MenuItem;
16import android.view.ViewGroup;
17
18import org.pacien.tincapp.BuildConfig;
19import org.pacien.tincapp.R;
20import org.pacien.tincapp.context.AppInfo;
21
22/**
23 * @author pacien
24 */
25public abstract class BaseActivity extends AppCompatActivity {
26
27 @Override
28 protected void onCreate(Bundle savedInstanceState) {
29 super.onCreate(savedInstanceState);
30 setContentView(R.layout.base);
31 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
32 setSupportActionBar(toolbar);
33 }
34
35 @Override
36 public boolean onCreateOptionsMenu(Menu m) {
37 getMenuInflater().inflate(R.menu.menu_base, m);
38 return true;
39 }
40
41 public void aboutDialog(MenuItem i) {
42 new AlertDialog.Builder(this)
43 .setTitle(BuildConfig.APPLICATION_ID)
44 .setMessage(getResources().getString(R.string.app_short_desc) + "\n\n" +
45 getResources().getString(R.string.app_copyright) + " " +
46 getResources().getString(R.string.app_license) + "\n\n" +
47 AppInfo.all(getResources()))
48 .setNeutralButton(R.string.action_open_project_website, (dialog, which) -> openWebsite(R.string.app_website_url))
49 .setPositiveButton(R.string.action_close, (dialog, which) -> { /* nop */ })
50 .show();
51 }
52
53 protected ViewGroup getContentView() {
54 return (ViewGroup) findViewById(R.id.main_content);
55 }
56
57 protected void openWebsite(@StringRes int url) {
58 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(url))));
59 }
60
61 protected void notify(@StringRes int msg) {
62 Snackbar.make(findViewById(R.id.activity_base), msg, Snackbar.LENGTH_LONG).show();
63 }
64
65 protected void copyIntoClipboard(String label, String str) {
66 ClipboardManager c = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
67 c.setPrimaryClip(ClipData.newPlainText(label, str));
68 notify(R.string.message_text_copied);
69 }
70
71}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
new file mode 100644
index 0000000..6070a0a
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -0,0 +1,62 @@
1package org.pacien.tincapp.activities
2
3import android.content.ClipData
4import android.content.ClipboardManager
5import android.content.Context
6import android.content.Intent
7import android.net.Uri
8import android.os.Bundle
9import android.support.annotation.StringRes
10import android.support.design.widget.Snackbar
11import android.support.v7.app.AlertDialog
12import android.support.v7.app.AppCompatActivity
13import android.view.Menu
14import android.view.MenuItem
15import kotlinx.android.synthetic.main.base.*
16import org.pacien.tincapp.BuildConfig
17import org.pacien.tincapp.R
18import org.pacien.tincapp.context.AppInfo
19
20/**
21 * @author pacien
22 */
23abstract class BaseActivity : AppCompatActivity() {
24
25 override fun onCreate(savedInstanceState: Bundle?) {
26 super.onCreate(savedInstanceState)
27 setContentView(R.layout.base)
28 setSupportActionBar(toolbar)
29 }
30
31 override fun onCreateOptionsMenu(m: Menu): Boolean {
32 menuInflater.inflate(R.menu.menu_base, m)
33 return true
34 }
35
36 fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) {
37 AlertDialog.Builder(this)
38 .setTitle(BuildConfig.APPLICATION_ID)
39 .setMessage(resources.getString(R.string.app_short_desc) + "\n\n" +
40 resources.getString(R.string.app_copyright) + " " +
41 resources.getString(R.string.app_license) + "\n\n" +
42 AppInfo.all(resources))
43 .setNeutralButton(R.string.action_open_project_website) { _, _ -> openWebsite(R.string.app_website_url) }
44 .setPositiveButton(R.string.action_close) { _, _ -> /* nop */ }
45 .show()
46 }
47
48 protected fun openWebsite(@StringRes url: Int) {