aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2017-05-05 01:02:16 +0200
committerPacien TRAN-GIRARD2017-05-05 01:02:16 +0200
commit2495d8032eb6839a55080b79ac818383c2f75b79 (patch)
tree6dfbab541368d10ddf1903e3ad93c44ea81080be /app/src
parent6fcd36fb73b2351a58f812532ce846414ed77117 (diff)
downloadtincapp-2495d8032eb6839a55080b79ac818383c2f75b79.tar.gz
Import unversioned prototypev0.1-preview
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/org/pacien/tincapp/.gitkeep0
-rw-r--r--app/src/main/AndroidManifest.xml35
-rw-r--r--app/src/main/c/exec.c34
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java71
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.java82
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.java67
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.java44
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.java34
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.java60
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.java28
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.java42
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.java75
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.java51
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.java81
-rw-r--r--app/src/main/java/org/pacien/tincapp/util/Function.java28
-rw-r--r--app/src/main/res/drawable/ic_help_primary_24dp.xml9
-rw-r--r--app/src/main/res/icon.pngbin0 -> 13933 bytes
-rw-r--r--app/src/main/res/icon.svg1
-rw-r--r--app/src/main/res/layout/base.xml47
-rw-r--r--app/src/main/res/layout/dialog_frame.xml11
-rw-r--r--app/src/main/res/layout/page_start.xml43
-rw-r--r--app/src/main/res/menu/menu_base.xml14
-rw-r--r--app/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 1103 bytes
-rw-r--r--app/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 777 bytes
-rw-r--r--app/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 1400 bytes
-rw-r--r--app/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 2312 bytes
-rw-r--r--app/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 3425 bytes
-rw-r--r--app/src/main/res/values-v21/styles.xml8
-rw-r--r--app/src/main/res/values-w820dp/dimens.xml3
-rw-r--r--app/src/main/res/values/colors.xml7
-rw-r--r--app/src/main/res/values/dimens.xml9
-rw-r--r--app/src/main/res/values/strings.xml33
-rw-r--r--app/src/main/res/values/styles.xml16
33 files changed, 933 insertions, 0 deletions
diff --git a/app/src/androidTest/java/org/pacien/tincapp/.gitkeep b/app/src/androidTest/java/org/pacien/tincapp/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/src/androidTest/java/org/pacien/tincapp/.gitkeep
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2822d37
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,35 @@
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="org.pacien.tincapp">
4
5 <uses-permission android:name="android.permission.INTERNET"/>
6 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
7
8 <application
9 android:allowBackup="false"
10 android:icon="@mipmap/ic_launcher"
11 android:label="@string/app_label"
12 android:supportsRtl="true"
13 android:theme="@style/AppTheme">
14
15 <activity
16 android:name=".activities.StartActivity"
17 android:label="@string/app_label"
18 android:theme="@style/AppTheme.NoActionBar">
19 <intent-filter>
20 <action android:name="android.intent.action.MAIN"/>
21 <category android:name="android.intent.category.LAUNCHER"/>
22 </intent-filter>
23 </activity>
24
25 <service
26 android:name="org.pacien.tincapp.service.TincVpnService"
27 android:permission="android.permission.BIND_VPN_SERVICE">
28 <intent-filter>
29 <action android:name="android.net.VpnService"/>
30 </intent-filter>
31 </service>
32
33 </application>
34
35</manifest>
diff --git a/app/src/main/c/exec.c b/app/src/main/c/exec.c
new file mode 100644
index 0000000..fdaec0f
--- /dev/null
+++ b/app/src/main/c/exec.c
@@ -0,0 +1,34 @@
1#include <jni.h>
2#include <unistd.h>
3#include <stdlib.h>
4
5static inline const char **to_string_array(JNIEnv *env, jobjectArray ja) {
6 const int len = (*env)->GetArrayLength(env, ja);
7 const char **ca = calloc((size_t) len + 1, sizeof(char *));
8
9 for (int i = 0; i < len; ++i) {
10 jstring jstr = (jstring) (*env)->GetObjectArrayElement(env, ja, i);
11 ca[i] = (*env)->GetStringUTFChars(env, jstr, NULL);
12 }
13
14 ca[len] = NULL;
15 return ca;
16}
17
18static inline void exec(const char **argcv) {
19 execv(argcv[0], (char *const *) argcv);
20 exit(1);
21}
22
23JNIEXPORT jint JNICALL
24Java_org_pacien_tincapp_commands_Executor_forkExec(JNIEnv *env, jclass class, jobjectArray argcv) {
25 pid_t pid = fork();
26 switch (pid) {
27 case 0:
28 exec(to_string_array(env, argcv));
29 return 0;
30
31 default:
32 return pid;
33 }
34}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java
new file mode 100644
index 0000000..0e6cb95
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java
@@ -0,0 +1,71 @@
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/StartActivity.java b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.java
new file mode 100644
index 0000000..e469fa0
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.java
@@ -0,0 +1,82 @@
1package org.pacien.tincapp.activities;
2
3import android.annotation.SuppressLint;
4import android.content.Intent;
5import android.os.Bundle;
6import android.support.v7.app.AlertDialog;
7import android.view.View;
8import android.view.ViewGroup;
9import android.widget.EditText;
10import android.widget.FrameLayout;
11
12import org.pacien.tincapp.R;
13import org.pacien.tincapp.commands.PermissionFixer;
14import org.pacien.tincapp.context.AppPaths;
15import org.pacien.tincapp.service.TincVpnService;
16
17/**
18 * @author pacien
19 */
20