Skip to content

Commit

Permalink
Force brighter colours
Browse files Browse the repository at this point in the history
Co-Authored-By: Rich <[email protected]>
  • Loading branch information
Domi04151309 and rlees85 committed Feb 9, 2025
1 parent 74be9a1 commit 2284b76
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.domi04151309.alwayson.helpers;

import android.graphics.Color
import kotlin.math.roundToInt

object ColorHelper {
fun boostColor(color: Int): Int {
val colorRed: Int = Color.red(color)
val colorGreen: Int = Color.green(color)
val colorBlue: Int = Color.blue(color)

return if (colorRed < 1 && colorGreen < 1 && colorBlue < 1) {
Color.WHITE
} else {
val rgbMax: Int = maxOf(colorRed, colorGreen, colorBlue)
val rgbFactor: Float = 255 / rgbMax.toFloat()
val boostedRed: Int = minOf(255, (colorRed * rgbFactor).roundToInt())
val boostedGreen: Int = minOf(255, (colorGreen * rgbFactor).roundToInt())
val boostedBlue: Int = minOf(255, (colorBlue * rgbFactor).roundToInt())
Color.rgb(boostedRed, boostedGreen, boostedBlue)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.service.notification.StatusBarNotification
import android.util.Log
import androidx.preference.PreferenceManager
import io.github.domi04151309.alwayson.actions.alwayson.AlwaysOn
import io.github.domi04151309.alwayson.helpers.ColorHelper
import io.github.domi04151309.alwayson.helpers.Global
import io.github.domi04151309.alwayson.helpers.JSON
import io.github.domi04151309.alwayson.helpers.Rules
Expand Down Expand Up @@ -84,7 +85,7 @@ class NotificationService : NotificationListenerService() {
icons.add(
Pair(
notification.notification.smallIcon,
notification.notification.color,
ColorHelper.boostColor(notification.notification.color),
),
)
}
Expand Down

0 comments on commit 2284b76

Please sign in to comment.