-
-
Notifications
You must be signed in to change notification settings - Fork 5
Description
AniTrend Issue Guidelines
Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.
You may find an answer in already closed issues:
https://github.com/AniTrend/anitrend-v2/issues?q=is%3Aissue+is%3Aclosed
Description of Bug
Contrast adjustments required for a few widgets that dynamically use the accent colour from a media image. The problem comes in when we have a colour that does not have enough contrast with a dark background, e.g. when you switch to night mode.
Reproduction Steps
- Open this link with the app https://anilist.co/anime/127230/Chainsaw-Man
- Switch to dark mode on your device
Screenshots/Videos
List (dark) | Detail (dark) | Detail (light) |
---|---|---|
![]() |
![]() |
![]() |
Additional Context
See co.anitrend.core.android.helpers.color.ColorExtensions
which is what we use to infer and shift colours that would typically not contrast enough with the background colour of the app at any given point in time.
anitrend-v2/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt
Lines 29 to 43 in ff08b5d
/** Checks if a color has enough contrast */ | |
fun Int.hasEnoughContrastFor( | |
@ColorInt backgroundColor: Int | |
) = ColorUtils.calculateContrast( | |
this, | |
backgroundColor | |
) > 1.8f | |
/** Decreases the lightness of the color by the [factor] */ | |
fun Int.increaseContrastBy(factor: Float): Int { | |
val hsl = FloatArray(3) | |
ColorUtils.colorToHSL(this, hsl) | |
hsl[2] = hsl[2] * factor | |
return ColorUtils.HSLToColor(hsl) | |
} |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status