From d0aa037b4c60203bf160f73c3baf6d70baa9e265 Mon Sep 17 00:00:00 2001 From: Kr328 <39107975+Kr328@users.noreply.github.com> Date: Wed, 20 Nov 2019 22:48:59 +0800 Subject: [PATCH] add database --- app/build.gradle | 8 ++- .../com/github/kr328/clash/MainActivity.kt | 5 -- app/src/main/res/layout/activity_main.xml | 12 +--- core/build.gradle | 2 +- .../java/com/github/kr328/clash/core/Clash.kt | 5 +- service/build.gradle | 9 ++- .../kr328/clash/service/IClashService.aidl | 2 + .../kr328/clash/service/ClashService.kt | 62 ++++++++++++++++++- .../github/kr328/clash/service/TunService.kt | 3 +- .../kr328/clash/service/data/ClashDatabase.kt | 26 ++++++++ .../clash/service/data/ClashProfileDao.kt | 14 +++++ .../clash/service/data/ClashProfileEntity.kt | 10 +++ 12 files changed, 134 insertions(+), 24 deletions(-) create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/ClashDatabase.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/ClashProfileDao.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/ClashProfileEntity.kt diff --git a/app/build.gradle b/app/build.gradle index 341e6f0..b74b6d9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,14 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.github.kr328.clash" - minSdkVersion 23 + minSdkVersion 24 targetSdkVersion 29 versionCode 1 versionName "1.0" @@ -21,10 +22,15 @@ android { } dependencies { + kapt "androidx.room:room-compiler:$room_version" + implementation project(":core") implementation project(":service") implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "androidx.appcompat:appcompat:1.1.0" implementation "androidx.core:core-ktx:1.1.0" + implementation "androidx.lifecycle:lifecycle-livedata:2.1.0" + implementation "androidx.lifecycle:lifecycle-common-java8:2.1.0" implementation "androidx.constraintlayout:constraintlayout:1.1.3" + implementation "androidx.room:room-runtime:$room_version" } diff --git a/app/src/main/java/com/github/kr328/clash/MainActivity.kt b/app/src/main/java/com/github/kr328/clash/MainActivity.kt index 3cb1ec7..4d52150 100644 --- a/app/src/main/java/com/github/kr328/clash/MainActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/MainActivity.kt @@ -4,11 +4,6 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { - companion object { - private const val REQUEST_CODE = 233 - private const val VPN_REQUEST = 234 - } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index b1f1561..55707ad 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,13 +6,5 @@ android:layout_height="match_parent" tools:context=".MainActivity"> -