diff options
-rw-r--r-- | docs/Changelog.md | 3 | ||||
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt | 8 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 6 | ||||
-rw-r--r-- | sample/src/main/res/xml/changelog.xml | 12 |
4 files changed, 21 insertions, 8 deletions
diff --git a/docs/Changelog.md b/docs/Changelog.md index a7037b4..fe3e1bb 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,10 +1,13 @@ # Changelog +## v1.4 + ## v1.3 * Added kpref subitems * Added DSL markers * Added transition utils and other utils * Added custom searchview with binders +* Added KauBoundedCardView ## v1.2 * Fix title attribute in changelog 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 a0330c5..5936a07 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt @@ -360,11 +360,11 @@ class SearchView @JvmOverloads constructor( * The cardView matches the parent's width, so menuX is correct */ configs.openListener?.invoke(this) + shadow.fadeIn() editText.showKeyboard() card.circularReveal(menuX, menuHalfHeight, duration = configs.revealDuration) { cardTransition() recycler.visible() - shadow.fadeIn() } } @@ -396,7 +396,11 @@ annotation class KauSearch fun Activity.bindSearchView(menu: Menu, @IdRes id: Int, @ColorInt menuIconColor: Int = Color.WHITE, config: SearchView.Configs.() -> Unit = {}): SearchView = findViewById<ViewGroup>(android.R.id.content).bindSearchView(menu, id, menuIconColor, config) - +/** + * Bind searchView to a menu item; call this in [Activity.onCreateOptionsMenu] + * Be wary that if you may reinflate the menu many times (eg through [Activity.invalidateOptionsMenu]), + * it may be worthwhile to hold a reference to the searchview and only bind it if it hasn't been bound before + */ @KauSearch fun ViewGroup.bindSearchView(menu: Menu, @IdRes id: Int, @ColorInt menuIconColor: Int = Color.WHITE, config: SearchView.Configs.() -> Unit = {}): SearchView { val searchView = SearchView(context) 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 4c22c2a..3cd714e 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -20,7 +20,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial class MainActivity : KPrefActivity() { - lateinit var searchView: SearchView + var searchView: SearchView? = null //some of the most common english words for show val wordBank: List<String> by lazy { listOf("the", "name", "of", "very", "to", "through", @@ -178,7 +178,7 @@ class MainActivity : KPrefActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) - searchView = bindSearchView(menu, R.id.action_search) { + if (searchView == null) searchView = bindSearchView(menu, R.id.action_search) { textObserver = { observable, searchView -> /* @@ -213,6 +213,6 @@ class MainActivity : KPrefActivity() { } override fun onBackPressed() { - if (!searchView.onBackPressed()) super.onBackPressed() + if (!(searchView?.onBackPressed() ?: false)) super.onBackPressed() } } diff --git a/sample/src/main/res/xml/changelog.xml b/sample/src/main/res/xml/changelog.xml index d864f74..003ee8b 100644 --- a/sample/src/main/res/xml/changelog.xml +++ b/sample/src/main/res/xml/changelog.xml @@ -6,15 +6,21 @@ <item text="" /> --> + <version title="v1.4"/> + <item text="" /> + <item text="" /> + <item text="" /> + <item text="" /> + <item text="" /> + <item text="" /> + <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="Added KauBoundedCardView" /> - <item text="" /> - <item text="" /> - <item text="" /> <version title="v1.2"/> <item text="Fix title attribute in changelog" /> |