Skip to content

Commit

Permalink
fix(daemon): use distinct notification IDs for deploy start/success/f…
Browse files Browse the repository at this point in the history
…ailure states

Distinct colors are also used for the different states.
  • Loading branch information
WhiredPlanck committed Feb 8, 2025
1 parent a8f13d7 commit 89e9285
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/main/java/com/osfans/trime/daemon/RimeDaemon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package com.osfans.trime.daemon

import android.app.PendingIntent
import android.content.Intent
import android.graphics.Color
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.osfans.trime.R
Expand Down Expand Up @@ -176,15 +177,17 @@ object RimeDaemon {
RimeMessage.DeployMessage.State.Start -> {
sendNotification(MESSAGE_ID) {
setSmallIcon(R.drawable.ic_baseline_sync_24)
setColor(Color.GRAY)
setContentText(appContext.getString(R.string.deploy_progress))
setPriority(NotificationCompat.PRIORITY_DEFAULT)
setTimeoutAfter(2000L)
}
withContext(Dispatchers.IO) { subprocess("logcat", "--clear") }
}
RimeMessage.DeployMessage.State.Success -> {
sendNotification(MESSAGE_ID) {
sendNotification(MESSAGE_ID + 1) {
setSmallIcon(R.drawable.ic_baseline_sync_24)
setColor(Color.GREEN)
setContentText(appContext.getString(R.string.deploy_finish))
setPriority(NotificationCompat.PRIORITY_DEFAULT)
setTimeoutAfter(2000L)
Expand All @@ -200,8 +203,9 @@ object RimeDaemon {
putExtra(LogActivity.FROM_DEPLOY, true)
putExtra(LogActivity.DEPLOY_FAILURE_TRACE, log)
}
sendNotification(MESSAGE_ID) {
sendNotification(MESSAGE_ID + 2) {
setSmallIcon(R.drawable.ic_baseline_warning_24)
setColor(Color.YELLOW)
setContentText(appContext.getString(R.string.view_deploy_failure_log))
setContentIntent(
PendingIntent.getActivity(
Expand Down

0 comments on commit 89e9285

Please sign in to comment.