diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-14 16:09:43 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-14 16:09:43 -0700 |
commit | 90e61e0fef26b7134cdda1b97f1a358d7496c4ec (patch) | |
tree | 4a446cb56f80db8f382a9cec38f1da66ebe95901 /sample/src/main/kotlin/ca/allanwang | |
parent | 7edb081d0e808982ba0d5c5d2a0021aa1befcd8c (diff) | |
download | kau-90e61e0fef26b7134cdda1b97f1a358d7496c4ec.tar.gz kau-90e61e0fef26b7134cdda1b97f1a358d7496c4ec.tar.bz2 kau-90e61e0fef26b7134cdda1b97f1a358d7496c4ec.zip |
Add text pref with example
Diffstat (limited to 'sample/src/main/kotlin/ca/allanwang')
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt | 1 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 28 |
2 files changed, 24 insertions, 5 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt index 96c7c71..a0fbc59 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt @@ -14,4 +14,5 @@ object KPrefSample : KPref() { var check1: Boolean by kpref("check1", true) var check2: Boolean by kpref("check2", false) var check3: Boolean by kpref("check3", false) + var text: String by kpref("text", "empty") }
\ No newline at end of file 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 4efd9f1..b8ba393 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -5,10 +5,7 @@ import android.view.Menu import android.view.MenuItem import ca.allanwang.kau.kpref.KPrefActivity import ca.allanwang.kau.kpref.KPrefAdapterBuilder -import ca.allanwang.kau.utils.darken -import ca.allanwang.kau.utils.navigationBarColor -import ca.allanwang.kau.utils.startActivitySlideIn -import ca.allanwang.kau.utils.toast +import ca.allanwang.kau.utils.* import ca.allanwang.kau.views.RippleCanvas import com.mikepenz.google_material_typeface_library.GoogleMaterial @@ -30,7 +27,7 @@ class MainActivity : KPrefActivity() { checkbox(title = R.string.checkbox_2, itemBuilder = { getter = { KPrefSample.check2 } - setter = { KPrefSample.check2 = it; reload(3) } + setter = { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) } }) checkbox(title = R.string.checkbox_3, coreBuilder = { @@ -80,6 +77,27 @@ class MainActivity : KPrefActivity() { 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) + build() + }.show() + true + } + }) } override fun onCreate(savedInstanceState: Bundle?) { |