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
27 changes: 1 addition & 26 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,13 @@ androidComponents {

composeCompiler { stabilityConfigurationFiles.add(layout.projectDirectory.file("stability.conf")) }

kotlin {
compilerOptions.optIn.addAll(
"androidx.compose.foundation.ExperimentalFoundationApi",
"androidx.compose.material3.ExperimentalMaterial3Api",
)
}

dependencies {
implementation(projects.core)
implementation(projects.service)
implementation(projects.common)
implementation(projects.glue)

implementation(libs.kotlin.coroutine)
implementation(libs.bytesize)

implementation(libs.androidx.core)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.ui.util)
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.viewmodel.navigation3)
implementation(libs.androidx.navigation3.runtime)
implementation(libs.androidx.navigation3.ui)

implementation(libs.composePreference)

implementation(libs.quickie.bundled)
}

val downloadGeoFiles by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.kr328.clash
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.github.kr328.clash.MainActivity.Companion.intent as mainIntent
import com.github.kr328.clash.util.mainIntent

class DialerReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Expand Down
19 changes: 8 additions & 11 deletions app/src/main/kotlin/com/github/kr328/clash/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.github.kr328.clash.common.util.unsafeLazy
import com.github.kr328.clash.common.util.uuid
import com.github.kr328.clash.crash.CrashRoute
import com.github.kr328.clash.crash.crashEntries
import com.github.kr328.clash.glue.R as GlueR
import com.github.kr328.clash.log.LogRoute
import com.github.kr328.clash.log.logsEntries
import com.github.kr328.clash.main.MainRoute
Expand Down Expand Up @@ -147,12 +148,12 @@ class MainActivity : ComponentActivity() {
}
Intents.ACTION_START_CLASH -> {
if (!Remote.broadcasts.clashRunning) startClash()
else toast(R.string.external_control_started)
else toast(GlueR.string.external_control_started)
true
}
Intents.ACTION_STOP_CLASH -> {
if (Remote.broadcasts.clashRunning) stopClash()
else toast(R.string.external_control_stopped)
else toast(GlueR.string.external_control_stopped)
true
}
else -> false
Expand All @@ -162,15 +163,15 @@ class MainActivity : ComponentActivity() {
private fun startClash() {
val vpnRequest = startClashService()
if (vpnRequest != null) {
toast(R.string.unable_to_start_vpn)
toast(GlueR.string.unable_to_start_vpn)
return
}
toast(R.string.external_control_started)
toast(GlueR.string.external_control_started)
}

private fun stopClash() {
stopClashService()
toast(R.string.external_control_stopped)
toast(GlueR.string.external_control_stopped)
}

private fun requestNotificationPermission() {
Expand Down Expand Up @@ -216,7 +217,8 @@ class MainActivity : ComponentActivity() {
"file" -> Profile.Type.File
else -> Profile.Type.Url
}
val name = uri.getQueryParameter("name") ?: application.getString(R.string.new_profile)
val name =
uri.getQueryParameter("name") ?: application.getString(GlueR.string.new_profile)
create(type, name).also { patch(it, name, url, 0) }
}
backStack.addIfNotLast(ProfilesRoute.Profiles(openPropertyUuid = uuid))
Expand All @@ -229,9 +231,4 @@ class MainActivity : ComponentActivity() {
ViewModel(application = context.applicationContext as Application) as T
}
}

