aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sample/src/main')
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt15
-rw-r--r--sample/src/main/res/values/strings.xml2
2 files changed, 7 insertions, 10 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index db42f9b..914fff8 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -14,27 +14,24 @@ import ca.allanwang.kau.views.RippleCanvas
class MainActivity : KPrefActivity() {
override fun onCreateKPrefs(savedInstanceState: android.os.Bundle?): KPrefAdapterBuilder.() -> Unit = {
- textColorGetter = { KPrefSample.textColor }
- accentColorGetter = { KPrefSample.accentColor }
+ textColor = { KPrefSample.textColor }
+ accentColor = { KPrefSample.accentColor }
header(R.string.header)
checkbox(title = R.string.checkbox_1, description = R.string.desc,
getter = { KPrefSample.check1 }, setter = { KPrefSample.check1 = it })
checkbox(title = R.string.checkbox_2,
- getter = { KPrefSample.check2 }, setter = { KPrefSample.check2 = it })
- checkbox(title = R.string.checkbox_3, description = R.string.desc_disabled, enabled = false,
+ getter = { KPrefSample.check2 }, setter = { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) })
+ checkbox(title = R.string.checkbox_3, description = R.string.desc_dependent, enabler = { KPrefSample.check2 },
getter = { KPrefSample.check3 }, setter = { KPrefSample.check3 = it })
colorPicker(title = R.string.text_color, description = R.string.color_custom,
- getter = { KPrefSample.textColor }, setter = {
- KPrefSample.textColor = it
- adapter.notifyAdapterDataSetChanged()
- },
+ getter = { KPrefSample.textColor }, setter = { KPrefSample.textColor = it; reload() },
configs = {
allowCustom = true
})
colorPicker(title = R.string.accent_color, description = R.string.color_no_custom,
getter = { KPrefSample.accentColor }, setter = {
KPrefSample.accentColor = it
- adapter.notifyAdapterDataSetChanged()
+ reload()
val darkerColor = it.darken()
this@MainActivity.navigationBarColor = darkerColor
toolbarCanvas.ripple(darkerColor, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500)
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 1246baf..56addfd 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -6,7 +6,7 @@
<string name="checkbox_1">Checkbox 1</string>
<string name="checkbox_2">Checkbox 2</string>
<string name="checkbox_3">Checkbox 3</string>
- <string name="desc_disabled">I am disabled</string>
+ <string name="desc_dependent">I am dependent on checkbox 2</string>
<string name="text_color">Text Color</string>
<string name="accent_color">Accent Color</string>
<string name="background_color">Background Color</string>