add clash://install-config handler

This commit is contained in:
Kr328 committed 2019-12-10 11:14:13 +08:00
1 parent 88ef4d2f10
commit 7cc53bbf32
3 files changed
+132 -117

No files matched your search

+30 -22
View File
@@ -18,81 +18,89 @@
<activity
android:name=".MainActivity"
android:label="@string/launch_name"
android:screenOrientation="portrait"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>
</activity>
<activity
android:name=".ImportUrlActivity"
android:label="@string/clash_import_from_url"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="clash" android:host="install-config"/>
</intent-filter>
</activity>
<activity
android:name=".ProfilesActivity"
android:label="@string/clash_profiles"
android:exported="false"
android:label="@string/clash_profiles"
android:screenOrientation="portrait" />
<activity
android:name=".CreateProfileActivity"
android:label="@string/clash_new_profile"
android:exported="false"
android:label="@string/clash_new_profile"
android:screenOrientation="portrait" />
<activity
android:name=".ImportFileActivity"
android:label="@string/clash_import_from_file"
android:exported="false"
android:label="@string/clash_import_from_file"
android:screenOrientation="portrait" />
<activity
android:name=".ImportUrlActivity"
android:label="@string/clash_import_from_url"
android:screenOrientation="portrait"
android:exported="false" />
<activity
android:name=".ClashStatusActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ProxyActivity"
android:label="@string/clash_proxy_manage"
android:exported="false"
android:label="@string/clash_proxy_manage"
android:screenOrientation="portrait" />
<activity
android:name=".SettingMainActivity"
android:label="@string/application_setting_title"
android:exported="false"
android:label="@string/application_setting_title"
android:screenOrientation="portrait" />
<activity
android:name=".SettingProxyActivity"
android:label="@string/application_setting_proxy"
android:exported="false"
android:label="@string/application_setting_proxy"
android:screenOrientation="portrait" />
<activity
android:name=".SettingAccessActivity"
android:label="@string/proxy_setting_vpn_setting_access_control"
android:exported="false"
android:label="@string/proxy_setting_vpn_setting_access_control"
android:screenOrientation="portrait" />
<activity
android:name=".SettingApplicationActivity"
android:label="@string/application_setting_application"
android:exported="false"
android:label="@string/application_setting_application"
android:screenOrientation="portrait" />
<activity
android:name=".LogActivity"
android:exported="false"
android:label="@string/clash_logs"
android:exported="false"
android:screenOrientation="portrait" />
<activity android:name=".FeedbackActivity"
<activity
android:name=".FeedbackActivity"
android:exported="false"
android:label="@string/clash_feedback"
android:exported="false"
android:screenOrientation="portrait" />
<service
android:name=".ClashStartService"
android:exported="false" />
<service
android:name=".TileService"
android:label="@string/launch_name"
android:icon="@drawable/ic_logo"
android:label="@string/launch_name"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
@@ -101,8 +109,8 @@
<receiver
android:name=".BootCompleteReceiver"
android:exported="true"
android:enabled="false">
android:enabled="false"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
@@ -51,6 +51,13 @@ class ImportUrlActivity : BaseActivity() {
activity_import_url_save.setOnClickListener {
checkAndInsert()
}
if ( intent.action == Intent.ACTION_VIEW
&& intent.data?.scheme == "clash"
&& intent.data?.host == "install-config") {
(elements[1] as FormAdapter.TextType).content =
intent.data?.getQueryParameter("url") ?: ""
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+95 -95
View File
@@ -1,96 +1,96 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs += ["$buildDir/intermediates/dynamic_assets"]
jniLibs.srcDirs += ["$buildDir/intermediates/native_output"]
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation "androidx.core:core-ktx:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0"
}
afterEvaluate {
def compileArch = ["arm64-v8a", "x86_64"]
def options = new GolangBuildOptions(file("src/main/golang"), file("$buildDir/intermediates/native_output"), "23")
def ts = compileArch.stream().map { abi ->
tasks.register("golangBuildFor" + abi.replace("-", "").replace("_", ""), GolangBuildTask.class) {
setOptions options, abi
}
}.toArray()
for ( task in tasks ) {
if ( task.name.contains("JniLib") )
task.dependsOn(ts)
}
def ds = tasks.register("downloadMMDB", MMDBDowloadTask.class) {
onlyIf {
System.currentTimeMillis() - file("$buildDir/intermediates/cache/Country.tar.gz").lastModified() > 24 * 3600 * 1000L
}
output = "$buildDir/intermediates/cache/Country.tar.gz"
}
def es = tasks.register("extractMMDB", Copy.class) {
onlyIf {
file("$buildDir/intermediates/cache/Country.tar.gz").lastModified() > file("$buildDir/intermediates/dynamic_assets/Country.mmdb").lastModified()
}
from(tarTree("$buildDir/intermediates/cache/Country.tar.gz")) {
include "**/*.mmdb"
}
into "$buildDir/intermediates/cache/mmdb"
doLast {
file("$buildDir/intermediates/dynamic_assets").mkdirs()
fileTree("$buildDir/intermediates/cache/mmdb").visit { FileVisitDetails details ->
if ( details.path.endsWith("Country.mmdb") )
details.file.renameTo(file("$buildDir/intermediates/dynamic_assets/Country.mmdb"))
}
}
dependsOn ds
}
for ( task in tasks ) {
if ( task.name.contains("generate") && task.name.contains("Assets") )
task.dependsOn(es)
}
}
repositories {
mavenCentral()
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs += ["$buildDir/intermediates/dynamic_assets"]
jniLibs.srcDirs += ["$buildDir/intermediates/native_output"]
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation "androidx.core:core-ktx:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0"
}
afterEvaluate {
def compileArch = ["arm64-v8a", "x86_64"]
def options = new GolangBuildOptions(file("src/main/golang"), file("$buildDir/intermediates/native_output"), "23")
def ts = compileArch.stream().map { abi ->
tasks.register("golangBuildFor" + abi.replace("-", "").replace("_", ""), GolangBuildTask.class) {
setOptions options, abi
}
}.toArray()
for ( task in tasks ) {
if ( task.name.contains("JniLib") )
task.dependsOn(ts)
}
def ds = tasks.register("downloadMMDB", MMDBDowloadTask.class) {
onlyIf {
System.currentTimeMillis() - file("$buildDir/intermediates/cache/Country.tar.gz").lastModified() > 24 * 3600 * 1000L
}
output = "$buildDir/intermediates/cache/Country.tar.gz"
}
def es = tasks.register("extractMMDB", Copy.class) {
onlyIf {
file("$buildDir/intermediates/cache/Country.tar.gz").lastModified() > file("$buildDir/intermediates/dynamic_assets/Country.mmdb").lastModified()
}
from(tarTree("$buildDir/intermediates/cache/Country.tar.gz")) {
include "**/*.mmdb"
}
into "$buildDir/intermediates/cache/mmdb"
doLast {
file("$buildDir/intermediates/dynamic_assets").mkdirs()
fileTree("$buildDir/intermediates/cache/mmdb").visit { FileVisitDetails details ->
if ( details.path.endsWith("Country.mmdb") )
details.file.renameTo(file("$buildDir/intermediates/dynamic_assets/Country.mmdb"))
}
}
dependsOn ds
}
for ( task in tasks ) {
if ( task.name.contains("generate") && task.name.contains("Assets") )
task.dependsOn(es)
}
}
repositories {
mavenCentral()
}