Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brighter colours when coloured icons is on #104

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,10 +82,11 @@ class NotificationService : NotificationListenerService() {
}
if (!apps.contains(notification.packageName)) {
apps += notification.packageName

icons.add(
Pair(
notification.notification.smallIcon,
notification.notification.color,
ColorHelper.boostColor(notification.notification.color),
),
)
}
Expand Down
Loading