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
Changes from 8 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
Expand Up @@ -2,6 +2,7 @@

import android.app.Notification
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.Icon
import android.os.Handler
import android.os.Looper
Expand All @@ -14,6 +15,7 @@
import io.github.domi04151309.alwayson.helpers.JSON
import io.github.domi04151309.alwayson.helpers.Rules
import io.github.domi04151309.alwayson.receivers.CombinedServiceReceiver
import kotlin.math.roundToInt
import org.json.JSONArray

class NotificationService : NotificationListenerService() {
Expand Down Expand Up @@ -81,10 +83,28 @@
}
if (!apps.contains(notification.packageName)) {
apps += notification.packageName

var color: Int = notification.notification.color

val colorRed: Int = Color.red(color)
val colorGreen: Int = Color.green(color)
val colorBlue: Int = Color.blue(color)

color = if ((colorRed < 1) && (colorGreen < 1) && (colorBlue < 1)) {
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Color.WHITE
} else {
val rgbMax: Int = maxOf(colorRed, colorGreen, colorBlue)
val rgbFactor: Float = 255 / rgbMax.toFloat()
val newRed: Int = minOf(255, (colorRed * rgbFactor).roundToInt())
val newGreen: Int = minOf(255, (colorGreen * rgbFactor).roundToInt())
val newBlue: Int = minOf(255, (colorBlue * rgbFactor).roundToInt())
Color.rgb(newRed, newGreen, newBlue)
}

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