Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: MetaCubeX/ClashMetaForAndroid
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.11.4
Choose a base ref
...
head repository: MetaCubeX/ClashMetaForAndroid
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 12 commits
  • 54 files changed
  • 4 contributors

Commits on Dec 22, 2024

  1. Copy the full SHA
    e15477c View commit details

Commits on Dec 25, 2024

  1. Update Dependencies (#412)

    Co-authored-by: clash-meta-maintainer[bot] <148681994+clash-meta-maintainer[bot]@users.noreply.github.com>
    clash-meta-maintainer[bot] authored Dec 25, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    565d1d7 View commit details

Commits on Dec 31, 2024

  1. Update Dependencies (#414)

    Co-authored-by: clash-meta-maintainer[bot] <148681994+clash-meta-maintainer[bot]@users.noreply.github.com>
    clash-meta-maintainer[bot] authored Dec 31, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7598481 View commit details
  2. Copy the full SHA
    3100e17 View commit details

Commits on Jan 21, 2025

  1. Update app (#428)

    5ec1cff authored Jan 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e8e0010 View commit details
  2. Update Dependencies (#422)

    clash-meta-maintainer[bot] authored Jan 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9fd394d View commit details

Commits on Jan 22, 2025

  1. app: refine LogsActivity & LogcatActivity (#431)

    5ec1cff authored Jan 22, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    64a69e6 View commit details

Commits on Feb 5, 2025

  1. remove unnecessary READ_EXTERNAL_STORAGE permission (#439)

    5ec1cff authored Feb 5, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2760de9 View commit details
  2. Update Dependencies (#437)

    Co-authored-by: clash-meta-maintainer[bot] <148681994+clash-meta-maintainer[bot]@users.noreply.github.com>
    clash-meta-maintainer[bot] authored Feb 5, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e5d8c9f View commit details

Commits on Feb 9, 2025

  1. Copy the full SHA
    57f0434 View commit details

Commits on Feb 10, 2025

  1. fix build error and filter target arch (#443)

    ForestL18 authored Feb 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a012d81 View commit details
  2. Update Dependencies (#441)

    Co-authored-by: clash-meta-maintainer[bot] <148681994+clash-meta-maintainer[bot]@users.noreply.github.com>
    clash-meta-maintainer[bot] authored Feb 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4f22a46 View commit details
Showing with 350 additions and 258 deletions.
  1. +2 −2 .github/workflows/build-debug.yaml
  2. +2 −2 .github/workflows/build-pre-release.yaml
  3. +2 −2 .github/workflows/build-release.yaml
  4. +2 −2 .github/workflows/update-dependencies.yaml
  5. +8 −4 app/src/main/AndroidManifest.xml
  6. +4 −1 app/src/main/java/com/github/kr328/clash/AccessControlActivity.kt
  7. +1 −0 app/src/main/java/com/github/kr328/clash/BaseActivity.kt
  8. +1 −0 app/src/main/java/com/github/kr328/clash/ExternalControlActivity.kt
  9. +0 −18 app/src/main/java/com/github/kr328/clash/FilesActivity.kt
  10. +2 −1 app/src/main/java/com/github/kr328/clash/LogcatActivity.kt
  11. +7 −6 app/src/main/java/com/github/kr328/clash/LogcatService.kt
  12. +1 −5 app/src/main/java/com/github/kr328/clash/LogsActivity.kt
  13. +31 −2 app/src/main/java/com/github/kr328/clash/MainActivity.kt
  14. +1 −0 app/src/main/java/com/github/kr328/clash/MetaFeatureSettingsActivity.kt
  15. +1 −0 app/src/main/java/com/github/kr328/clash/NewProfileActivity.kt
  16. +1 −1 app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt
  17. +4 −2 app/src/main/java/com/github/kr328/clash/PropertiesActivity.kt
  18. +1 −0 app/src/main/java/com/github/kr328/clash/ProvidersActivity.kt
  19. +3 −1 app/src/main/java/com/github/kr328/clash/TileService.kt
  20. +2 −1 app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt
  21. +1 −5 app/src/main/java/com/github/kr328/clash/util/Activity.kt
  22. +23 −6 build.gradle.kts
  23. +1 −2 common/src/main/AndroidManifest.xml
  24. +21 −1 common/src/main/java/com/github/kr328/clash/common/compat/Context.kt
  25. +12 −1 common/src/main/java/com/github/kr328/clash/common/compat/Services.kt
  26. +1 −0 core/.gitignore
  27. +16 −3 core/build.gradle.kts
  28. +1 −1 core/src/foss/golang/clash
  29. +16 −16 core/src/foss/golang/go.mod
  30. +36 −33 core/src/foss/golang/go.sum
  31. +1 −2 core/src/main/AndroidManifest.xml
  32. +16 −15 core/src/main/golang/go.mod
  33. +36 −32 core/src/main/golang/go.sum
  34. +1 −1 core/src/main/java/com/github/kr328/clash/core/bridge/Bridge.kt
  35. +1 −1 design/src/main/AndroidManifest.xml
  36. +1 −1 design/src/main/java/com/github/kr328/clash/design/MainDesign.kt
  37. +1 −1 design/src/main/java/com/github/kr328/clash/design/ProxyDesign.kt
  38. +3 −3 design/src/main/java/com/github/kr328/clash/design/adapter/PopupListAdapter.kt
  39. +4 −4 design/src/main/java/com/github/kr328/clash/design/component/ProxyViewConfig.kt
  40. +2 −2 design/src/main/java/com/github/kr328/clash/design/util/App.kt
  41. +1 −1 design/src/main/java/com/github/kr328/clash/design/util/Inserts.kt
  42. +1 −9 design/src/main/java/com/github/kr328/clash/design/view/AppRecyclerView.kt
  43. +1 −1 design/src/main/java/com/github/kr328/clash/design/view/LargeActionCard.kt
  44. +2 −2 design/src/main/res/values-vi/strings.xml
  45. +43 −0 gradle/libs.versions.toml
  46. +2 −4 gradle/wrapper/gradle-wrapper.properties
  47. +1 −1 hideapi/src/main/AndroidManifest.xml
  48. +1 −1 service/build.gradle.kts
  49. +16 −5 service/src/main/AndroidManifest.xml
  50. +2 −1 service/src/main/java/com/github/kr328/clash/service/ProfileWorker.kt
  51. +4 −3 service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt
  52. +3 −2 service/src/main/java/com/github/kr328/clash/service/clash/module/Module.kt
  53. +3 −2 service/src/main/java/com/github/kr328/clash/service/clash/module/StaticNotificationModule.kt
  54. +0 −46 settings.gradle.kts
4 changes: 2 additions & 2 deletions .github/workflows/build-debug.yaml
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
distribution: "temurin"
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
4 changes: 2 additions & 2 deletions .github/workflows/build-pre-release.yaml
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
distribution: "temurin"
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
4 changes: 2 additions & 2 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
distribution: "temurin"
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
4 changes: 2 additions & 2 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
distribution: "temurin"
java-version: 21

- name: Setup Go
uses: actions/setup-go@v5
12 changes: 8 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.github.kr328.clash">
xmlns:tools="http://schemas.android.com/tools">

<uses-feature
android:name="android.software.leanback"
@@ -12,10 +11,11 @@

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<application
android:name=".MainApplication"
@@ -172,7 +172,11 @@
<service
android:name=".LogcatService"
android:exported="false"
android:label="@string/clash_logcat" />
android:label="@string/clash_logcat"
android:foregroundServiceType="specialUse">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="explanation_for_special_use"/>
</service>
<service
android:name=".TileService"
android:exported="true"
Original file line number Diff line number Diff line change
@@ -120,6 +120,9 @@ class AccessControlActivity : BaseActivity<AccessControlDesign>() {
.filter {
it.packageName == "android" || it.requestedPermissions?.contains(INTERNET) == true
}
.filter {
it.applicationInfo != null
}
.filter {
systemApp || !it.isSystemApp
}
@@ -132,6 +135,6 @@ class AccessControlActivity : BaseActivity<AccessControlDesign>() {

private val PackageInfo.isSystemApp: Boolean
get() {
return applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0
return applicationInfo?.flags?.and(ApplicationInfo.FLAG_SYSTEM) != 0
}
}
1 change: 1 addition & 0 deletions app/src/main/java/com/github/kr328/clash/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import java.util.*
import java.util.concurrent.atomic.AtomicInteger
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import com.github.kr328.clash.design.R

abstract class BaseActivity<D : Design<*>> : AppCompatActivity(),
CoroutineScope by MainScope(),
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import java.util.*
import com.github.kr328.clash.design.R

class ExternalControlActivity : Activity(), CoroutineScope by MainScope() {
override fun onCreate(savedInstanceState: Bundle?) {
18 changes: 0 additions & 18 deletions app/src/main/java/com/github/kr328/clash/FilesActivity.kt
Original file line number Diff line number Diff line change
@@ -81,24 +81,6 @@ class FilesActivity : BaseActivity<FilesDesign>() {
client.renameDocument(it.file.id, newName)
}
is FilesDesign.Request.ImportFile -> {
if (Build.VERSION.SDK_INT >= 23) {
val hasPermission = ContextCompat.checkSelfPermission(
this@FilesActivity,
Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED

if (!hasPermission) {
val granted = startActivityForResult(
ActivityResultContracts.RequestPermission(),
Manifest.permission.READ_EXTERNAL_STORAGE,
)

if (!granted) {
return@onReceive
}
}
}

val uri: Uri? = startActivityForResult(
ActivityResultContracts.GetContent(),
"*/*"
3 changes: 2 additions & 1 deletion app/src/main/java/com/github/kr328/clash/LogcatActivity.kt
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import kotlinx.coroutines.withContext
import java.io.OutputStreamWriter
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import com.github.kr328.clash.design.R

class LogcatActivity : BaseActivity<LogcatDesign>() {
private var conn: ServiceConnection? = null
@@ -111,7 +112,7 @@ class LogcatActivity : BaseActivity<LogcatDesign>() {
when (it) {
LogcatDesign.Request.Close -> {
stopService(LogcatService::class.intent)

startActivity(LogsActivity::class.intent)
finish()
}
else -> Unit
13 changes: 7 additions & 6 deletions app/src/main/java/com/github/kr328/clash/LogcatService.kt
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
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.log.Log
import com.github.kr328.clash.common.util.intent
import com.github.kr328.clash.core.model.LogMessage
@@ -130,17 +131,17 @@ class LogcatService : Service(), CoroutineScope by CoroutineScope(Dispatchers.De
NotificationChannelCompat.Builder(
CHANNEL_ID,
NotificationManagerCompat.IMPORTANCE_DEFAULT
).setName(getString(R.string.clash_logcat)).build()
).setName(getString(com.github.kr328.clash.design.R.string.clash_logcat)).build()
)
}

private fun showNotification() {
val notification = NotificationCompat
.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo_service)
.setColor(getColorCompat(R.color.color_clash_light))
.setContentTitle(getString(R.string.clash_logcat))
.setContentText(getString(R.string.running))
.setSmallIcon(com.github.kr328.clash.service.R.drawable.ic_logo_service)
.setColor(getColorCompat(com.github.kr328.clash.design.R.color.color_clash_light))
.setContentTitle(getString(com.github.kr328.clash.design.R.string.clash_logcat))
.setContentText(getString(com.github.kr328.clash.design.R.string.running))
.setContentIntent(
PendingIntent.getActivity(
this,
@@ -152,7 +153,7 @@ class LogcatService : Service(), CoroutineScope by CoroutineScope(Dispatchers.De
)
.build()

startForeground(R.id.nf_logcat_status, notification)
startForegroundCompat(R.id.nf_logcat_status, notification)
}

companion object {
6 changes: 1 addition & 5 deletions app/src/main/java/com/github/kr328/clash/LogsActivity.kt
Original file line number Diff line number Diff line change
@@ -11,11 +11,8 @@ import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext

class LogsActivity : BaseActivity<LogsDesign>() {
override suspend fun main() {
if (LogcatService.running) {
return startActivity(LogcatActivity::class.intent)
}

override suspend fun main() {
val design = LogsDesign(this)

setContentDesign(design)
@@ -38,7 +35,6 @@ class LogsActivity : BaseActivity<LogsDesign>() {
when (it) {
LogsDesign.Request.StartLogcat -> {
startActivity(LogcatActivity::class.intent)

finish()
}
LogsDesign.Request.DeleteAll -> {
33 changes: 31 additions & 2 deletions app/src/main/java/com/github/kr328/clash/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package com.github.kr328.clash

import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.os.PersistableBundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.github.kr328.clash.common.util.intent
import com.github.kr328.clash.common.util.ticker
import com.github.kr328.clash.design.MainDesign
@@ -15,6 +22,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext
import java.util.concurrent.TimeUnit
import com.github.kr328.clash.design.R

class MainActivity : BaseActivity<MainDesign>() {
override suspend fun main() {
@@ -51,8 +59,13 @@ class MainActivity : BaseActivity<MainDesign>() {
startActivity(ProfilesActivity::class.intent)
MainDesign.Request.OpenProviders ->
startActivity(ProvidersActivity::class.intent)
MainDesign.Request.OpenLogs ->
startActivity(LogsActivity::class.intent)
MainDesign.Request.OpenLogs -> {
if (LogcatService.running) {
startActivity(LogcatActivity::class.intent)
} else {
startActivity(LogsActivity::class.intent)
}
}
MainDesign.Request.OpenSettings ->
startActivity(SettingsActivity::class.intent)
MainDesign.Request.OpenHelp ->
@@ -129,4 +142,20 @@ class MainActivity : BaseActivity<MainDesign>() {
packageManager.getPackageInfo(packageName, 0).versionName + "\n" + Bridge.nativeCoreVersion().replace("_", "-")
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val requestPermissionLauncher =
registerForActivityResult(RequestPermission()
) { isGranted: Boolean ->
}
if (ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED) {
requestPermissionLauncher.launch(android.Manifest.permission.POST_NOTIFICATIONS)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext
import java.io.File
import java.io.FileOutputStream
import com.github.kr328.clash.design.R


class MetaFeatureSettingsActivity : BaseActivity<MetaFeatureSettingsDesign>() {
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext
import java.util.*
import com.github.kr328.clash.design.R

class NewProfileActivity : BaseActivity<NewProfileDesign>() {
private val self: NewProfileActivity
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import com.github.kr328.clash.common.util.setUUID
import com.github.kr328.clash.common.util.ticker
import com.github.kr328.clash.design.ProfilesDesign
import com.github.kr328.clash.design.ui.ToastDuration
import com.github.kr328.clash.R
import com.github.kr328.clash.service.model.Profile
import com.github.kr328.clash.util.withProfile
import kotlinx.coroutines.Dispatchers
@@ -19,6 +18,7 @@ import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext
import java.util.*
import java.util.concurrent.TimeUnit
import com.github.kr328.clash.design.R

class ProfilesActivity : BaseActivity<ProfilesDesign>() {
override suspend fun main() {
Original file line number Diff line number Diff line change
@@ -12,17 +12,19 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.selects.select
import com.github.kr328.clash.design.R

class PropertiesActivity : BaseActivity<PropertiesDesign>() {
private var canceled: Boolean = false
private lateinit var original: Profile

override suspend fun main() {
setResult(RESULT_CANCELED)

val uuid = intent.uuid ?: return finish()
val design = PropertiesDesign(this)

val original = withProfile { queryByUUID(uuid) } ?: return finish()
original = withProfile { queryByUUID(uuid) } ?: return finish()

design.profile = original

@@ -71,7 +73,7 @@ class PropertiesActivity : BaseActivity<PropertiesDesign>() {
design?.apply {
launch {
if (!progressing) {
if (requestExitWithoutSaving())
if (original == profile || requestExitWithoutSaving())
finish()
}
}
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.selects.select
import java.util.concurrent.TimeUnit
import com.github.kr328.clash.design.R

class ProvidersActivity : BaseActivity<ProvidersDesign>() {
override suspend fun main() {
4 changes: 3 additions & 1 deletion app/src/main/java/com/github/kr328/clash/TileService.kt
Original file line number Diff line number Diff line change
@@ -9,11 +9,13 @@ import android.os.Build
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
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.remote.StatusClient
import com.github.kr328.clash.util.startClashService
import com.github.kr328.clash.util.stopClashService
import com.github.kr328.clash.service.R

@RequiresApi(Build.VERSION_CODES.N)
class TileService : TileService() {
@@ -36,7 +38,7 @@ class TileService : TileService() {
override fun onStartListening() {
super.onStartListening()

registerReceiver(
registerReceiverCompat(
receiver,
IntentFilter().apply {
addAction(Intents.ACTION_CLASH_STARTED)
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import android.content.BroadcastReceiver
import android.content.Context
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 java.util.*
@@ -88,7 +89,7 @@ class Broadcasts(private val context: Application) {
return

try {
context.registerReceiver(broadcastReceiver, IntentFilter().apply {
context.registerReceiverCompat(broadcastReceiver, IntentFilter().apply {
addAction(Intents.ACTION_SERVICE_RECREATED)
addAction(Intents.ACTION_CLASH_STARTED)
addAction(Intents.ACTION_CLASH_STOPPED)
Loading