Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.kr328.clash.app
import android.app.Application
import android.content.Context
import com.github.kr328.clash.app.di.appModule
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.crash.di.crashModule
import com.github.kr328.clash.glue.remote.Remote
import com.github.kr328.clash.glue.util.clashDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ val appModule = module {
}

private class AppInfoProviderImpl(application: Application) : AppInfoProvider {
override val versionName: String =
checkNotNull(application.packageManager.getPackageInfo(application.packageName, 0).versionName)
override val packageName: String = application.packageName
override val buildCommit: String = BuildConfig.COMMIT
override val receiveBroadcastsPermission: String = "${packageName}.permission.RECEIVE_BROADCASTS"
Expand Down
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ allprojects {
compilerOptions {
allWarningsAsErrors = true
jvmTarget = JvmTarget.fromTarget(libs.versions.jvmTarget.get())
freeCompilerArgs.addAll("-Xcontext-sensitive-resolution")
freeCompilerArgs.addAll("-Xcontext-sensitive-resolution", "-Xexpect-actual-classes")
}
}

Expand All @@ -62,6 +62,8 @@ allprojects {
plugins.withId(rootProject.libs.plugins.android.multiplatform.get().pluginId) {
plugins.apply(libs.plugins.kotlin.multiplatform.get().pluginId)
extensions.configure<KotlinMultiplatformExtension> {
jvm()

extensions.configure<KotlinMultiplatformAndroidLibraryTarget> {
namespace = "com.github.kr328.clash.${project.name}"
compileSdk = 37
Expand All @@ -72,6 +74,9 @@ allprojects {

extensions.configure<NamedDomainObjectContainer<KotlinSourceSet>> {
commonMain.dependencies {
if (project.path != projects.common.path) {
implementation(projects.common)
}
implementation(libs.jetbrains.compose.ui)
implementation(libs.jetbrains.compose.uiTooling)
implementation(libs.jetbrains.compose.uiToolingPreview)
Expand Down
1 change: 1 addition & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ kotlin {
}
androidMain.dependencies {
implementation(libs.androidx.core)
implementation(libs.androidx.browser)
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.github.kr328.clash.common.model

actual typealias ComponentName = android.content.ComponentName
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.github.kr328.clash.common.util

import android.content.Context
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.net.toUri

fun Context.openLink(link: String) {
CustomTabsIntent.Builder().build().launchUrl(this, link.toUri())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.github.kr328.clash.common.util

actual object Log {
private const val TAG = "Tabby"

actual fun i(message: String, throwable: Throwable?) {
android.util.Log.i(TAG, message, throwable)
}

actual fun w(message: String, throwable: Throwable?) {
android.util.Log.w(TAG, message, throwable)
}

actual fun e(message: String, throwable: Throwable?) {
android.util.Log.e(TAG, message, throwable)
}

actual fun d(message: String, throwable: Throwable?) {
android.util.Log.d(TAG, message, throwable)
}

actual fun v(message: String, throwable: Throwable?) {
android.util.Log.v(TAG, message, throwable)
}

actual fun f(message: String, throwable: Throwable) {
android.util.Log.wtf(message, throwable)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.kr328.clash.common.util

import com.github.kr328.clash.common.log.Log
import kotlin.time.Duration
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.github.kr328.clash.common.di

import android.content.ComponentName
import com.github.kr328.clash.common.model.ComponentName
import kotlin.reflect.KClass
import org.koin.core.component.KoinComponent
import org.koin.core.component.get

interface AppInfoProvider {
val versionName: String
val packageName: String
val buildCommit: String
val receiveBroadcastsPermission: String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.github.kr328.clash.common.model

expect class ComponentName
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package com.github.kr328.clash.glue.util

import android.content.Context
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.net.toUri
package com.github.kr328.clash.common.util

const val MIHOMO_CORE = "https://github.com/MetaCubeX/mihomo"
const val MIHOMO_WIKI = "https://wiki.metacubex.one/"
const val TABBY_REPO = "Goooler/Tabby"
const val TABBY_GITHUB = "https://github.com/$TABBY_REPO"
const val TABBY_RELEASES_LATEST = "$TABBY_GITHUB/releases/latest"

fun Context.openLink(link: String) {
CustomTabsIntent.Builder().build().launchUrl(this, link.toUri())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.kr328.clash.common.util

expect object Log {
fun i(message: String, throwable: Throwable? = null)

fun w(message: String, throwable: Throwable? = null)

fun e(message: String, throwable: Throwable? = null)

fun d(message: String, throwable: Throwable? = null)

fun v(message: String, throwable: Throwable? = null)

fun f(message: String, throwable: Throwable)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.github.kr328.clash.common.model

actual class ComponentName
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.github.kr328.clash.common.util

actual object Log {
private const val TAG = "Tabby"

actual fun i(message: String, throwable: Throwable?) {}

actual fun w(message: String, throwable: Throwable?) {}

actual fun e(message: String, throwable: Throwable?) {}

actual fun d(message: String, throwable: Throwable?) {}

actual fun v(message: String, throwable: Throwable?) {}

actual fun f(message: String, throwable: Throwable) {}
}
2 changes: 1 addition & 1 deletion core/src/main/kotlin/com/github/kr328/clash/core/Clash.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.kr328.clash.core

import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.bridge.Bridge
import com.github.kr328.clash.core.bridge.ClashException
import com.github.kr328.clash.core.bridge.FetchCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.kr328.clash.core.bridge
import android.os.Build
import android.os.ParcelFileDescriptor
import androidx.annotation.Keep
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.application
import java.io.File
import kotlinx.coroutines.CompletableDeferred
Expand Down
1 change: 0 additions & 1 deletion glue/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ dependencies {
api(projects.common)

implementation(libs.kotlin.coroutine)
implementation(libs.androidx.browser)
implementation(libs.androidx.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.content.Intent
import android.content.IntentFilter
import com.github.kr328.clash.common.compat.registerReceiverCompat
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.getSerializableCompat
import kotlin.uuid.Uuid
import kotlinx.coroutines.flow.MutableSharedFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.app.Application
import android.content.Context
import android.content.Intent
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.mainIntent
import com.github.kr328.clash.glue.store.AppStore
import com.github.kr328.clash.glue.util.ApplicationObserver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.content.ComponentName
import android.content.Context
import android.content.ServiceConnection
import android.os.IBinder
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.intent
import com.github.kr328.clash.glue.util.unbindServiceSilent
import com.github.kr328.clash.service.RemoteService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.kr328.clash.glue.remote
import android.content.Context
import android.net.Uri
import com.github.kr328.clash.common.constants.Authorities
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.service.StatusProvider

class StatusClient(private val context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.app.Application
import android.content.Context
import android.os.Build
import android.os.Bundle
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import java.io.File
import java.util.zip.ZipFile

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.kr328.clash.glue.util

import android.os.DeadObjectException
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.glue.remote.Remote
import com.github.kr328.clash.service.remote.IClashManager
import com.github.kr328.clash.service.remote.IProfileManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.kr328.clash.service

import android.content.Context
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.Clash
import com.github.kr328.clash.core.model.ConfigurationOverride
import com.github.kr328.clash.core.model.LogMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.kr328.clash.service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.service.clash.clashRuntime
import com.github.kr328.clash.service.clash.module.AppListCacheModule
import com.github.kr328.clash.service.clash.module.CloseModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.provider.DocumentsContract.Document as D
import android.provider.DocumentsContract.Root
import android.provider.DocumentsProvider
import com.github.kr328.clash.common.R as CommonR
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.PatternFileName
import com.github.kr328.clash.service.document.Document
import com.github.kr328.clash.service.document.FileDocument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.github.kr328.clash.service

import android.content.Context
import androidx.core.net.toUri
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.Clash
import com.github.kr328.clash.core.model.FetchStatus
import com.github.kr328.clash.service.data.Imported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.content.Intent
import androidx.core.content.getSystemService
import com.github.kr328.clash.common.compat.pendingIntentFlags
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.componentName
import com.github.kr328.clash.common.util.setUUID
import com.github.kr328.clash.service.data.Imported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.github.kr328.clash.common.compat.pendingIntentFlags
import com.github.kr328.clash.common.compat.startForegroundCompat
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.id.UndefinedIds
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.mainIntent
import com.github.kr328.clash.common.util.setUUID
import com.github.kr328.clash.common.util.uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.net.ProxyInfo
import android.net.VpnService
import android.os.Build
import com.github.kr328.clash.common.compat.pendingIntentFlags
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.mainIntent
import com.github.kr328.clash.service.clash.clashRuntime
import com.github.kr328.clash.service.clash.module.AppListCacheModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.kr328.clash.service.clash

import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.Clash
import com.github.kr328.clash.service.clash.module.Module
import kotlinx.coroutines.CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.app.Service
import android.content.Intent
import android.content.pm.PackageInfo
import com.github.kr328.clash.common.compat.getInstalledPackagesCompat
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.Clash
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.channels.Channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.github.kr328.clash.service.clash.module

import android.app.Service
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log

class CloseModule(service: Service) : Module<CloseModule.RequestClose>(service) {
object RequestClose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.github.kr328.clash.service.clash.module

import android.app.Service
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.common.util.getSerializableCompat
import com.github.kr328.clash.core.Clash
import com.github.kr328.clash.service.StatusProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.content.Intent
import android.content.IntentFilter
import com.github.kr328.clash.common.compat.registerReceiverCompat
import com.github.kr328.clash.common.di.AppInfoProvider.Companion.appInfoProvider
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.net.NetworkCapabilities
import android.net.NetworkRequest
import android.os.Build
import androidx.core.content.getSystemService
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.Clash
import com.github.kr328.clash.service.util.asSocketAddressText
import java.net.InetAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.app.Service
import android.content.Intent
import android.os.PowerManager
import androidx.core.content.getSystemService
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.Log
import com.github.kr328.clash.core.Clash
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.channels.Channel
Expand Down
Loading