MaterialPreferences
This library is based on Flows
and Coroutines
and works with the provided DataStore Storage or even with a custom storage implementation.
It supports LiveData
by default as Flows
can easily be converted to LiveData
. Preferences are elegantly declared via delegates
.
Additionally the preference-screen module provides a DSL to easily set up RecyclerView
based preference screens.
It also supports custom extensions for custom preference screens.
Following are the key features:
- define preferences elegantly via delegates
- flow and coroutine based
- allows to observe single / some / all preferences
- provides suspending update functions
- provides a DSL for a
RecyclerView
based setting screen
Core
With this library you can declare preferences via kotlin delegates
,and observe and update them via kotlin Flows
. This works with any storage implementation, an implementation for JetPack DataStore is provided already.
1/4 Define preferences:
2/4 Observe/Read preferences:
3/4 Lifedata:
4/4 Update preferences:
Storage
The Storage
is an abstraction to support any storage implementation. The datastore
module provides an implementation based on the Android JetPack DataStore.
Preference Screen
The preference-screen* modules allow you to create preference screens like following easily via DSL.
Gradle (via JitPack.io)
- add jitpack to your project's
build.gradle
:
- add the compile statement to your module's
build.gradle
: