diff --git a/app/build.gradle b/app/build.gradle index cd0ff9e..11ce45c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.application' +apply plugin: 'kotlinx-serialization' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' @@ -38,11 +39,13 @@ dependencies { implementation "androidx.lifecycle:lifecycle-common-java8:2.1.0" implementation 'androidx.browser:browser:1.0.0' implementation 'androidx.preference:preference:1.1.0' - implementation 'androidx.recyclerview:recyclerview:1.1.0-rc01' - implementation 'androidx.core:core-ktx:1.2.0-beta02' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.core:core-ktx:1.2.0-rc01' implementation 'androidx.fragment:fragment-ktx:1.2.0-rc02' implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3' implementation "androidx.room:room-runtime:$room_version" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0" + implementation "com.charleskorn.kaml:kaml:0.14.0" implementation "com.google.android.material:material:1.2.0-alpha02" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f662b10..c9a60a9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,11 +14,13 @@ android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> + android:name=".MainActivity" + android:label="@string/app_name"> + \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt new file mode 100644 index 0000000..316da09 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt @@ -0,0 +1,14 @@ +package com.github.kr328.clash + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.activity_profiles.* + +class ProfilesActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main_profiles) + + setSupportActionBar(activity_profiles_toolbar) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/model/ClashProfile.kt b/app/src/main/java/com/github/kr328/clash/model/ClashProfile.kt new file mode 100644 index 0000000..4cf60b5 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/model/ClashProfile.kt @@ -0,0 +1,11 @@ +package com.github.kr328.clash.model + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ClashProfile( + @SerialName("Proxy") val proxies: List, + @SerialName("Proxy Group") val proxyGroups: List, + @SerialName("Rule") val rules: List +) \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/model/ClashProxy.kt b/app/src/main/java/com/github/kr328/clash/model/ClashProxy.kt new file mode 100644 index 0000000..efdc6ab --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/model/ClashProxy.kt @@ -0,0 +1,8 @@ +package com.github.kr328.clash.model + +import kotlinx.serialization.Serializable + +@Serializable +data class ClashProxy( + private val type: String, + private val name: String) \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/model/ClashProxyGroup.kt b/app/src/main/java/com/github/kr328/clash/model/ClashProxyGroup.kt new file mode 100644 index 0000000..75bcd37 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/model/ClashProxyGroup.kt @@ -0,0 +1,9 @@ +package com.github.kr328.clash.model + +import kotlinx.serialization.Serializable + +@Serializable +data class ClashProxyGroup( + private val type: String, + private val name: String +) \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_new_profile.xml b/app/src/main/res/drawable/ic_new_profile.xml new file mode 100644 index 0000000..0258249 --- /dev/null +++ b/app/src/main/res/drawable/ic_new_profile.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_profiles.xml b/app/src/main/res/layout/activity_profiles.xml new file mode 100644 index 0000000..f2989d4 --- /dev/null +++ b/app/src/main/res/layout/activity_profiles.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_profile.xml b/app/src/main/res/layout/adapter_profile.xml new file mode 100644 index 0000000..5bb8ccd --- /dev/null +++ b/app/src/main/res/layout/adapter_profile.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7b3b30..ca9d4a7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,20 +1,22 @@ - - Clash - - Clash Stopped - Click to start - Clash Started - %s Traffic Forwarded - - Proxy Manage - %d Proxies - - Profiles - %s Selected - Unselected - - Logs - Settings - Feedback - About - + + Clash + + Clash Stopped + Click to start + Clash Started + %s Traffic Forwarded + + Proxy Manage + %d Proxies + + Profiles + %s Selected + Unselected + + Logs + Settings + Feedback + About + + New Profile + diff --git a/build.gradle b/build.gradle index d2b47a5..dd71c44 100644 --- a/build.gradle +++ b/build.gradle @@ -1,30 +1,31 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext { - kotlin_version = '1.3.60' - room_version = '2.2.1' - } - repositories { - google() - jcenter() - - } - dependencies { - classpath 'com.android.tools.build:gradle:3.5.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext { + kotlin_version = '1.3.60' + room_version = '2.2.2' + } + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.5.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileEntity.kt b/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileEntity.kt index 78e7745..ab8eefa 100644 --- a/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileEntity.kt +++ b/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileEntity.kt @@ -9,7 +9,9 @@ data class ClashProfileEntity( @ColumnInfo(name = "url") val url: String, @ColumnInfo(name = "selected") val selected: Boolean, @ColumnInfo(name = "type") val writable: Type, - @ColumnInfo(name = "last_update") val lastUpdate: Long, + @ColumnInfo(name = "proxies") val proxies: Long, + @ColumnInfo(name = "proxy_groups") val proxyGroups: Long, + @ColumnInfo(name = "rules") val rules: Long, @ColumnInfo(name = "id") @PrimaryKey(autoGenerate = true) val id: Int = 0) { enum class Type {