aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-17 12:15:08 -0700
committerAllan Wang <me@allanwang.ca>2017-06-17 12:15:08 -0700
commit9e98acc68b7a43cdc0f32bb8c98736ce631d9eae (patch)
tree5c11d59d47627be522996a9d182ef713a55fd0c7 /README.md
parenta9096748fa49c2f8c3cec0de017058114d5ae626 (diff)
downloadkau-9e98acc68b7a43cdc0f32bb8c98736ce631d9eae.tar.gz
kau-9e98acc68b7a43cdc0f32bb8c98736ce631d9eae.tar.bz2
kau-9e98acc68b7a43cdc0f32bb8c98736ce631d9eae.zip
Add more readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 35 insertions, 3 deletions
diff --git a/README.md b/README.md
index 91eca7d..4882f59 100644
--- a/README.md
+++ b/README.md
@@ -92,8 +92,8 @@ The easiest way to create the settings is to extend `KPrefActivity`.
We will then override `onCreateKPrefs` to generate our adapter builder.
-The adapter builder implements `CoreAttributeContract` that will be added to every kpref item.
-Each item also extends a bunch of other contracts that allow for mandatory arguments and optional configurations.
+The adapter builder can easily add items using defined functions.
+Each item added extends one or more contracts to configure it.
The contracts are as follows:
@@ -112,8 +112,40 @@ Item | Implements | Description
`checkbox` | `CoreContract` `BaseContract` | Checkbox item; by default, clicking it will toggle the checkbox and the kpref
`colorPicker` | `CoreContract` `BaseContract` `KPrefColorContract` | Color picker item; by default, clicking it will open a dialog which will change the color (int)
`header` | `CoreContract` | Header; just a title that isn't clickable
- `text` | `CoreContract` `BaseContract` `KPrefTextContract` | Text item; displays the kpref as a String on the right; does not have click implementation by default
+`text` | `CoreContract` `BaseContract` `KPrefTextContract` | Text item; displays the kpref as a String on the right; does not have click implementation by default
+An example of the adapter builder:
+
+```kotlin
+override fun onCreateKPrefs(savedInstanceState: android.os.Bundle?): KPrefAdapterBuilder.() -> Unit = {
+
+ textColor = { KPrefSample.textColor }
+ accentColor = { KPrefSample.accentColor }
+
+ header(R.string.header)
+
+ /**
+ * This is how the setup looks like with all the proper tags
+ */
+ checkbox(title = R.string.checkbox_1, getter = { KPrefSample.check1 }, setter = { KPrefSample.check1 = it },
+ builder = {
+ descRes = R.string.desc
+ })
+
+ /**
+ * This is how it looks like without the tags
+ */
+ checkbox(R.string.checkbox_3, { KPrefSample.check3 }, { KPrefSample.check3 = it }) {
+ descRes = R.string.desc_dependent
+ enabler = { KPrefSample.check2 }
+ onDisabledClick = {
+ itemView, _, _ ->
+ itemView.context.toast("I am still disabled")
+ true
+ }
+ }
+}
+```
<a name="changelog"></a>
## Changelog XML