ModernAndroidPreferences

Introduction: Android Preferences defined through Kotlin DSL, shown in a RecyclerView
More: Author   ReportBugs   
Tags:

Latest release Build status License

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

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"
    }
}

…and many other preference widgets!

Create preference adapter

val preferencesAdapter = PreferencesAdapter(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

ModernAndroidPreferences is on Bintray, so you can get it like any other dependency via JCenter:

dependencies {
    implementation 'de.Maxr1998.android:modernpreferences:0.5.6'
}

Alternatively, you can get snapshot versions through JitPack:

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

…

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

License

Copyright © 2018-2020 Max Rumpf alias Maxr1998

This library is released under the Apache License version 2.0. If you use this library (or code inspired by it) in your projects, crediting me is appreciated.

The example application however is licensed under the GNU General Public version 3, or any later version.

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools