Skip to content
Merged
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
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ dependencies {

implementation(libs.androidx.core)
implementation(libs.androidx.activity.compose)

implementation(platform(libs.koin.bom))
implementation(libs.koin.android)
}

val downloadGeoFiles by
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/kotlin/com/github/kr328/clash/AppModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.kr328.clash

import android.app.Activity
import com.github.kr328.clash.util.MainActivityClassProvider
import org.koin.dsl.module

val appModule = module { single<MainActivityClassProvider> { MainActivityClassProviderImpl } }

private object MainActivityClassProviderImpl : MainActivityClassProvider {
override val mainActivityClass: Class<out Activity> = MainActivity::class.java
}
12 changes: 12 additions & 0 deletions app/src/main/kotlin/com/github/kr328/clash/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import com.github.kr328.clash.service.util.sendServiceRecreated
import com.github.kr328.clash.store.UiStore
import com.github.kr328.clash.util.clashDir
import java.io.File
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin

class MainApplication : Application() {
private val uiStore by lazy(LazyThreadSafetyMode.NONE) { UiStore(this) }
Expand All @@ -34,13 +37,22 @@ class MainApplication : Application() {
Log.d("Process $processName started")

if (processName == packageName) {
koin()
Remote.launch()
setupShortcuts()
} else {
sendServiceRecreated()
}
}

private fun koin() {
startKoin {
androidLogger()
androidContext(this@MainApplication)
modules(appModule)
}
Comment thread
Goooler marked this conversation as resolved.
}

private fun setupShortcuts() {
if (uiStore.hideAppIcon) {
// Prevent launcher activity not found.
Expand Down
3 changes: 3 additions & 0 deletions glue/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ dependencies {

implementation(libs.kotlin.coroutine)
implementation(libs.androidx.core)

implementation(platform(libs.koin.bom))
implementation(libs.koin.core)
}
12 changes: 10 additions & 2 deletions glue/src/main/kotlin/com/github/kr328/clash/util/Intent.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package com.github.kr328.clash.util

import android.app.Activity
import android.content.Context
import android.content.Intent
import org.koin.mp.KoinPlatform

fun mainIntent(context: Context, action: String? = null) =
Intent(context, Class.forName("com.github.kr328.clash.MainActivity")).setAction(action)
interface MainActivityClassProvider {
val mainActivityClass: Class<out Activity>
}

fun mainIntent(context: Context, action: String? = null): Intent {
val mainActivityClass = KoinPlatform.getKoin().get<MainActivityClassProvider>().mainActivityClass
Comment thread
Goooler marked this conversation as resolved.
return Intent(context, mainActivityClass).setAction(action)
}
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ okhttp-client = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp"
okhttp-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
bytesize = "me.saket.bytesize:bytesize:2.2.1"

koin-bom = "io.insert-koin:koin-bom:4.2.1"
koin-core = { module = "io.insert-koin:koin-core" }
koin-android = { module = "io.insert-koin:koin-android" }

composePreference = "me.zhanghai.compose.preference:preference:2.2.0"

# Dummy to get renovate updates, the version is used in rootProject build.gradle with spotless.
Expand Down