diff options
Diffstat (limited to 'sample')
-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 | ||||
-rw-r--r-- | sample/src/main/res/values/strings.xml | 2 |
3 files changed, 26 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?) { diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index 56addfd..7399593 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -13,4 +13,6 @@ <string name="color_custom">This selector allows custom colors</string> <string name="color_no_custom">This selector does not allow custom colors</string> <string name="color_custom_alpha">This selector allows for custom colors with alpha values</string> + <string name="text">Text Pref</string> + <string name="text_desc">Saves the text</string> </resources> |