mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca85a688cc | ||
|
|
0e3ed548c9 | ||
|
|
27dc5395e0 | ||
|
|
4f05ba1ac6 | ||
|
|
1a36218c80 | ||
|
|
3125b90efe | ||
|
|
2a7425700a |
24
.github/workflows/build-unsigned.yaml
vendored
Normal file
24
.github/workflows/build-unsigned.yaml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Build Unsigned
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
BuildUnsigned:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v2
|
||||
- name: Setup Cmake & Ninja
|
||||
uses: lukka/get-cmake@latest
|
||||
- name: Build
|
||||
run: ./gradlew --no-daemon app:assembleRelease
|
||||
@@ -48,13 +48,20 @@ android {
|
||||
versionNameSuffix = ".premium"
|
||||
|
||||
if (buildFlavor == "premium") {
|
||||
val appCenterKey = rootProject.file("local.properties").inputStream()
|
||||
.use { Properties().apply { load(it) } }
|
||||
.getProperty("appcenter.key", null)
|
||||
val localFile = rootProject.file("local.properties")
|
||||
if (localFile.exists()) {
|
||||
val appCenterKey = localFile.inputStream()
|
||||
.use { Properties().apply { load(it) } }
|
||||
.getProperty("appcenter.key", null)
|
||||
|
||||
Objects.requireNonNull(appCenterKey)
|
||||
|
||||
buildConfigField("String", "APP_CENTER_KEY", "\"$appCenterKey\"")
|
||||
if (appCenterKey != null) {
|
||||
buildConfigField("String", "APP_CENTER_KEY", "\"$appCenterKey\"")
|
||||
} else {
|
||||
buildConfigField("String", "APP_CENTER_KEY", "null")
|
||||
}
|
||||
} else {
|
||||
buildConfigField("String", "APP_CENTER_KEY", "null")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +122,7 @@ dependencies {
|
||||
|
||||
implementation(kotlin("stdlib-jdk7"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
|
||||
implementation("androidx.core:core-ktx:$ktxVersion")
|
||||
implementation("androidx.core:core-ktx:$coreVersion")
|
||||
implementation("androidx.activity:activity:$activityVersion")
|
||||
implementation("androidx.appcompat:appcompat:$appcompatVersion")
|
||||
implementation("androidx.coordinatorlayout:coordinatorlayout:$coordinatorlayoutVersion")
|
||||
|
||||
@@ -114,7 +114,7 @@ abstract class BaseActivity<D : Design<*>> :
|
||||
|
||||
Remote.broadcasts.addObserver(this)
|
||||
|
||||
events.offer(Event.ActivityStart)
|
||||
events.trySend(Event.ActivityStart)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
@@ -124,7 +124,7 @@ abstract class BaseActivity<D : Design<*>> :
|
||||
|
||||
Remote.broadcasts.removeObserver(this)
|
||||
|
||||
events.offer(Event.ActivityStop)
|
||||
events.trySend(Event.ActivityStop)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -174,23 +174,23 @@ abstract class BaseActivity<D : Design<*>> :
|
||||
}
|
||||
|
||||
override fun onProfileChanged() {
|
||||
events.offer(Event.ProfileChanged)
|
||||
events.trySend(Event.ProfileChanged)
|
||||
}
|
||||
|
||||
override fun onProfileLoaded() {
|
||||
events.offer(Event.ProfileLoaded)
|
||||
events.trySend(Event.ProfileLoaded)
|
||||
}
|
||||
|
||||
override fun onServiceRecreated() {
|
||||
events.offer(Event.ServiceRecreated)
|
||||
events.trySend(Event.ServiceRecreated)
|
||||
}
|
||||
|
||||
override fun onStarted() {
|
||||
events.offer(Event.ClashStart)
|
||||
events.trySend(Event.ClashStart)
|
||||
}
|
||||
|
||||
override fun onStopped(cause: String?) {
|
||||
events.offer(Event.ClashStop)
|
||||
events.trySend(Event.ClashStop)
|
||||
|
||||
if (cause != null && activityStarted) {
|
||||
launch {
|
||||
|
||||
@@ -141,7 +141,7 @@ class FilesActivity : BaseActivity<FilesDesign>() {
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
design?.requests?.offer(FilesDesign.Request.PopStack)
|
||||
design?.requests?.trySend(FilesDesign.Request.PopStack)
|
||||
}
|
||||
|
||||
private suspend fun FilesDesign.fetch(client: FilesClient, stack: Stack<String>, root: String) {
|
||||
|
||||
@@ -97,7 +97,7 @@ class LogcatService : Service(), CoroutineScope by CoroutineScope(Dispatchers.De
|
||||
LogcatWriter(this@LogcatService).use {
|
||||
val observer = object : ILogObserver {
|
||||
override fun newItem(log: LogMessage) {
|
||||
channel.offer(log)
|
||||
channel.trySend(log)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class LogsActivity : BaseActivity<LogsDesign>() {
|
||||
deleteAllLogs()
|
||||
}
|
||||
|
||||
events.offer(Event.ActivityStart)
|
||||
events.trySend(Event.ActivityStart)
|
||||
}
|
||||
}
|
||||
is LogsDesign.Request.OpenFile -> {
|
||||
|
||||
@@ -32,4 +32,8 @@ class MainApplication : Application() {
|
||||
sendServiceRecreated()
|
||||
}
|
||||
}
|
||||
|
||||
fun finalize() {
|
||||
Global.destroy()
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class ProxyActivity : BaseActivity<ProxyDesign>() {
|
||||
}
|
||||
ProxyDesign.Request.ReloadAll -> {
|
||||
names.indices.forEach { idx ->
|
||||
design.requests.offer(ProxyDesign.Request.Reload(idx))
|
||||
design.requests.trySend(ProxyDesign.Request.Reload(idx))
|
||||
}
|
||||
}
|
||||
is ProxyDesign.Request.Reload -> {
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.github.kr328.clash.store.AppStore
|
||||
import com.github.kr328.clash.util.ApplicationObserver
|
||||
import com.github.kr328.clash.util.verifyApk
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -30,9 +29,9 @@ object Remote {
|
||||
fun launch() {
|
||||
ApplicationObserver.attach(Global.application)
|
||||
|
||||
ApplicationObserver.onVisibleChanged(visible::offer)
|
||||
ApplicationObserver.onVisibleChanged { visible.trySend(it) }
|
||||
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
Global.launch(Dispatchers.IO) {
|
||||
run()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import org.gradle.api.Project
|
||||
|
||||
const val buildVersionCode = 204002
|
||||
const val buildVersionName = "2.4.2"
|
||||
const val buildVersionCode = 204003
|
||||
const val buildVersionName = "2.4.3"
|
||||
|
||||
const val buildMinSdkVersion = 21
|
||||
const val buildTargetSdkVersion = 30
|
||||
|
||||
const val buildNdkVersion = "23.0.7123448"
|
||||
const val buildNdkVersion = "22.1.7171670"
|
||||
|
||||
val Project.buildFlavor: String
|
||||
get() {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const val activityVersion = "1.2.3"
|
||||
const val coroutineVersion = "1.4.3"
|
||||
const val coroutineVersion = "1.5.0"
|
||||
const val roomVersion = "2.3.0"
|
||||
const val ktxVersion = "1.3.2"
|
||||
const val appcompatVersion = "1.2.0"
|
||||
const val coreVersion = "1.5.0"
|
||||
const val appcompatVersion = "1.3.0"
|
||||
const val muiltprocessVersion = "1.0.0"
|
||||
const val appcenterVersion = "4.1.1"
|
||||
const val serializationVersion = "1.2.1"
|
||||
const val materialVersion = "1.3.0"
|
||||
const val coordinatorlayoutVersion = "1.1.0"
|
||||
const val recyclerviewVersion = "1.2.0"
|
||||
const val fragmentVersion = "1.3.3"
|
||||
const val fragmentVersion = "1.3.4"
|
||||
const val viewpagerVersion = "1.0.0"
|
||||
|
||||
@@ -40,7 +40,7 @@ dependencies {
|
||||
compileOnly(project(":hideapi"))
|
||||
|
||||
implementation(kotlin("stdlib-jdk7"))
|
||||
implementation("androidx.core:core-ktx:$ktxVersion")
|
||||
implementation("androidx.core:core-ktx:$coreVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.github.kr328.clash.common
|
||||
|
||||
import android.app.Application
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
object Global {
|
||||
object Global : CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
||||
val application: Application
|
||||
get() = application_
|
||||
|
||||
@@ -11,4 +14,8 @@ object Global {
|
||||
fun init(application: Application) {
|
||||
this.application_ = application
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ dependencies {
|
||||
api(project(":common"))
|
||||
|
||||
implementation(kotlin("stdlib-jdk7"))
|
||||
implementation("androidx.core:core-ktx:$ktxVersion")
|
||||
implementation("androidx.core:core-ktx:$coreVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
|
||||
}
|
||||
|
||||
Submodule core/src/main/golang/tun2socket updated: 46a71ab799...958ecb352f
@@ -218,7 +218,7 @@ object Clash {
|
||||
return Channel<LogMessage>(32).apply {
|
||||
Bridge.nativeSubscribeLogcat(object : LogcatInterface {
|
||||
override fun received(jsonPayload: String) {
|
||||
offer(Json.decodeFromString(LogMessage.serializer(), jsonPayload))
|
||||
trySend(Json.decodeFromString(LogMessage.serializer(), jsonPayload))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -80,7 +80,10 @@ data class ConfigurationOverride(
|
||||
var fakeIpFilter: List<String>? = null,
|
||||
|
||||
@SerialName("fallback-filter")
|
||||
val fallbackFilter: DnsFallbackFilter = DnsFallbackFilter()
|
||||
val fallbackFilter: DnsFallbackFilter = DnsFallbackFilter(),
|
||||
|
||||
@SerialName("nameserver-policy")
|
||||
var nameserverPolicy: Map<String, String>? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -59,7 +59,7 @@ dependencies {
|
||||
|
||||
implementation(kotlin("stdlib-jdk7"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
|
||||
implementation("androidx.core:core-ktx:$ktxVersion")
|
||||
implementation("androidx.core:core-ktx:$coreVersion")
|
||||
implementation("androidx.appcompat:appcompat:$appcompatVersion")
|
||||
implementation("androidx.activity:activity:$activityVersion")
|
||||
implementation("com.google.android.material:material:$materialVersion")
|
||||
|
||||
@@ -236,7 +236,7 @@ class OverrideSettingsDesign(
|
||||
summary = R.string.sideload_geoip_summary
|
||||
) {
|
||||
clicked {
|
||||
requests.offer(Request.EditSideloadGeoip)
|
||||
requests.trySend(Request.EditSideloadGeoip)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,6 +378,15 @@ class OverrideSettingsDesign(
|
||||
configure = dnsDependencies::add,
|
||||
)
|
||||
|
||||
editableTextMap(
|
||||
value = configuration.dns::nameserverPolicy,
|
||||
keyAdapter = TextAdapter.String,
|
||||
valueAdapter = TextAdapter.String,
|
||||
title = R.string.name_server_policy,
|
||||
placeholder = R.string.dont_modify,
|
||||
configure = dnsDependencies::add,
|
||||
)
|
||||
|
||||
dns.listener?.onChanged()
|
||||
}
|
||||
|
||||
@@ -385,6 +394,6 @@ class OverrideSettingsDesign(
|
||||
}
|
||||
|
||||
fun requestClear() {
|
||||
requests.offer(Request.ResetOverride)
|
||||
requests.trySend(Request.ResetOverride)
|
||||
}
|
||||
}
|
||||
@@ -32,48 +32,48 @@ class ProxyMenu(
|
||||
R.id.not_selectable -> {
|
||||
uiStore.proxyExcludeNotSelectable = item.isChecked
|
||||
|
||||
requests.offer(ProxyDesign.Request.ReLaunch)
|
||||
requests.trySend(ProxyDesign.Request.ReLaunch)
|
||||
}
|
||||
R.id.single -> {
|
||||
uiStore.proxySingleLine = true
|
||||
|
||||
updateConfig()
|
||||
|
||||
requests.offer(ProxyDesign.Request.ReloadAll)
|
||||
requests.trySend(ProxyDesign.Request.ReloadAll)
|
||||
}
|
||||
R.id.multiple -> {
|
||||
uiStore.proxySingleLine = false
|
||||
|
||||
updateConfig()
|
||||
|
||||
requests.offer(ProxyDesign.Request.ReloadAll)
|
||||
requests.trySend(ProxyDesign.Request.ReloadAll)
|
||||
}
|
||||
R.id.default_ -> {
|
||||
uiStore.proxySort = ProxySort.Default
|
||||
|
||||
requests.offer(ProxyDesign.Request.ReloadAll)
|
||||
requests.trySend(ProxyDesign.Request.ReloadAll)
|
||||
}
|
||||
R.id.name -> {
|
||||
uiStore.proxySort = ProxySort.Title
|
||||
|
||||
requests.offer(ProxyDesign.Request.ReloadAll)
|
||||
requests.trySend(ProxyDesign.Request.ReloadAll)
|
||||
}
|
||||
R.id.delay -> {
|
||||
uiStore.proxySort = ProxySort.Delay
|
||||
|
||||
requests.offer(ProxyDesign.Request.ReloadAll)
|
||||
requests.trySend(ProxyDesign.Request.ReloadAll)
|
||||
}
|
||||
R.id.dont_modify -> {
|
||||
requests.offer(ProxyDesign.Request.PatchMode(null))
|
||||
requests.trySend(ProxyDesign.Request.PatchMode(null))
|
||||
}
|
||||
R.id.direct_mode -> {
|
||||
requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Direct))
|
||||
requests.trySend(ProxyDesign.Request.PatchMode(TunnelState.Mode.Direct))
|
||||
}
|
||||
R.id.global_mode -> {
|
||||
requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Global))
|
||||
requests.trySend(ProxyDesign.Request.PatchMode(TunnelState.Mode.Global))
|
||||
}
|
||||
R.id.rule_mode -> {
|
||||
requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Rule))
|
||||
requests.trySend(ProxyDesign.Request.PatchMode(TunnelState.Mode.Rule))
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class AccessControlDesign(
|
||||
binding.surface = dialog.surface
|
||||
binding.mainList.applyLinearAdapter(context, adapter)
|
||||
binding.keywordView.addTextChangedListener {
|
||||
filter.offer(Unit)
|
||||
filter.trySend(Unit)
|
||||
}
|
||||
binding.closeView.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
|
||||
@@ -38,7 +38,7 @@ class ApkBrokenDesign(context: Context) : Design<ApkBrokenDesign.Request>(contex
|
||||
summary = R.string.google_play_url
|
||||
) {
|
||||
clicked {
|
||||
requests.offer(Request(context.getString(R.string.google_play_url)))
|
||||
requests.trySend(Request(context.getString(R.string.google_play_url)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class ApkBrokenDesign(context: Context) : Design<ApkBrokenDesign.Request>(contex
|
||||
summary = R.string.github_releases_url
|
||||
) {
|
||||
clicked {
|
||||
requests.offer(Request(context.getString(R.string.github_releases_url)))
|
||||
requests.trySend(Request(context.getString(R.string.github_releases_url)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class AppSettingsDesign(
|
||||
title = R.string.dark_mode
|
||||
) {
|
||||
listener = OnChangedListener {
|
||||
requests.offer(Request.ReCreateAllActivities)
|
||||
requests.trySend(Request.ReCreateAllActivities)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,38 +72,38 @@ class FilesDesign(context: Context) : Design<FilesDesign.Request>(context) {
|
||||
|
||||
private fun requestOpen(file: File) {
|
||||
if (file.isDirectory) {
|
||||
requests.offer(Request.OpenDirectory(file))
|
||||
requests.trySend(Request.OpenDirectory(file))
|
||||
} else {
|
||||
requests.offer(Request.OpenFile(file))
|
||||
requests.trySend(Request.OpenFile(file))
|
||||
}
|
||||
}
|
||||
|
||||
fun requestRename(dialog: Dialog, file: File) {
|
||||
requests.offer(Request.RenameFile(file))
|
||||
requests.trySend(Request.RenameFile(file))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestImport(dialog: Dialog, file: File) {
|
||||
requests.offer(Request.ImportFile(file))
|
||||
requests.trySend(Request.ImportFile(file))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestExport(dialog: Dialog, file: File) {
|
||||
requests.offer(Request.ExportFile(file))
|
||||
requests.trySend(Request.ExportFile(file))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestDelete(dialog: Dialog, file: File) {
|
||||
requests.offer(Request.DeleteFile(file))
|
||||
requests.trySend(Request.DeleteFile(file))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestNew() {
|
||||
requests.offer(Request.ImportFile(null))
|
||||
requests.trySend(Request.ImportFile(null))
|
||||
}
|
||||
|
||||
private fun requestMore(file: File) {
|
||||
|
||||
@@ -23,7 +23,7 @@ class LogsDesign(context: Context) : Design<LogsDesign.Request>(context) {
|
||||
private val binding = DesignLogsBinding
|
||||
.inflate(context.layoutInflater, context.root, false)
|
||||
private val adapter = LogFileAdapter(context) {
|
||||
requests.offer(Request.OpenFile(it))
|
||||
requests.trySend(Request.OpenFile(it))
|
||||
}
|
||||
|
||||
override val root: View
|
||||
|
||||
@@ -97,6 +97,6 @@ class MainDesign(context: Context) : Design<MainDesign.Request>(context) {
|
||||
}
|
||||
|
||||
fun request(request: Request) {
|
||||
requests.offer(request)
|
||||
requests.trySend(request)
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class NetworkSettingsDesign(
|
||||
summary = R.string.access_control_packages_summary,
|
||||
) {
|
||||
clicked {
|
||||
requests.offer(Request.StartAccessControlList)
|
||||
requests.trySend(Request.StartAccessControlList)
|
||||
}
|
||||
|
||||
vpnDependencies.add(this)
|
||||
|
||||
@@ -38,13 +38,13 @@ class NewProfileDesign(context: Context) : Design<NewProfileDesign.Request>(cont
|
||||
}
|
||||
|
||||
private fun requestCreate(provider: ProfileProvider) {
|
||||
requests.offer(Request.Create(provider))
|
||||
requests.trySend(Request.Create(provider))
|
||||
}
|
||||
|
||||
private fun requestDetail(provider: ProfileProvider): Boolean {
|
||||
if (provider !is ProfileProvider.External) return false
|
||||
|
||||
requests.offer(Request.OpenDetail(provider))
|
||||
requests.trySend(Request.OpenDetail(provider))
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class ProfilesDesign(context: Context) : Design<ProfilesDesign.Request>(context)
|
||||
suspend fun requestSave(profile: Profile) {
|
||||
showToast(R.string.active_unsaved_tips, ToastDuration.Long) {
|
||||
setAction(R.string.edit) {
|
||||
requests.offer(Request.Edit(profile))
|
||||
requests.trySend(Request.Edit(profile))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,37 +84,37 @@ class ProfilesDesign(context: Context) : Design<ProfilesDesign.Request>(context)
|
||||
}
|
||||
|
||||
fun requestUpdateAll() {
|
||||
requests.offer(Request.UpdateAll)
|
||||
requests.trySend(Request.UpdateAll)
|
||||
}
|
||||
|
||||
fun requestCreate() {
|
||||
requests.offer(Request.Create)
|
||||
requests.trySend(Request.Create)
|
||||
}
|
||||
|
||||
private fun requestActive(profile: Profile) {
|
||||
requests.offer(Request.Active(profile))
|
||||
requests.trySend(Request.Active(profile))
|
||||
}
|
||||
|
||||
fun requestUpdate(dialog: Dialog, profile: Profile) {
|
||||
requests.offer(Request.Update(profile))
|
||||
requests.trySend(Request.Update(profile))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestEdit(dialog: Dialog, profile: Profile) {
|
||||
requests.offer(Request.Edit(profile))
|
||||
requests.trySend(Request.Edit(profile))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestDuplicate(dialog: Dialog, profile: Profile) {
|
||||
requests.offer(Request.Duplicate(profile))
|
||||
requests.trySend(Request.Duplicate(profile))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
fun requestDelete(dialog: Dialog, profile: Profile) {
|
||||
requests.offer(Request.Delete(profile))
|
||||
requests.trySend(Request.Delete(profile))
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
@@ -142,11 +142,11 @@ class PropertiesDesign(context: Context) : Design<PropertiesDesign.Request>(cont
|
||||
}
|
||||
|
||||
fun requestCommit() {
|
||||
requests.offer(Request.Commit)
|
||||
requests.trySend(Request.Commit)
|
||||
}
|
||||
|
||||
fun requestBrowseFiles() {
|
||||
requests.offer(Request.BrowseFiles)
|
||||
requests.trySend(Request.BrowseFiles)
|
||||
}
|
||||
|
||||
private fun ModelProgressBarConfigure.applyFrom(status: FetchStatus) {
|
||||
|
||||
@@ -24,7 +24,7 @@ class ProvidersDesign(
|
||||
get() = binding.root
|
||||
|
||||
private val adapter = ProviderAdapter(context, providers) { index, provider ->
|
||||
requests.offer(Request.Update(index, provider))
|
||||
requests.trySend(Request.Update(index, provider))
|
||||
}
|
||||
|
||||
fun updateElapsed() {
|
||||
@@ -56,7 +56,7 @@ class ProvidersDesign(
|
||||
adapter.states.filter { !it.updating }.forEachIndexed { index, state ->
|
||||
state.updating = true
|
||||
|
||||
requests.offer(Request.Update(index, state.provider))
|
||||
requests.trySend(Request.Update(index, state.provider))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class ProxyDesign(
|
||||
config,
|
||||
List(groupNames.size) { index ->
|
||||
ProxyAdapter(config) { name ->
|
||||
requests.offer(Request.Select(index, name))
|
||||
requests.trySend(Request.Select(index, name))
|
||||
}
|
||||
}
|
||||
) {
|
||||
@@ -171,7 +171,7 @@ class ProxyDesign(
|
||||
fun requestUrlTesting() {
|
||||
urlTesting = true
|
||||
|
||||
requests.offer(Request.UrlTest(binding.pagesView.currentItem))
|
||||
requests.trySend(Request.UrlTest(binding.pagesView.currentItem))
|
||||
|
||||
updateUrlTestButtonStatus()
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ class SettingsDesign(context: Context) : Design<SettingsDesign.Request>(context)
|
||||
}
|
||||
|
||||
fun request(request: Request) {
|
||||
requests.offer(request)
|
||||
requests.trySend(request)
|
||||
}
|
||||
}
|
||||
@@ -28,46 +28,46 @@ class AccessControlMenu(
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.select_all ->
|
||||
requests.offer(Request.SelectAll)
|
||||
requests.trySend(Request.SelectAll)
|
||||
R.id.select_none ->
|
||||
requests.offer(Request.SelectNone)
|
||||
requests.trySend(Request.SelectNone)
|
||||
R.id.select_invert ->
|
||||
requests.offer(Request.SelectInvert)
|
||||
requests.trySend(Request.SelectInvert)
|
||||
R.id.system_apps -> {
|
||||
uiStore.accessControlSystemApp = !item.isChecked
|
||||
|
||||
requests.offer(Request.ReloadApps)
|
||||
requests.trySend(Request.ReloadApps)
|
||||
}
|
||||
R.id.name -> {
|
||||
uiStore.accessControlSort = AppInfoSort.Label
|
||||
|
||||
requests.offer(Request.ReloadApps)
|
||||
requests.trySend(Request.ReloadApps)
|
||||
}
|
||||
R.id.package_name -> {
|
||||
uiStore.accessControlSort = AppInfoSort.PackageName
|
||||
|
||||
requests.offer(Request.ReloadApps)
|
||||
requests.trySend(Request.ReloadApps)
|
||||
}
|
||||
R.id.install_time -> {
|
||||
uiStore.accessControlSort = AppInfoSort.InstallTime
|
||||
|
||||
requests.offer(Request.ReloadApps)
|
||||
requests.trySend(Request.ReloadApps)
|
||||
}
|
||||
R.id.update_time -> {
|
||||
uiStore.accessControlSort = AppInfoSort.UpdateTime
|
||||
|
||||
requests.offer(Request.ReloadApps)
|
||||
requests.trySend(Request.ReloadApps)
|
||||
}
|
||||
R.id.reverse -> {
|
||||
uiStore.accessControlReverse = item.isChecked
|
||||
|
||||
requests.offer(Request.ReloadApps)
|
||||
requests.trySend(Request.ReloadApps)
|
||||
}
|
||||
R.id.import_from_clipboard -> {
|
||||
requests.offer(Request.Import)
|
||||
requests.trySend(Request.Import)
|
||||
}
|
||||
R.id.export_to_clipboard -> {
|
||||
requests.offer(Request.Export)
|
||||
requests.trySend(Request.Export)
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.github.kr328.clash.design.ui.Insets
|
||||
fun View.setOnInsertsChangedListener(adaptLandscape: Boolean = true, listener: (Insets) -> Unit) {
|
||||
setOnApplyWindowInsetsListener { v, ins ->
|
||||
val compat = WindowInsetsCompat.toWindowInsetsCompat(ins)
|
||||
val insets = compat.systemWindowInsets
|
||||
val insets = compat.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
|
||||
val rInsets = if (ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
||||
Insets(
|
||||
@@ -28,7 +28,7 @@ fun View.setOnInsertsChangedListener(adaptLandscape: Boolean = true, listener: (
|
||||
|
||||
listener(if (adaptLandscape) rInsets.landscape(v.context) else rInsets)
|
||||
|
||||
compat.consumeStableInsets().toWindowInsets()
|
||||
compat.toWindowInsets()
|
||||
}
|
||||
|
||||
requestApplyInsets()
|
||||
|
||||
@@ -208,4 +208,7 @@
|
||||
<string name="active_unsaved_tips">配置文件需要在激活之前保存</string>
|
||||
<string name="mode_switch_tips">僅在本次會話中有效</string>
|
||||
<string name="import_">導入</string>
|
||||
<string name="sources">源代碼</string>
|
||||
<string name="clash_core">Clash 核心</string>
|
||||
<string name="name_server_policy">Name Server 策略</string>
|
||||
</resources>
|
||||
@@ -208,4 +208,7 @@
|
||||
<string name="active_unsaved_tips">配置文件需要在激活之前保存</string>
|
||||
<string name="mode_switch_tips">僅在本次會話中有效</string>
|
||||
<string name="import_">導入</string>
|
||||
<string name="sources">源代碼</string>
|
||||
<string name="clash_core">Clash 核心</string>
|
||||
<string name="name_server_policy">Name Server 策略</string>
|
||||
</resources>
|
||||
@@ -210,4 +210,5 @@
|
||||
<string name="import_">导入</string>
|
||||
<string name="sources">源代码</string>
|
||||
<string name="clash_core">Clash 核心</string>
|
||||
<string name="name_server_policy">Name Server 策略</string>
|
||||
</resources>
|
||||
@@ -159,6 +159,7 @@
|
||||
<string name="geoip_fallback">GeoIP Fallback</string>
|
||||
<string name="ipcidr_fallback">IPCIDR Fallback</string>
|
||||
<string name="domain_fallback">Domain Fallback</string>
|
||||
<string name="name_server_policy">Name Server Policy</string>
|
||||
|
||||
<string name="dont_modify">Do not modify</string>
|
||||
<string name="empty">Empty</string>
|
||||
|
||||
@@ -379,6 +379,15 @@ class OverrideSettingsDesign(
|
||||
placeholder = R.string.dont_modify,
|
||||
configure = dnsDependencies::add,
|
||||
)
|
||||
|
||||
editableTextMap(
|
||||
value = configuration.dns::nameserverPolicy,
|
||||
keyAdapter = TextAdapter.String,
|
||||
valueAdapter = TextAdapter.String,
|
||||
title = R.string.name_server_policy,
|
||||
placeholder = R.string.dont_modify,
|
||||
configure = dnsDependencies::add,
|
||||
)
|
||||
|
||||
dns.listener?.onChanged()
|
||||
}
|
||||
@@ -389,4 +398,4 @@ class OverrideSettingsDesign(
|
||||
fun requestClear() {
|
||||
requests.offer(Request.ResetOverride)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
|
||||
implementation("androidx.room:room-runtime:$roomVersion")
|
||||
implementation("androidx.room:room-ktx:$roomVersion")
|
||||
implementation("androidx.core:core-ktx:$ktxVersion")
|
||||
implementation("androidx.core:core-ktx:$coreVersion")
|
||||
implementation("dev.rikka.rikkax.preference:multiprocess:$muiltprocessVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.content.getSystemService
|
||||
import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.common.compat.pendingIntentFlags
|
||||
import com.github.kr328.clash.common.compat.startForegroundServiceCompat
|
||||
import com.github.kr328.clash.common.constants.Intents
|
||||
@@ -16,7 +17,6 @@ import com.github.kr328.clash.service.data.Imported
|
||||
import com.github.kr328.clash.service.data.ImportedDao
|
||||
import com.github.kr328.clash.service.model.Profile
|
||||
import com.github.kr328.clash.service.util.importedDir
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
@@ -27,7 +27,7 @@ class ProfileReceiver : BroadcastReceiver() {
|
||||
when (intent.action) {
|
||||
Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED,
|
||||
Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_TIME_CHANGED -> {
|
||||
GlobalScope.launch {
|
||||
Global.launch {
|
||||
reset()
|
||||
|
||||
val service = Intent(Intents.ACTION_PROFILE_SCHEDULE_UPDATES)
|
||||
|
||||
@@ -28,7 +28,7 @@ class ConfigurationModule(service: Service) : Module<ConfigurationModule.LoadExc
|
||||
|
||||
var loaded: UUID? = null
|
||||
|
||||
reload.offer(Unit)
|
||||
reload.trySend(Unit)
|
||||
|
||||
while (true) {
|
||||
val changed: UUID? = select {
|
||||
@@ -75,6 +75,6 @@ class ConfigurationModule(service: Service) : Module<ConfigurationModule.LoadExc
|
||||
}
|
||||
|
||||
fun reload() {
|
||||
reload.offer(Unit)
|
||||
reload.trySend(Unit)
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ abstract class Module<E>(val service: Service) {
|
||||
return
|
||||
}
|
||||
|
||||
channel.offer(intent)
|
||||
channel.trySend(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class NetworkObserveModule(service: Service) :
|
||||
override fun onAvailable(network: Network) {
|
||||
this.network = network
|
||||
|
||||
networks.offer(network)
|
||||
networks.trySend(network)
|
||||
}
|
||||
|
||||
override fun onCapabilitiesChanged(
|
||||
@@ -49,19 +49,19 @@ class NetworkObserveModule(service: Service) :
|
||||
if (this.network == network && this.internet != internet) {
|
||||
this.internet = internet
|
||||
|
||||
networks.offer(network)
|
||||
networks.trySend(network)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLost(network: Network) {
|
||||
if (this.network == network) {
|
||||
networks.offer(null)
|
||||
networks.trySend(null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLinkPropertiesChanged(network: Network, linkProperties: LinkProperties) {
|
||||
if (this.network == network) {
|
||||
networks.offer(network)
|
||||
networks.trySend(network)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.service.data.migrations.LEGACY_MIGRATION
|
||||
import com.github.kr328.clash.service.data.migrations.MIGRATIONS
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.ref.SoftReference
|
||||
import androidx.room.Database as DB
|
||||
@@ -41,7 +40,7 @@ abstract class Database : RoomDatabase() {
|
||||
}
|
||||
|
||||
init {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
Global.launch(Dispatchers.IO) {
|
||||
LEGACY_MIGRATION(Global.application)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user