aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-26 15:43:32 -0700
committerAllan Wang <me@allanwang.ca>2017-06-26 15:43:32 -0700
commit600524d548105aa026c0d1900d503bab34c38ce4 (patch)
treec83ff4ba6d35321e5cd98b8effca59656114043e
parentc09b59f09a24d79ff306aea7dd86e6ca2b2c3208 (diff)
downloadkau-600524d548105aa026c0d1900d503bab34c38ce4.tar.gz
kau-600524d548105aa026c0d1900d503bab34c38ce4.tar.bz2
kau-600524d548105aa026c0d1900d503bab34c38ce4.zip
Add back press helper
-rw-r--r--docs/Changelog.md6
-rw-r--r--gradle.properties4
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt14
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt11
-rw-r--r--sample/src/main/res/xml/changelog.xml13
5 files changed, 42 insertions, 6 deletions
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 042f94d..a7037b4 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1,5 +1,11 @@
# Changelog
+## v1.3
+* Added kpref subitems
+* Added DSL markers
+* Added transition utils and other utils
+* Added custom searchview with binders
+
## v1.2
* Fix title attribute in changelog
* Update support libs
diff --git a/gradle.properties b/gradle.properties
index aa9e621..3f64bcf 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -20,8 +20,8 @@ APP_GROUP=ca.allanwang
MIN_SDK=21
TARGET_SDK=26
BUILD_TOOLS=26.0.0
-VERSION_CODE=2
-VERSION_NAME=1.1
+VERSION_CODE=4
+VERSION_NAME=1.3
ANDROID_SUPPORT_LIBS=26.0.0-beta2
MATERIAL_DIALOG=0.9.4.3
diff --git a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
index bfeed52..d7ff634 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
@@ -179,6 +179,7 @@ class SearchView @JvmOverloads constructor(
init {
View.inflate(context, R.layout.kau_search_view, this)
+ z = 99f
iconNav.setSearchIcon(configs.navIcon)
iconClear.setSearchIcon(configs.clearIcon).setOnClickListener {
editText.text.clear()
@@ -186,6 +187,7 @@ class SearchView @JvmOverloads constructor(
tintForeground(configs.foregroundColor)
tintBackground(configs.backgroundColor)
with(recycler) {
+ isNestedScrollingEnabled = false
layoutManager = LinearLayoutManager(context)
addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
@@ -264,6 +266,18 @@ class SearchView @JvmOverloads constructor(
}
/**
+ * Handle a back press event
+ * Returns true if back press is consumed, false otherwise
+ */
+ fun onBackPressed(): Boolean {
+ if (isOpen && menuItem != null) {
+ revealClose()
+ return true
+ }
+ return false
+ }
+
+ /**
* Tint foreground attributes
* This can be done publicly through [configs], which will also save the color
*/
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 51010c0..83523fa 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -9,6 +9,7 @@ import ca.allanwang.kau.kpref.KPrefActivity
import ca.allanwang.kau.kpref.KPrefAdapterBuilder
import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.searchview.SearchItem
+import ca.allanwang.kau.searchview.SearchView
import ca.allanwang.kau.searchview.bindSearchView
import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.navigationBarColor
@@ -20,6 +21,8 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
class MainActivity : KPrefActivity() {
+ lateinit var searchView: SearchView
+
override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = {
textColor = { KPrefSample.textColor }
accentColor = { KPrefSample.accentColor }
@@ -95,6 +98,9 @@ class MainActivity : KPrefActivity() {
subItems(R.string.sub_item, subPrefs()) {
descRes = R.string.sub_item_desc
}
+
+ plainText(R.string.kau_lorem_ipsum)
+
}
fun subPrefs(): KPrefAdapterBuilder.() -> Unit = {
@@ -125,7 +131,7 @@ class MainActivity : KPrefActivity() {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
- container.bindSearchView(menu, R.id.action_search) {
+ searchView = container.bindSearchView(menu, R.id.action_search) {
textObserver = {
observable, searchView ->
observable.subscribe {
@@ -155,4 +161,7 @@ class MainActivity : KPrefActivity() {
return true
}
+ override fun onBackPressed() {
+ if (!searchView.onBackPressed()) super.onBackPressed()
+ }
}
diff --git a/sample/src/main/res/xml/changelog.xml b/sample/src/main/res/xml/changelog.xml
index 76d2563..55ddd34 100644
--- a/sample/src/main/res/xml/changelog.xml
+++ b/sample/src/main/res/xml/changelog.xml
@@ -6,14 +6,21 @@
<item text="" />
-->
+ <version title="v1.3"/>
+ <item text="Added kpref subitems" />
+ <item text="Added DSL markers" />
+ <item text="Added transition utils and other utils" />
+ <item text="Added custom searchview with binders" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+
<version title="v1.2"/>
<item text="Fix title attribute in changelog" />
<item text="Update support libs" />
<item text="Add is app installed utils" />
<item text="Add email builder" />
- <item text="" />
- <item text="" />
- <item text="" />
<version title="v1.1"/>
<item text="Created kpref items" />