Simple Settings library for Android

Simple installation activity

Simple Settings is a library that offers an easy to use and manage solution for creating a control panel without template code. This saves costs, time and effort.

Screenshots (Android 10)





If you want to test the library, see the sample application on Google Play!


The first step to using this library is to add it to the dependencies section of your project:

Implementation of com.chillibits:simpleettings:1.0.0-alpha11.

Implementation of androidx.preference:.

You must also mention the activity in your manifesto:


The library accepts two different ways to provide information through the control panel.

Delivery of articles per program

With this callback you can create configuration items using the show() method:

SimpleSettings(this).show {
section {
title = Test section
for (i in 1…4) {
SwitchPref {
title = Test 1,$i
summary = Test 1,$i
default = if(i % 2 == 0) SimpleSwitchPref.ON otherwise SimpleSwitchPref.OFF
if (true) {
TextPref {
title = Test 2
summary = This is a Test 2
part {
InputPref {
title = Test 3
summary = This is a Test 3

This is especially useful if you need to generate your preferences at runtime. You can use the hinges and conditions as described above.

Pay attention: It is not obligatory to hand over the keys for each preference. In this case, the library automatically generates a key by converting the header of each preference into CamelCase.

Examples :

List Preferences –> list Preference
List Preference –> list Preference
These are user rights –> thisIsACustomPreference
custom –> custom.

Optionally, you can pass the SimpleSettingsConfig object to the builder of your SimpleSettings instance to customize the appearance of the setup activity. The different parameters are listed below.

Delivery of elements with the xml file

You can also specify your preferred screen as a normal xml file:





To create the settings screen in the default configuration, simply call the SimpleSettings show method and send the prepared xml resource file.

SimpleSettings([protected by email])).show(R.xml.preferences)

or (if you need to add preferences, click on Earphones in your preferences)

private fun showPreferences() {
fall config = SimpleSettingsConfig().apply {
showResetOption = true
preferenceCallback = [Email Protection] }
SimpleSettings([Email Protection], config).show(R.xml.preferences)

Overload the fun onPreferenceClick (context: context, button: line) : Preferences. OnPreferenceClickListener? {{{{Preference-> WebsiteClickListener([Email protected], getString(R.string.url_github))custom preference -> Preference.OnPreferenceClickListener {{{{Preference-> WebsiteClickListener([Email protected], getString(R.string.url_github)).


else -> super.onPreferenceClick(context, key)

Obtaining preferential values

Simultaneous search

You can retrieve the preferred values as usual via SharedPreferences, or use the built-in shortcuts provided with the library.
It provides improvement functions for the context class to facilitate access to the preferred values:

val-Wert1 = getPrefStringValue (stringPreference, default)
val-Wert2 = getPrefIntValue (intPreference, 99)
val-Wert3 = getPrefBooleanValue (booleanPreference, true)
val-Wert4 = getPrefFloatValue (floatPreference, 101.6f)
val-Wert5 = getPrefLongValue (longPref, 4834597833234)
val-Wert6 = getPrefStringSetValue (stringSetPreference, setOf(default 1, default 2)).

As you can see, this works for the types String, Int, Boolean, Float, Long, StringSet.

Search as LiveData

In addition, the library offers the possibility to monitor the setting values as LiveData :

getPrefObserver( listpreference, Observer { value ->
textField.text = value

As described above it works for String, Int, Boolean, Float, Long, StringSet types.

Pay attention: The expansion functions are only available for the AppCompatibleActivity class, as the LifecycleOwner is required for making observations.

Library facilities

The library offers various configuration options. To apply these options, you need to pass the SimpleSettingsConfig object to your SimpleSettings instance constructor.

Method Description
setActivityTitle(string) Sets the title of the SettingsActivity toolbar. The default value is Settings, translated into all supported languages.
setActivityTitle (Context, Int) Sets the title of the SettingsActivity toolbar with a string source. The default value is Settings, translated into all supported languages.
displayHomeAsUpEnabled (boolean) Activates or deactivates the arrow symbol in the top left corner of the operating window to return to the call procedure. The default value is correct.
showResetOption (boolean) Enables or disables the menu item options to reset all settings to default values. The default value is wrong.
setPreferenceCallback(context) Sets a reminder to subscribe to a one-click subscription to privileged object events

If you missed the setting option, please let us know by opening the question.

Pre-defined listener clicks

The library offers several predefined clicks to store a large amount of template code. These listening clicks are available:

In-depth access to the project

Consult the wiki if you want to understand the benefits of this library or learn more about certain types of preferences.

Languages supported

Here are the languages currently supported by this library

The new translations are highly appreciated. If you want to translate the library, open pr.


You May Also Like