This library allows to automatically desaturate colors when using Dark theme as described in Material Docs
- The library has some problem with material widgets, and I'm currently working to resolve this issue
Simply add this to your BaseActivity and you're done
abstract class BaseActivity : AppCompatActivity() {
private var customResources: Resources? = null
override fun getResources(): Resources {
if (customResources == null) {
val res = super.getResources()
val isDarkMode = res.getBoolean(R.bool.is_dark_mode)
customResources = DarkDesaturatedResources(isDarkMode, res)
}
return customResources!!
}
}
In this example `R.bool.dark_mode is. used to detect when is using dark mode, see the sample application for more information
Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
implementation 'com.github.ologe:color-desaturation:1.0.2'