add package list

This commit is contained in:
Kr328 committed 2020-02-19 15:28:32 +08:00
1 parent 168a097111
commit ab03e551da
11 files changed
+297 -9

No files matched your search

@@ -19,7 +19,7 @@ import com.github.kr328.clash.core.utils.asSpeedString
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
class ClashNotification(private val context: ClashService, enableRefresh: Boolean) :
class ClashNotification(private val context: ClashService, private val enableRefresh: Boolean) :
CoroutineScope by context {
companion object {
private const val CLASH_STATUS_NOTIFICATION_CHANNEL = "clash_status_channel"
@@ -63,7 +63,7 @@ class ClashNotification(private val context: ClashService, enableRefresh: Boolea
init {
createNotificationChannel()
notifyBaseNotification()
updateBase()
if (enableRefresh) {
launch {
@@ -119,7 +119,9 @@ class ClashNotification(private val context: ClashService, enableRefresh: Boolea
}
fun destroy() {
context.unregisterReceiver(observer)
if ( enableRefresh )
context.unregisterReceiver(observer)
context.stopForeground(true)
}
@@ -127,11 +129,14 @@ class ClashNotification(private val context: ClashService, enableRefresh: Boolea
launch {
this@ClashNotification.profile = profile
update()
if ( enableRefresh )
update()
else
updateBase()
}
}
private fun notifyBaseNotification() {
private fun updateBase() {
val notification = baseBuilder
.setContentTitle(profile)
.setContentText(context.getText(R.string.running))
+1 -1
View File
@@ -12,5 +12,5 @@
<string name="profile_status_update_failure">更新 %s 失败</string>
<string name="profile_status_updating">正在更新 %s</string>
<string name="running">正在运行</string>
<string name="tun_service_label">Tun 服务</string>
<string name="tun_service_label">Tun 设备服务</string>
</resources>