feat: show toast after profile updated

This commit is contained in:
Steve Johnson
2023-10-31 22:14:47 +08:00
parent bd82ba7773
commit b6f4f7ac62
13 changed files with 107 additions and 1 deletions

View File

@@ -15,6 +15,8 @@ import com.github.kr328.clash.common.id.UndefinedIds
import com.github.kr328.clash.common.util.setUUID
import com.github.kr328.clash.common.util.uuid
import com.github.kr328.clash.service.data.ImportedDao
import com.github.kr328.clash.service.util.sendProfileUpdateCompleted
import com.github.kr328.clash.service.util.sendProfileUpdateFailed
import kotlinx.coroutines.*
import java.util.*
import java.util.concurrent.TimeUnit
@@ -176,6 +178,8 @@ class ProfileWorker : BaseService() {
NotificationManagerCompat.from(this)
.notify(id, notification)
sendProfileUpdateCompleted(uuid)
}
private fun failed(uuid: UUID, name: String, reason: String) {
@@ -191,6 +195,8 @@ class ProfileWorker : BaseService() {
NotificationManagerCompat.from(this)
.notify(id, notification)
sendProfileUpdateFailed(uuid, reason)
}
companion object {

View File

@@ -27,6 +27,21 @@ fun Context.sendProfileLoaded(uuid: UUID) {
sendBroadcastSelf(intent)
}
fun Context.sendProfileUpdateCompleted(uuid: UUID) {
val intent = Intent(Intents.ACTION_PROFILE_UPDATE_COMPLETED)
.putExtra(Intents.EXTRA_UUID, uuid.toString())
sendBroadcastSelf(intent)
}
fun Context.sendProfileUpdateFailed(uuid: UUID, reason: String) {
val intent = Intent(Intents.ACTION_PROFILE_UPDATE_FAILED)
.putExtra(Intents.EXTRA_UUID, uuid.toString())
.putExtra(Intents.EXTRA_FAIL_REASON, reason)
sendBroadcastSelf(intent)
}
fun Context.sendOverrideChanged() {
val intent = Intent(Intents.ACTION_OVERRIDE_CHANGED)