mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Chore: clean compat code
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
package com.github.kr328.clash.service
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationChannelCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.github.kr328.clash.common.compat.getColorCompat
|
||||
@@ -95,26 +93,20 @@ class ProfileWorker : BaseService() {
|
||||
}
|
||||
|
||||
private fun createChannels() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
||||
return
|
||||
|
||||
NotificationManagerCompat.from(this).createNotificationChannels(
|
||||
NotificationManagerCompat.from(this).createNotificationChannelsCompat(
|
||||
listOf(
|
||||
NotificationChannel(
|
||||
NotificationChannelCompat.Builder(
|
||||
SERVICE_CHANNEL,
|
||||
getString(R.string.profile_service_status),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
),
|
||||
NotificationChannel(
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
).setName(getString(R.string.profile_service_status)).build(),
|
||||
NotificationChannelCompat.Builder(
|
||||
STATUS_CHANNEL,
|
||||
getString(R.string.profile_process_status),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
),
|
||||
NotificationChannel(
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
).setName(getString(R.string.profile_process_status)).build(),
|
||||
NotificationChannelCompat.Builder(
|
||||
RESULT_CHANNEL,
|
||||
getString(R.string.profile_process_result),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
NotificationManagerCompat.IMPORTANCE_DEFAULT
|
||||
).setName(getString(R.string.profile_process_result)).build()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.github.kr328.clash.service.clash.module
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationChannelCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.github.kr328.clash.common.compat.getColorCompat
|
||||
@@ -57,14 +55,11 @@ class StaticNotificationModule(service: Service) : Module<Unit>(service) {
|
||||
const val CHANNEL_ID = "clash_status_channel"
|
||||
|
||||
fun createNotificationChannel(service: Service) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
||||
return
|
||||
NotificationManagerCompat.from(service).createNotificationChannel(
|
||||
NotificationChannel(
|
||||
NotificationChannelCompat.Builder(
|
||||
CHANNEL_ID,
|
||||
service.getText(R.string.clash_service_status_channel),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
)
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
).setName(service.getText(R.string.clash_service_status_channel)).build()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class TunModule(private val vpn: VpnService) : Module<Unit>(vpn) {
|
||||
source: InetSocketAddress,
|
||||
target: InetSocketAddress,
|
||||
): Int {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
|
||||
if (Build.VERSION.SDK_INT < 29)
|
||||
return -1
|
||||
|
||||
return runCatching { connectivity.getConnectionOwnerUid(protocol, source, target) }
|
||||
|
||||
Reference in New Issue
Block a user