diff options
Diffstat (limited to 'sample')
4 files changed, 28 insertions, 17 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 9adabed..0c243e4 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt @@ -17,4 +17,7 @@ object KPrefSample : KPref() { var check3: Boolean by kpref("check3", false) var text: String by kpref("text", "empty") var seekbar: Int by kpref("seekbar", 20) + var time12: Int by kpref("time_12", 315) + var time24: Int by kpref("time_24", 2220) + }
\ 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 1528970..ca75ebb 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -107,8 +107,7 @@ class MainActivity : KPrefActivity() { checkbox(R.string.checkbox_3, { KPrefSample.check3 }, { KPrefSample.check3 = it }) { descRes = R.string.desc_dependent enabler = { KPrefSample.check2 } - onDisabledClick = { - itemView, _, _ -> + onDisabledClick = { itemView, _, _ -> itemView.context.toast("I am still disabled") true } @@ -140,8 +139,7 @@ class MainActivity : KPrefActivity() { text(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) { descRes = R.string.text_desc - onClick = { - itemView, _, item -> + onClick = { itemView, _, item -> itemView.context.materialDialog { title("Type Text") input("Type here", item.pref, { _, input -> item.pref = input.toString() }) @@ -193,17 +191,25 @@ class MainActivity : KPrefActivity() { textGetter = { string(R.string.kau_lorem_ipsum) } } + timePicker(R.string.time, { KPrefSample.time12 }, { KPrefSample.time12 = it }) { + descRes = R.string.time_desc_12 + use24HourFormat = false + } + + timePicker(R.string.time, { KPrefSample.time24 }, { KPrefSample.time24 = it }) { + descRes = R.string.time_desc_24 + use24HourFormat = true + } + } fun subPrefs(): KPrefAdapterBuilder.() -> Unit = { text(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) { descRes = R.string.text_desc - onClick = { - itemView, _, item -> + onClick = { itemView, _, item -> itemView.context.materialDialog { title("Type Text") - input("Type here", item.pref, { - _, input -> + input("Type here", item.pref, { _, input -> item.pref = input.toString() reloadSelf() }) @@ -237,21 +243,18 @@ class MainActivity : KPrefActivity() { menuInflater.inflate(R.menu.menu_main, menu) if (searchView == null) searchView = bindSearchView(menu, R.id.action_search) { - textCallback = { - query, searchView -> + textCallback = { query, searchView -> val items = wordBank.filter { it.contains(query) }.sorted().map { SearchItem(it) } searchView.results = items } - searchCallback = { - query, _ -> + searchCallback = { query, _ -> toast("Enter pressed for $query") true } textDebounceInterval = 0 noResultsFound = R.string.kau_no_results_found shouldClearOnClose = false - onItemClick = { - _, _, content, searchView -> + onItemClick = { _, _, content, searchView -> toast(content) searchView.revealClose() } diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index a887ad3..1e3361e 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -15,6 +15,9 @@ <string name="text">Text Pref</string> <string name="text_desc">Saves the text</string> <string name="seekbar">Seekbar</string> + <string name="time">Time Pref</string> + <string name="time_desc_12">AM PM version</string> + <string name="time_desc_24">24h version</string> <string name="sub_item">Sub Item Pref</string> <string name="sub_item_desc">Press this to view the next subset of preferences</string> <string name="your_email">your.email@here.com</string> diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index 8476660..7f421f8 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -6,9 +6,11 @@ <item text="" /> --> - <version title="v3.4.1"/> - <item text="Validate context before showing dialogs" /> - <item text="Add intent resolver checks prior to all executions." /> + <version title="v3.4.3"/> + <item text=":core: Validate context before showing dialogs" /> + <item text=":core: Add intent resolver checks prior to all executions." /> + <item text=":core: Fix bundle NPE when starting activity" /> + <item text=":kpref-activity: Create timePicker" /> <item text="" /> <item text="" /> <item text="" /> |