You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
A follow up to this would most likely introduce something like the following code sample, given this is a very rough draft
fun Int.adjustColorForContrast(@ColorInt backgroundColor:Int): Int {
val color =// convert `this` to `Color`val background =// convert `backgroundColor` to `Color`val colorLuminance =0.2126* color.red +0.7152* color.green +0.0722* color.blue
val backgroundLuminance =0.2126* background.red +0.7152* background.green +0.0722* background.blue
val contrastRatio = (colorLuminance +0.05) / (backgroundLuminance +0.05)
val threshold =4.5if (contrastRatio < threshold) {
return color.inv() // Invert the color
}
return color
}
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.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
The text was updated successfully, but these errors were encountered: