Skip to content

This library allows to automatically desaturate colors when using Dark theme as described in Material Docs

License

Notifications You must be signed in to change notification settings

ologe/color-desaturation

Repository files navigation

Color desaturation

This library allows to automatically desaturate colors when using Dark theme as described in Material Docs

Caveats

  • The library has some problem with material widgets, and I'm currently working to resolve this issue

Usage

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

Getting started

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'

Screenshots

About

This library allows to automatically desaturate colors when using Dark theme as described in Material Docs

Resources

License

Stars

Watchers

Forks

Packages

No packages published