Skip to content

ponsuyambu/Toggler

Repository files navigation

Toggles

Toggler master Download codecov Maintainability

Handle the feature toggles in your Android app seamlessly!

Setup

Dependency

repositories {
    maven { url 'https://dl.bintray.com/suyambu/android/' }
}
dependencies {
    implementation 'in.ponshere:toggler:0.0.4'
}

Toggles configuration

Basic usage

1. Create an interface with SwitchToggle annotation
interface AppToggles {
    @SwitchToggle(
        sharedPreferencesKey = "featureA",
        defaultValue = true,
        fireBaseRemoteConfigKey = "featureA"
    )
    fun isFeatureAEnabled(): Boolean
}
2. Initialize the toggler in application class
class TogglerApp : Application() {
    override fun onCreate() {
        super.onCreate()
        val appToggles = Toggler.init(this, AppToggles::class.java)
    }
}
3. Use the toggle
if(Toggler.get<AppToggles>().isFeatureAEnabled()) {
    //enable Feature A
}

or you can also use the appToggles instance created in application class.

if(appToggles.isFeatureAEnabled()) {
    //enable Feature A
}
4. Showing all toggles

To show all of the toggles, use the below API. In the screen, you can easily enable/disable/change toggle values.

Toggler.showAllToggles(context)

Contributing

Please fork this repository and contribute back using pull requests. Features can be requested using issues. All code, comments, and critiques are greatly appreciated.