Android Preferences defined through Kotlin DSL, shown in a RecyclerView
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper Update dependencies and build tools Oct 11, 2018
library
testapp
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

ModernAndroidPreferences

Android Preferences defined through Kotlin DSL, shown in a RecyclerView.
No XML, no awful PreferenceManager, Fragments or styling problems, no more ListView. 🎉

Syntax example

val screen = screen(context) {
    pref("first") {
        title = "A preference"
        summary = "Click me to do stuff"
        click {
            doStuff()
        }
    }
    pref("second") {
        title = "Another one"
        iconRes = R.drawable.preference_icon_24dp
    }
    categoryHeader("more") {
        titleRes = R.string.category_more
    }
    switch("toggle_feature") {
        title = "Also supports switches"
    }
}

Create preference adapter

val preferencesAdapter = PreferencesAdapter()
preferencesAdapter.setRootScreen(screen)

View the example app

Example Activities (with and without using ViewModel) show advanced info like back handling, saving/restoring scroll position, and using the OnScreenChangeListener.

Include to project

You can get ModernAndroidPreferences through JitPack:

repositories {
    maven { url 'https://jitpack.io' }
}

…

dependencies {
    implementation 'com.github.Maxr1998:ModernAndroidPreferences:-SNAPSHOT'
}