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
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.
|
/** 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) |
|
} |
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
Screenshots/Videos
Additional Context
See
co.anitrend.core.android.helpers.color.ColorExtensionswhich 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