companion object {
fun intent(context: Context, action: String? = null) =
Intent(context, MainActivity::class.java).setAction(action)
}
}
13 changes: 7 additions & 6 deletions app/src/main/kotlin/com/github/kr328/clash/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.core.graphics.drawable.IconCompat
import com.github.kr328.clash.common.Global
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.glue.R as GlueR
import com.github.kr328.clash.remote.Remote
import com.github.kr328.clash.service.util.sendServiceRecreated
import com.github.kr328.clash.store.UiStore
Expand Down Expand Up @@ -55,8 +56,8 @@ class MainApplication : Application() {

val toggle =
ShortcutInfoCompat.Builder(this, "toggle_clash")
.setShortLabel(getString(R.string.shortcut_toggle_short))
.setLongLabel(getString(R.string.shortcut_toggle_long))
.setShortLabel(getString(GlueR.string.shortcut_toggle_short))
.setLongLabel(getString(GlueR.string.shortcut_toggle_long))
.setIcon(icon)
.setIntent(
Intent(Intents.ACTION_TOGGLE_CLASH)
Expand All @@ -68,8 +69,8 @@ class MainApplication : Application() {

val start =
ShortcutInfoCompat.Builder(this, "start_clash")
.setShortLabel(getString(R.string.shortcut_start_short))
.setLongLabel(getString(R.string.shortcut_start_long))
.setShortLabel(getString(GlueR.string.shortcut_start_short))
.setLongLabel(getString(GlueR.string.shortcut_start_long))
.setIcon(icon)
.setIntent(
Intent(Intents.ACTION_START_CLASH)
Expand All @@ -81,8 +82,8 @@ class MainApplication : Application() {

val stop =
ShortcutInfoCompat.Builder(this, "stop_clash")
.setShortLabel(getString(R.string.shortcut_stop_short))
.setLongLabel(getString(R.string.shortcut_stop_long))
.setShortLabel(getString(GlueR.string.shortcut_stop_short))
.setLongLabel(getString(GlueR.string.shortcut_stop_long))
.setIcon(icon)
.setIntent(
Intent(Intents.ACTION_STOP_CLASH)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/github/kr328/clash/TileService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.service.quicksettings.TileService
import com.github.kr328.clash.common.compat.registerReceiverCompat
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.common.constants.Permissions
import com.github.kr328.clash.glue.R as GlueR
import com.github.kr328.clash.remote.StatusClient
import com.github.kr328.clash.util.startClashService
import com.github.kr328.clash.util.stopClashService
Expand Down Expand Up @@ -65,7 +66,7 @@ class TileService : TileService() {

tile.state = if (clashRunning) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE

tile.label = currentProfile.ifEmpty { getText(R.string.launch_name_meta) }
tile.label = currentProfile.ifEmpty { getText(GlueR.string.launch_name_meta) }

tile.icon =
Icon.createWithResource(this, com.github.kr328.clash.service.R.drawable.ic_logo_service)
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_clash_light">#1e4376</color>
<color name="color_clash_dark">#1976d2</color>
<color name="color_system_ui_overlay">#50000000</color>
<color name="color_light_background">#FFFAFAFA</color>
<color name="color_dark_background">#FF121212</color>
<color name="color_dark_surface">#FF202020</color>
<color name="color_light_clash_stopped">#FF808080</color>
<color name="color_light_control_disabled">#FFD3D3D3</color>
<color name="color_dark_control_disabled">#FF808080</color>
<color name="color_error">#FFB00020</color>
<color name="color_launcher_background">#FFFFFF</color>
<color name="ic_banner_background">#FFFFFF</color>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
4 changes: 0 additions & 4 deletions app/src/main/res/values/ic_banner_background.xml

This file was deleted.

4 changes: 0 additions & 4 deletions app/src/main/res/values/ic_launcher_background.xml

This file was deleted.

23 changes: 23 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import com.android.build.gradle.api.AndroidBasePlugin
import com.diffplug.gradle.spotless.SpotlessExtension
import kotlin.collections.addAll
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand Down Expand Up @@ -58,4 +59,26 @@ allprojects {
}
kotlinGradle { ktfmt(libs.ktfmt.get().version).googleStyle() }
}

plugins.withId(rootProject.libs.plugins.kotlin.compose.get().pluginId) {
extensions.configure<KotlinAndroidProjectExtension> {
compilerOptions.optIn.addAll(
"androidx.compose.foundation.ExperimentalFoundationApi",
"androidx.compose.material3.ExperimentalMaterial3Api",
)
}
dependencies {
"implementation"(platform(libs.androidx.compose.bom))
"implementation"(libs.androidx.compose.ui)
"implementation"(libs.androidx.compose.ui.tooling.preview)
"implementation"(libs.androidx.compose.ui.util)
"debugImplementation"(libs.androidx.compose.ui.tooling)
"implementation"(libs.androidx.compose.animation)
"implementation"(libs.androidx.compose.material3)
"implementation"(libs.androidx.lifecycle.viewmodel.compose)
"implementation"(libs.androidx.lifecycle.viewmodel.navigation3)
"implementation"(libs.androidx.navigation3.runtime)
"implementation"(libs.androidx.navigation3.ui)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import android.content.Intent
import com.github.kr328.clash.common.Global
import kotlin.reflect.KClass

val Class<*>.componentName: ComponentName
get() = ComponentName(Global.application.packageName, name)

val KClass<*>.componentName: ComponentName
get() = ComponentName(Global.application.packageName, this.java.name)

Expand Down
16 changes: 16 additions & 0 deletions glue/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
}

dependencies {
api(projects.core)
api(projects.service)
api(projects.common)

implementation(libs.composePreference)

implementation(libs.quickie.bundled)
implementation(libs.bytesize)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewWrapper
import com.github.kr328.clash.R
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.main.ui.CMFA_GITHUB
import com.github.kr328.clash.main.ui.openLink
import com.github.kr328.clash.ui.component.MihomoScaffold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.github.kr328.clash.R
import com.github.kr328.clash.crash.vm.AppCrashedViewModel
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.ui.component.MihomoScaffold
import com.github.kr328.clash.ui.theme.MihomoThemeWrapper
import com.github.kr328.clash.ui.theme.PreviewMihomo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import android.os.IInterface
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.github.kr328.clash.MainActivity.Companion.intent as mainIntent
import com.github.kr328.clash.R
import com.github.kr328.clash.common.compat.getColorCompat
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.log.Log
import com.github.kr328.clash.common.util.intent
import com.github.kr328.clash.core.model.LogMessage
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.log.util.LogcatCache
import com.github.kr328.clash.log.util.LogcatWriter
import com.github.kr328.clash.service.RemoteService
import com.github.kr328.clash.service.remote.ILogObserver
import com.github.kr328.clash.service.remote.IRemoteService
import com.github.kr328.clash.service.remote.unwrap
import com.github.kr328.clash.util.logsDir
import com.github.kr328.clash.util.mainIntent
import java.io.IOException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.github.kr328.clash.R
import com.github.kr328.clash.core.model.LogMessage
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.log.vm.LogcatViewModel
import com.github.kr328.clash.ui.component.MihomoScaffold
import com.github.kr328.clash.ui.component.ModelProgressBarDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.github.kr328.clash.R
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.log.vm.LogsViewModel
import com.github.kr328.clash.model.LogFile
import com.github.kr328.clash.ui.component.MihomoScaffold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.application
import androidx.lifecycle.viewModelScope
import com.github.kr328.clash.R
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.common.util.intent
import com.github.kr328.clash.core.model.LogMessage
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.log.LogcatService
import com.github.kr328.clash.log.util.LogcatFilter
import com.github.kr328.clash.log.util.LogcatReader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.fromHtml
import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.core.net.toUri
import com.github.kr328.clash.R
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.ui.component.MihomoScaffold
import com.github.kr328.clash.ui.theme.MihomoThemeWrapper
import com.github.kr328.clash.ui.theme.PreviewMihomo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.github.kr328.clash.R
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.main.vm.MainViewModel
import com.github.kr328.clash.ui.component.MihomoScaffold
import com.github.kr328.clash.ui.icon.BaselineApps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.application
import androidx.lifecycle.viewModelScope
import com.github.kr328.clash.R
import com.github.kr328.clash.common.log.Log
import com.github.kr328.clash.core.bridge.Bridge
import com.github.kr328.clash.core.util.trafficTotal
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.remote.Remote
import com.github.kr328.clash.util.startClashService
import com.github.kr328.clash.util.stopClashService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.kr328.clash.model
import android.content.Context
import android.content.Intent
import androidx.compose.ui.graphics.vector.ImageVector
import com.github.kr328.clash.R
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.ui.icon.BaselineAttachFile
import com.github.kr328.clash.ui.icon.BaselineCloudDownload
import com.github.kr328.clash.ui.icon.BaselineQrCodeScanner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.github.kr328.clash.R
import com.github.kr328.clash.common.util.grantPermissions
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.model.File
import com.github.kr328.clash.profile.vm.FilesViewModel
import com.github.kr328.clash.ui.component.MihomoScaffold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.core.graphics.drawable.toBitmap
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.github.kr328.clash.R
import com.github.kr328.clash.common.constants.Intents
import com.github.kr328.clash.glue.R
import com.github.kr328.clash.model.ProfileProvider
import com.github.kr328.clash.profile.vm.NewProfileViewModel
import com.github.kr328.clash.ui.component.MihomoScaffold
Expand Down
Loading