From eb480c2677fbbf237c1a607550f98a2267446edc Mon Sep 17 00:00:00 2001 From: vadym Date: Sat, 13 Jun 2020 02:14:45 -0700 Subject: [PATCH 01/11] 1. fixed service stop 2. created layout --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 - .../chronosx88/yggdrasil/MainActivity.kt | 59 +++++++++++-------- .../yggdrasil/YggdrasilTunService.kt | 54 ++++++++++------- app/src/main/res/drawable/pink_out_line.xml | 8 +++ .../res/drawable/toggle_widget_background.xml | 6 ++ app/src/main/res/layout/activity_main.xml | 57 ++++++++++++++---- app/src/main/res/values/colors.xml | 10 +++- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 2 +- 10 files changed, 137 insertions(+), 64 deletions(-) create mode 100644 app/src/main/res/drawable/pink_out_line.xml create mode 100644 app/src/main/res/drawable/toggle_widget_background.xml diff --git a/app/build.gradle b/app/build.gradle index 3e72e09..27b27c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ android { compileSdkVersion 29 defaultConfig { applicationId "io.github.chronosx88.yggdrasil" - minSdkVersion 21 + minSdkVersion 22 targetSdkVersion 29 versionCode 1 versionName "1.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4e5b87b..1080956 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,10 +24,8 @@ - - \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt index 49e3421..60b380a 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt @@ -4,48 +4,55 @@ import android.app.Activity import android.content.Intent import android.net.VpnService import android.os.Bundle -import android.widget.Button +import android.util.Log +import android.widget.RadioGroup import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { - private var isYggStarted = false + companion object { + private const val TAG="Yggdrasil"; + private const val VPN_REQUEST_CODE = 0x0F + } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + val connectRadioGroup = findViewById(R.id.connectRadioGroup) + connectRadioGroup.setOnCheckedChangeListener( + RadioGroup.OnCheckedChangeListener { group, checkedId -> + when (checkedId) { + R.id.disconnectButton -> stopVpn() + R.id.connectButton -> startVpn() + else -> { // Note the block + //print("x is neither 1 nor 2") + } + } + }) + } - val connectButton = findViewById