diff --git a/src/main/kotlin/com/lapism/search/internal/ClippableRoundedCornerLayout.kt b/src/main/kotlin/com/lapism/search/internal/ClippableRoundedCornerLayout.kt index bd87a3e5..d51f7eec 100755 --- a/src/main/kotlin/com/lapism/search/internal/ClippableRoundedCornerLayout.kt +++ b/src/main/kotlin/com/lapism/search/internal/ClippableRoundedCornerLayout.kt @@ -14,9 +14,11 @@ class ClippableRoundedCornerLayout @JvmOverloads constructor( defStyleRes: Int = 0 ) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) { + // ********************************************************************************************* // TODO CLIP ANIMATION var path: Path? = null + // ********************************************************************************************* override fun dispatchDraw(canvas: Canvas?) { if (path == null) { super.dispatchDraw(canvas) diff --git a/src/main/kotlin/com/lapism/search/internal/FocusEditText.kt b/src/main/kotlin/com/lapism/search/internal/FocusEditText.kt index 13e3a86f..0a957d11 100755 --- a/src/main/kotlin/com/lapism/search/internal/FocusEditText.kt +++ b/src/main/kotlin/com/lapism/search/internal/FocusEditText.kt @@ -12,8 +12,10 @@ class FocusEditText @JvmOverloads constructor( defStyleAttr: Int = 0 ) : AppCompatEditText(context, attrs, defStyleAttr) { + // ********************************************************************************************* private var textClear: Boolean = false + // ********************************************************************************************* override fun onKeyPreIme(keyCode: Int, event: KeyEvent?): Boolean { if (keyCode == KeyEvent.KEYCODE_BACK && event?.action == KeyEvent.ACTION_UP && textClear) { if (hasFocus()) { @@ -29,6 +31,7 @@ class FocusEditText @JvmOverloads constructor( text?.clear() } + // ********************************************************************************************* fun setTextClearOnBackPressed(clear: Boolean) { textClear = clear } diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt index 56872973..440b2c8e 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt @@ -1,16 +1,14 @@ package com.lapism.search.widget import android.content.Context +import android.content.res.ColorStateList import android.content.res.TypedArray import android.graphics.Color import android.graphics.drawable.Drawable import android.util.AttributeSet import android.view.LayoutInflater import android.view.View -import androidx.annotation.ColorInt -import androidx.annotation.DrawableRes -import androidx.annotation.Nullable -import androidx.annotation.StringRes +import androidx.annotation.* import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.view.ViewCompat import com.google.android.material.appbar.AppBarLayout @@ -18,6 +16,7 @@ import com.lapism.search.R import com.lapism.search.databinding.MaterialSearchBarBinding +@Suppress("unused", "MemberVisibilityCanBePrivate") class MaterialSearchBar @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, @@ -157,37 +156,32 @@ class MaterialSearchBar @JvmOverloads constructor( binding.searchBarToolbar.setHint(hint) } - /* - fun setForegroundColor(){ - - } - - fun setBackgroundColor(){ - - } + fun setForegroundColor(@Nullable foregroundColor: ColorStateList?) { + binding.searchBarCard.setCardForegroundColor(foregroundColor) + } - fun setStrokeWidth(){ + fun setStrokeWidth(@Dimension strokeWidth: Int) { + binding.searchBarCard.strokeWidth = strokeWidth + } - } + fun setStrokeColor(strokeColor: ColorStateList) { + binding.searchBarCard.setStrokeColor(strokeColor) + } - fun setStrokeColor{ - card?.setStrokeColor() - } - */ + fun setRadius(radius: Float) { + binding.searchBarCard.radius = radius + } - fun setMargins(left: Int, top: Int, right: Int, bottom: Int) { + // ********************************************************************************************* + // TODO PUBLIC ? and requestLayout() + private fun setMargins(left: Int, top: Int, right: Int, bottom: Int) { if (binding.searchBarCard.layoutParams is MarginLayoutParams) { val params = binding.searchBarCard.layoutParams as? MarginLayoutParams params?.setMargins(left, top, right, bottom) binding.searchBarCard.layoutParams = params - // requestLayout() TODO } } - fun setRadius(radius: Float) { - binding.searchBarCard.radius = radius - } - // ********************************************************************************************* @Suppress("unused") class ScrollingViewBehavior : AppBarLayout.ScrollingViewBehavior { diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt index 0a579225..ec64593e 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt @@ -18,6 +18,7 @@ abstract class MaterialSearchLayout @JvmOverloads constructor( defStyleRes: Int = 0 ) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) { + // ********************************************************************************************* @NavigationIconCompat @get:NavigationIconCompat var navigationIconCompat: Int = 0 @@ -47,6 +48,7 @@ abstract class MaterialSearchLayout @JvmOverloads constructor( } } + // ********************************************************************************************* abstract fun setNavigationIcon(@DrawableRes resId: Int) abstract fun setNavigationIcon(@Nullable drawable: Drawable?) diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt index 4ed9c440..55becad9 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt @@ -14,8 +14,10 @@ import com.lapism.search.databinding.MaterialSearchToolbarBinding class MaterialSearchToolbar : MaterialToolbar { + // ********************************************************************************************* private var binding: MaterialSearchToolbarBinding + // ********************************************************************************************* constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) @@ -26,11 +28,13 @@ class MaterialSearchToolbar : MaterialToolbar { defStyleAttr ) + // ********************************************************************************************* init { val inflater = LayoutInflater.from(context) binding = MaterialSearchToolbarBinding.inflate(inflater, this, true) } + // ********************************************************************************************* override fun setTitle(resId: Int) { } @@ -58,17 +62,17 @@ class MaterialSearchToolbar : MaterialToolbar { } } - override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo?) { + override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(info) - info?.className = TextView::class.java.canonicalName + info.className = TextView::class.java.canonicalName var text: CharSequence? = getText() val isEmpty = TextUtils.isEmpty(text) - info?.hintText = getHint() - info?.isShowingHintText = isEmpty + info.hintText = getHint() + info.isShowingHintText = isEmpty if (isEmpty) { text = getHint() } - info?.text = text + info.text = text } // ********************************************************************************************* diff --git a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt index 6f5aa3c0..b6d00828 100755 --- a/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt +++ b/src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt @@ -22,6 +22,7 @@ import com.lapism.search.R import com.lapism.search.databinding.MaterialSearchViewBinding +@Suppress("MemberVisibilityCanBePrivate", "unused") class MaterialSearchView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, @@ -33,7 +34,6 @@ class MaterialSearchView @JvmOverloads constructor( private var binding: MaterialSearchViewBinding private var focusListener: OnFocusChangeListener? = null private var queryListener: OnQueryTextListener? = null - private var clearClickListener: OnClearClickListener? = null // ********************************************************************************************* init { @@ -79,7 +79,6 @@ class MaterialSearchView @JvmOverloads constructor( binding.searchViewClearButton.visibility = View.GONE binding.searchViewClearButton.setOnClickListener { - clearClickListener?.onClearClick() binding.searchViewEditText.text?.clear() } @@ -151,11 +150,18 @@ class MaterialSearchView @JvmOverloads constructor( a.recycle() - // TODO ANIMATE binding.seachViewClip.path - 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) @@ -182,7 +188,7 @@ class MaterialSearchView @JvmOverloads constructor( binding.searchViewBackground.setBackgroundColor(color) } - override fun addView(child: View?) { + override fun addView(child: View) { binding.searchViewContentContainer.addView(child) } @@ -219,7 +225,6 @@ class MaterialSearchView @JvmOverloads constructor( } // ********************************************************************************************* - // TODO ANOTACE, NAZVY PROMENNCYH fun setClearIcon(@Nullable drawable: Drawable?) { binding.searchViewClearButton.setImageDrawable(drawable) } @@ -340,14 +345,9 @@ class MaterialSearchView @JvmOverloads constructor( fun onQueryTextSubmit(query: CharSequence): Boolean } - interface OnClearClickListener { - - fun onClearClick() - } - // ********************************************************************************************* @Suppress("unused") - class SavedState : AbsSavedState { + private class SavedState : AbsSavedState { var text: String? = null var focus: Boolean = false