diff options
Diffstat (limited to 'sample/src')
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 154 | ||||
-rw-r--r-- | sample/src/main/res/xml/changelog.xml | 2 |
2 files changed, 76 insertions, 80 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 544f349..7c6412a 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -18,85 +18,81 @@ class MainActivity : KPrefActivity() { header(R.string.header) - checkbox(title = R.string.checkbox_1, coreBuilder = { - description = R.string.desc - }, itemBuilder = { - getter = { KPrefSample.check1 } - setter = { KPrefSample.check1 = it } - }) - - checkbox(title = R.string.checkbox_2, itemBuilder = { - getter = { KPrefSample.check2 } - setter = { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) } - }) - - checkbox(title = R.string.checkbox_3, coreBuilder = { - description = R.string.desc_dependent - }, itemBuilder = { - enabler = { KPrefSample.check2 } - getter = { KPrefSample.check3 } - setter = { KPrefSample.check3 = it } - onDisabledClick = { - itemView, _, _ -> - itemView.context.toast("I am still disabled") - true - } - }) - - colorPicker(title = R.string.text_color, coreBuilder = { - description = R.string.color_custom - }, itemBuilder = { - getter = { KPrefSample.textColor } - setter = { KPrefSample.textColor = it; reload() } - }, colorBuilder = { - allowCustom = true - }) - - colorPicker(title = R.string.accent_color, coreBuilder = { - description = R.string.color_no_custom - }, itemBuilder = { - getter = { KPrefSample.accentColor } - setter = { - KPrefSample.accentColor = it - reload() - val darkerColor = it.darken() - this@MainActivity.navigationBarColor = darkerColor - toolbarCanvas.ripple(darkerColor, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) - } - }, colorBuilder = { - allowCustom = false - }) - - colorPicker(title = R.string.background_color, coreBuilder = { - iicon = GoogleMaterial.Icon.gmd_colorize - description = R.string.color_custom_alpha - }, itemBuilder = { - getter = { KPrefSample.bgColor } - setter = { KPrefSample.bgColor = it; bgCanvas.ripple(it, duration = 500L) } - }, colorBuilder = { - allowCustomAlpha = true - allowCustom = true - }) - - text<String>(title = R.string.text, coreBuilder = { - description = R.string.text_desc - }, itemBuilder = { - getter = { KPrefSample.text } - setter = { KPrefSample.text = it } - onClick = { - itemView, _, item -> - itemView.context.materialDialog { - title("Type Text") - input("Type here", item.pref, { - _, input -> - item.pref = input.toString() - reloadByTitle(R.string.text) - }) - inputRange(0, 20) - } - true - } - }) + checkbox(title = R.string.checkbox_1, + getter = { KPrefSample.check1 }, + setter = { KPrefSample.check1 = it }, + builder = { + descRes = R.string.desc + }) + + checkbox(title = R.string.checkbox_2, + getter = { KPrefSample.check2 }, + setter = { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) }) + + checkbox(title = R.string.checkbox_3, + getter = { KPrefSample.check3 }, + setter = { KPrefSample.check3 = it }, + builder = { + descRes = R.string.desc_dependent + enabler = { KPrefSample.check2 } + onDisabledClick = { + itemView, _, _ -> + itemView.context.toast("I am still disabled") + true + } + }) + + colorPicker(title = R.string.text_color, + getter = { KPrefSample.textColor }, + setter = { KPrefSample.textColor = it; reload() }, + builder = { + descRes = R.string.color_custom + allowCustom = true + }) + + colorPicker(title = R.string.accent_color, + getter = { KPrefSample.accentColor }, + setter = { + KPrefSample.accentColor = it + reload() + val darkerColor = it.darken() + this@MainActivity.navigationBarColor = darkerColor + toolbarCanvas.ripple(darkerColor, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) + }, + builder = { + descRes = R.string.color_no_custom + allowCustom = false + }) + + colorPicker(title = R.string.background_color, + getter = { KPrefSample.bgColor }, + setter = { KPrefSample.bgColor = it; bgCanvas.ripple(it, duration = 500L) }, + builder = { + iicon = GoogleMaterial.Icon.gmd_colorize + descRes = R.string.color_custom_alpha + allowCustomAlpha = true + allowCustom = true + }) + + text<String>(title = R.string.text, + getter = { KPrefSample.text }, + setter = { KPrefSample.text = it }, + builder = { + descRes = R.string.text_desc + onClick = { + itemView, _, item -> + itemView.context.materialDialog { + title("Type Text") + input("Type here", item.pref, { + _, input -> + item.pref = input.toString() + reloadByTitle(R.string.text) + }) + inputRange(0, 20) + } + true + } + }) } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/sample/src/main/res/xml/changelog.xml b/sample/src/main/res/xml/changelog.xml index 7569fb2..5ded21e 100644 --- a/sample/src/main/res/xml/changelog.xml +++ b/sample/src/main/res/xml/changelog.xml @@ -2,7 +2,7 @@ <resources> <!-- - <version title="v"/> + <version titleRes="v"/> <item text="" /> --> |