From 7b6a6321edf7df3a81aa12f8f434727c946c2492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Lapi=C5=A1?= Date: Tue, 28 Dec 2021 13:16:51 +0100 Subject: [PATCH 1/4] next --- README.md | 4 +-- build.gradle | 4 +-- .../lapism/search/widget/MaterialSearchBar.kt | 22 +++++++------ .../search/widget/MaterialSearchView.kt | 33 ++++++++++--------- .../res/layout/material_search_toolbar.xml | 4 +-- src/main/res/layout/material_search_view.xml | 18 +++++----- src/main/res/values-sw600dp/dimens.xml | 6 ++++ src/main/res/values/attrs.xml | 7 ++-- src/main/res/values/dimens.xml | 1 - src/main/res/values/styles.xml | 13 ++++++++ 10 files changed, 67 insertions(+), 45 deletions(-) create mode 100755 src/main/res/values-sw600dp/dimens.xml create mode 100644 src/main/res/values/styles.xml diff --git a/README.md b/README.md index 87d6f5b5..6f9ecd16 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![API](https://img.shields.io/badge/API-26%2B-brightgreen.svg?style=flat) -[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.6.0-blue.svg)](https://kotlinlang.org) +[![Kotlin Version](https://img.shields.io/badge/Kotlin-blue.svg)](https://kotlinlang.org) [![Download](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fio%2Fgithub%2Flapism%2Fsearch%2Fmaven-metadata.xml) ](https://repo1.maven.org/maven2/io/github/lapism/search/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) @@ -29,7 +29,7 @@ Add the dependency to your gradle file: } dependencies { - implementation 'io.github.lapism:search:1.1.0' + implementation 'io.github.lapism:search:1.2.0' } ``` diff --git a/build.gradle b/build.gradle index 6958c8f2..3d4912e2 100755 --- a/build.gradle +++ b/build.gradle @@ -43,10 +43,8 @@ android { dependencies { - // Core - implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.4.0' - implementation 'com.google.android.material:material:1.5.0-beta01' + implementation 'com.google.android.material:material:1.6.0-alpha01' } ext { diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt index dd86d2ed..a644f21d 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt @@ -60,12 +60,13 @@ class MaterialSearchBar @JvmOverloads constructor( setBackgroundColor(color!!) } - val defaultRadius = context.resources.getDimensionPixelSize(R.dimen.search_dp_24) - val customRadius = a?.getInt(R.styleable.MaterialSearchBar_search_radius, defaultRadius) - setRadius(customRadius?.toFloat()!!) + if (a?.hasValue(R.styleable.MaterialSearchBar_search_radius)!!) { + val customRadius = a?.getInt(R.styleable.MaterialSearchBar_search_radius, 0) + setRadius(customRadius?.toFloat()!!) + } - if (a?.hasValue(R.styleable.MaterialSearchBar_android_elevation)!!) { - val customElevation = a?.getInt(R.styleable.MaterialSearchBar_android_elevation, 0) + if (a?.hasValue(R.styleable.MaterialSearchBar_search_elevation)!!) { + val customElevation = a?.getInt(R.styleable.MaterialSearchBar_search_elevation, 0) elevation = customElevation?.toFloat()!! } @@ -101,10 +102,6 @@ class MaterialSearchBar @JvmOverloads constructor( binding.searchBarCard.setCardBackgroundColor(color) } - override fun setOnClickListener(@Nullable l: OnClickListener?) { - binding.searchBarToolbar.setOnClickListener(l) - } - override fun setElevation(elevation: Float) { binding.searchBarCard.cardElevation = elevation } @@ -113,6 +110,10 @@ class MaterialSearchBar @JvmOverloads constructor( return binding.searchBarCard.elevation } + override fun setOnClickListener(@Nullable l: OnClickListener?) { + binding.searchBarToolbar.setOnClickListener(l) + } + override fun onAttachedToWindow() { super.onAttachedToWindow() @@ -173,7 +174,7 @@ class MaterialSearchBar @JvmOverloads constructor( } // ********************************************************************************************* - // TODO PUBLIC ? and requestLayout() + // TODO set public and requestLayout(), invalidate() private fun setMargins(left: Int, top: Int, right: Int, bottom: Int) { if (binding.searchBarCard.layoutParams is MarginLayoutParams) { val params = binding.searchBarCard.layoutParams as? MarginLayoutParams @@ -200,6 +201,7 @@ class MaterialSearchBar @JvmOverloads constructor( dependency.setBackgroundColor(Color.TRANSPARENT) dependency.stateListAnimator = null ViewCompat.setElevation(dependency, 0.0f) + return true } return false } diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt index b6d00828..919a0563 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt @@ -55,7 +55,7 @@ class MaterialSearchView @JvmOverloads constructor( }) binding.searchViewEditText.setOnEditorActionListener { _, _, _ -> onSubmitQuery() - return@setOnEditorActionListener true // same as ,,true" :) + true } binding.searchViewEditText.setOnFocusChangeListener { _, hasFocus -> visibility = if (hasFocus) { @@ -109,6 +109,8 @@ class MaterialSearchView @JvmOverloads constructor( setBackgroundColor(color) } + // TODO TOOLBAR COLOR + if (a.hasValue(R.styleable.MaterialSearchView_search_clearIcon)) { setClearIcon(a.getDrawable(R.styleable.MaterialSearchView_search_clearIcon)) } else { @@ -133,6 +135,10 @@ class MaterialSearchView @JvmOverloads constructor( ) } + if (a.hasValue(R.styleable.MaterialSearchView_android_elevation)) { + val customElevation = a.getDimensionPixelSize(R.styleable.MaterialSearchView_android_elevation, 0) + } + if (a.hasValue(R.styleable.MaterialSearchView_android_hint)) { val hint = a.getString(R.styleable.MaterialSearchView_android_hint) setHint(hint) @@ -153,15 +159,6 @@ class MaterialSearchView @JvmOverloads constructor( visibility = View.GONE } - /* TODO styles + codes, ANIMATE binding.searchViewClip.path, SCALE, path - private fun setTransition() { - val mTransition = LayoutTransition() - mTransition.enableTransitionType(LayoutTransition.CHANGING) - mTransition.setDuration(3000L) - - binding.searchViewBackground.layoutTransition = mTransition - }*/ - // ********************************************************************************************* override fun setNavigationIcon(@DrawableRes resId: Int) { binding.searchViewToolbar.setNavigationIcon(resId) @@ -225,6 +222,10 @@ class MaterialSearchView @JvmOverloads constructor( } // ********************************************************************************************* + fun setNavigationBackgroundColor(@ColorInt color: Int) { + binding.searchViewToolbar.setBackgroundColor(color) + } + fun setClearIcon(@Nullable drawable: Drawable?) { binding.searchViewClearButton.setImageDrawable(drawable) } @@ -261,9 +262,7 @@ class MaterialSearchView @JvmOverloads constructor( private fun onSubmitQuery() { val query = binding.searchViewEditText.text if (query != null && TextUtils.getTrimmedLength(query) > 0) { - if (queryListener == null || !queryListener!!.onQueryTextSubmit(query.toString())) { - hideKeyboard() - } + queryListener?.onQueryTextSubmit(query.toString()) } } @@ -279,6 +278,10 @@ class MaterialSearchView @JvmOverloads constructor( binding.searchViewDivider.setBackgroundColor(color) } + fun setDividerResource(@DrawableRes resid: Int) { + binding.searchViewDivider.setBackgroundResource(resid) + } + fun setScrimColor(@ColorInt color: Int) { binding.searchViewScrim.setBackgroundColor(color) } @@ -340,9 +343,9 @@ class MaterialSearchView @JvmOverloads constructor( interface OnQueryTextListener { - fun onQueryTextChange(newText: CharSequence): Boolean + fun onQueryTextChange(newText: CharSequence) - fun onQueryTextSubmit(query: CharSequence): Boolean + fun onQueryTextSubmit(query: CharSequence) } // ********************************************************************************************* diff --git a/src/main/res/layout/material_search_toolbar.xml b/src/main/res/layout/material_search_toolbar.xml index 8538bc0a..70cc1956 100755 --- a/src/main/res/layout/material_search_toolbar.xml +++ b/src/main/res/layout/material_search_toolbar.xml @@ -1,9 +1,9 @@ \ No newline at end of file + android:maxLines="1" /> \ No newline at end of file diff --git a/src/main/res/layout/material_search_view.xml b/src/main/res/layout/material_search_view.xml index 6ee8a075..9f1e2d33 100755 --- a/src/main/res/layout/material_search_view.xml +++ b/src/main/res/layout/material_search_view.xml @@ -1,6 +1,5 @@ - + - + android:background="?attr/colorSurface"> + android:textDirection="firstStrong" /> - + diff --git a/src/main/res/values-sw600dp/dimens.xml b/src/main/res/values-sw600dp/dimens.xml new file mode 100755 index 00000000..2298d476 --- /dev/null +++ b/src/main/res/values-sw600dp/dimens.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index eb9c52c0..20ca3f37 100755 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -10,8 +10,9 @@ - - + + + @@ -27,6 +28,8 @@ + + diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml index 95a44343..eba2789e 100755 --- a/src/main/res/values/dimens.xml +++ b/src/main/res/values/dimens.xml @@ -6,7 +6,6 @@ 4dp 8dp 16dp - 24dp 48dp 16sp diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml new file mode 100644 index 00000000..416c3ad4 --- /dev/null +++ b/src/main/res/values/styles.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file From 6162d32a71001dce9e500645497e3517d4042591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Lapi=C5=A1?= Date: Wed, 29 Dec 2021 18:32:12 +0100 Subject: [PATCH 2/4] Fixes --- README.md | 9 +++--- .../lapism/search/widget/MaterialSearchBar.kt | 28 ++++++++--------- .../search/widget/MaterialSearchLayout.kt | 5 +++ .../search/widget/MaterialSearchToolbar.kt | 3 +- .../search/widget/MaterialSearchView.kt | 31 ++++++++++++------- .../widget/MaterialTransparentToolbar.kt | 31 +++++++++++++++++++ src/main/res/layout/material_search_view.xml | 8 ++--- src/main/res/values-sw600dp/dimens.xml | 6 ---- src/main/res/values/attrs.xml | 10 +++--- src/main/res/values/public.xml | 3 +- 10 files changed, 85 insertions(+), 49 deletions(-) create mode 100755 src/main/kotlin/com/lapism/search/widget/MaterialTransparentToolbar.kt delete mode 100755 src/main/res/values-sw600dp/dimens.xml diff --git a/README.md b/README.md index 6f9ecd16..126fea46 100755 --- a/README.md +++ b/README.md @@ -154,9 +154,9 @@ You have to use app theme Theme.Material3.* or Theme.MaterialComponents.*. - - - + + + @@ -168,7 +168,8 @@ You have to use app theme Theme.Material3.* or Theme.MaterialComponents.*. - + + diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt index a644f21d..30cbe8f7 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt @@ -55,9 +55,9 @@ class MaterialSearchBar @JvmOverloads constructor( setNavigationContentDescription(description) } - if (a?.hasValue(R.styleable.MaterialSearchBar_search_backgroundColor)!!) { - val color = a?.getInt(R.styleable.MaterialSearchBar_search_backgroundColor, 0) - setBackgroundColor(color!!) + if (a?.hasValue(R.styleable.MaterialSearchBar_search_navigationBackgroundColor)!!) { + val color = a?.getInt(R.styleable.MaterialSearchBar_search_navigationBackgroundColor, 0) + setNavigationBackgroundColor(color!!) } if (a?.hasValue(R.styleable.MaterialSearchBar_search_radius)!!) { @@ -65,9 +65,13 @@ class MaterialSearchBar @JvmOverloads constructor( setRadius(customRadius?.toFloat()!!) } - if (a?.hasValue(R.styleable.MaterialSearchBar_search_elevation)!!) { - val customElevation = a?.getInt(R.styleable.MaterialSearchBar_search_elevation, 0) - elevation = customElevation?.toFloat()!! + if (a?.hasValue(R.styleable.MaterialSearchBar_search_navigationElevation)!!) { + val navigationElevation = + a?.getDimensionPixelSize( + R.styleable.MaterialSearchBar_search_navigationElevation, + 0 + ) + setNavigationElevation(navigationElevation?.toFloat()!!) } if (a?.hasValue(R.styleable.MaterialSearchBar_android_hint)!!) { @@ -97,19 +101,15 @@ class MaterialSearchBar @JvmOverloads constructor( binding.searchBarToolbar.setNavigationOnClickListener(listener) } - // ********************************************************************************************* - override fun setBackgroundColor(@ColorInt color: Int) { - binding.searchBarCard.setCardBackgroundColor(color) - } - - override fun setElevation(elevation: Float) { + override fun setNavigationElevation(elevation: Float) { binding.searchBarCard.cardElevation = elevation } - override fun getElevation(): Float { - return binding.searchBarCard.elevation + override fun setNavigationBackgroundColor(@ColorInt color: Int) { + binding.searchBarCard.setCardBackgroundColor(color) } + // ********************************************************************************************* override fun setOnClickListener(@Nullable l: OnClickListener?) { binding.searchBarToolbar.setOnClickListener(l) } diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt index ec64593e..823803ac 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt @@ -4,6 +4,7 @@ import android.content.Context import android.graphics.drawable.Drawable import android.util.AttributeSet import android.widget.FrameLayout +import androidx.annotation.ColorInt import androidx.annotation.DrawableRes import androidx.annotation.Nullable import androidx.annotation.StringRes @@ -59,4 +60,8 @@ abstract class MaterialSearchLayout @JvmOverloads constructor( abstract fun setNavigationOnClickListener(listener: OnClickListener) + abstract fun setNavigationElevation(elevation: Float) + + abstract fun setNavigationBackgroundColor(@ColorInt color: Int) + } \ No newline at end of file diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt index 55becad9..2d8075b3 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt @@ -8,11 +8,10 @@ import android.view.LayoutInflater import android.view.accessibility.AccessibilityNodeInfo import android.widget.TextView import androidx.annotation.Nullable -import com.google.android.material.appbar.MaterialToolbar import com.lapism.search.databinding.MaterialSearchToolbarBinding -class MaterialSearchToolbar : MaterialToolbar { +class MaterialSearchToolbar : MaterialTransparentToolbar { // ********************************************************************************************* private var binding: MaterialSearchToolbarBinding diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt index 919a0563..ef2aa559 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt @@ -104,13 +104,11 @@ class MaterialSearchView @JvmOverloads constructor( setNavigationContentDescription(description) } - if (a.hasValue(R.styleable.MaterialSearchView_search_backgroundColor)) { - val color = a.getInt(R.styleable.MaterialSearchView_search_backgroundColor, 0) - setBackgroundColor(color) + if (a.hasValue(R.styleable.MaterialSearchBar_search_navigationBackgroundColor)) { + val color = a.getInt(R.styleable.MaterialSearchBar_search_navigationBackgroundColor, 0) + setNavigationBackgroundColor(color) } - // TODO TOOLBAR COLOR - if (a.hasValue(R.styleable.MaterialSearchView_search_clearIcon)) { setClearIcon(a.getDrawable(R.styleable.MaterialSearchView_search_clearIcon)) } else { @@ -135,8 +133,13 @@ class MaterialSearchView @JvmOverloads constructor( ) } - if (a.hasValue(R.styleable.MaterialSearchView_android_elevation)) { - val customElevation = a.getDimensionPixelSize(R.styleable.MaterialSearchView_android_elevation, 0) + if (a.hasValue(R.styleable.MaterialSearchView_search_navigationElevation)) { + val navigationElevation = + a.getDimensionPixelSize( + R.styleable.MaterialSearchView_search_navigationElevation, + 0 + ) + setNavigationElevation(navigationElevation.toFloat()) } if (a.hasValue(R.styleable.MaterialSearchView_android_hint)) { @@ -180,9 +183,17 @@ class MaterialSearchView @JvmOverloads constructor( binding.searchViewToolbar.setNavigationOnClickListener(listener) } + override fun setNavigationElevation(elevation: Float) { + binding.searchViewToolbar.elevation = elevation + } + + override fun setNavigationBackgroundColor(@ColorInt color: Int) { + binding.searchViewToolbar.setBackgroundColor(color) + } + // ********************************************************************************************* override fun setBackgroundColor(@ColorInt color: Int) { - binding.searchViewBackground.setBackgroundColor(color) + binding.searchViewContentContainer.setBackgroundColor(color) } override fun addView(child: View) { @@ -222,10 +233,6 @@ class MaterialSearchView @JvmOverloads constructor( } // ********************************************************************************************* - fun setNavigationBackgroundColor(@ColorInt color: Int) { - binding.searchViewToolbar.setBackgroundColor(color) - } - fun setClearIcon(@Nullable drawable: Drawable?) { binding.searchViewClearButton.setImageDrawable(drawable) } diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialTransparentToolbar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialTransparentToolbar.kt new file mode 100755 index 00000000..51a337fc --- /dev/null +++ b/src/main/kotlin/com/lapism/search/widget/MaterialTransparentToolbar.kt @@ -0,0 +1,31 @@ +package com.lapism.search.widget + +import android.content.Context +import android.os.Build +import android.util.AttributeSet +import androidx.core.content.ContextCompat +import com.google.android.material.appbar.MaterialToolbar + + +open class MaterialTransparentToolbar : MaterialToolbar { + + // ********************************************************************************************* + constructor(context: Context) : super(context) + + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) + + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) + + // ********************************************************************************************* + init { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + outlineAmbientShadowColor = ContextCompat.getColor(context, android.R.color.transparent) + outlineSpotShadowColor = ContextCompat.getColor(context, android.R.color.transparent) + } + } + +} \ No newline at end of file diff --git a/src/main/res/layout/material_search_view.xml b/src/main/res/layout/material_search_view.xml index 9f1e2d33..b5096f96 100755 --- a/src/main/res/layout/material_search_view.xml +++ b/src/main/res/layout/material_search_view.xml @@ -21,11 +21,10 @@ android:layout_height="match_parent" android:background="?attr/colorSurface"> - - + + android:layout_height="match_parent" + android:background="?attr/colorSurface" /> diff --git a/src/main/res/values-sw600dp/dimens.xml b/src/main/res/values-sw600dp/dimens.xml deleted file mode 100755 index 2298d476..00000000 --- a/src/main/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index 20ca3f37..4517c663 100755 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -9,10 +9,9 @@ - + + - - @@ -24,12 +23,11 @@ - + + - - diff --git a/src/main/res/values/public.xml b/src/main/res/values/public.xml index b8a443c7..aed10816 100755 --- a/src/main/res/values/public.xml +++ b/src/main/res/values/public.xml @@ -4,7 +4,8 @@ - + + From 83730b70b1be4d1efbd7c790663c43ad1dda4610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Lapi=C5=A1?= Date: Wed, 29 Dec 2021 18:37:59 +0100 Subject: [PATCH 3/4] Fixes --- .../lapism/search/widget/MaterialSearchBar.kt | 10 +++++----- .../lapism/search/widget/MaterialSearchView.kt | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt index 30cbe8f7..b3f66e4a 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt @@ -60,11 +60,6 @@ class MaterialSearchBar @JvmOverloads constructor( setNavigationBackgroundColor(color!!) } - if (a?.hasValue(R.styleable.MaterialSearchBar_search_radius)!!) { - val customRadius = a?.getInt(R.styleable.MaterialSearchBar_search_radius, 0) - setRadius(customRadius?.toFloat()!!) - } - if (a?.hasValue(R.styleable.MaterialSearchBar_search_navigationElevation)!!) { val navigationElevation = a?.getDimensionPixelSize( @@ -74,6 +69,11 @@ class MaterialSearchBar @JvmOverloads constructor( setNavigationElevation(navigationElevation?.toFloat()!!) } + if (a?.hasValue(R.styleable.MaterialSearchBar_search_radius)!!) { + val customRadius = a?.getInt(R.styleable.MaterialSearchBar_search_radius, 0) + setRadius(customRadius?.toFloat()!!) + } + if (a?.hasValue(R.styleable.MaterialSearchBar_android_hint)!!) { val hint = a?.getString(R.styleable.MaterialSearchBar_android_hint) setHint(hint) diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt index ef2aa559..986240e2 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt @@ -109,6 +109,15 @@ class MaterialSearchView @JvmOverloads constructor( setNavigationBackgroundColor(color) } + if (a.hasValue(R.styleable.MaterialSearchView_search_navigationElevation)) { + val navigationElevation = + a.getDimensionPixelSize( + R.styleable.MaterialSearchView_search_navigationElevation, + 0 + ) + setNavigationElevation(navigationElevation.toFloat()) + } + if (a.hasValue(R.styleable.MaterialSearchView_search_clearIcon)) { setClearIcon(a.getDrawable(R.styleable.MaterialSearchView_search_clearIcon)) } else { @@ -133,15 +142,6 @@ class MaterialSearchView @JvmOverloads constructor( ) } - if (a.hasValue(R.styleable.MaterialSearchView_search_navigationElevation)) { - val navigationElevation = - a.getDimensionPixelSize( - R.styleable.MaterialSearchView_search_navigationElevation, - 0 - ) - setNavigationElevation(navigationElevation.toFloat()) - } - if (a.hasValue(R.styleable.MaterialSearchView_android_hint)) { val hint = a.getString(R.styleable.MaterialSearchView_android_hint) setHint(hint) From ed2e26290133bba76f5435bf1ba073447a8ac3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Lapi=C5=A1?= Date: Wed, 29 Dec 2021 18:51:06 +0100 Subject: [PATCH 4/4] Fixes --- src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt index b3f66e4a..e5f658a7 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt @@ -196,14 +196,12 @@ class MaterialSearchBar @JvmOverloads constructor( child: View, dependency: View ): Boolean { - super.onDependentViewChanged(parent, child, dependency) if (dependency is AppBarLayout) { dependency.setBackgroundColor(Color.TRANSPARENT) dependency.stateListAnimator = null ViewCompat.setElevation(dependency, 0.0f) - return true } - return false + return super.onDependentViewChanged(parent, child, dependency) } }