Skip to content

Commit 92678fd

Browse files
author
Martin Lapiš
committed
Update
1 parent 81f4272 commit 92678fd

File tree

6 files changed

+46
-41
lines changed

6 files changed

+46
-41
lines changed

src/main/kotlin/com/lapism/search/internal/ClippableRoundedCornerLayout.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ class ClippableRoundedCornerLayout @JvmOverloads constructor(
1414
defStyleRes: Int = 0
1515
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
1616

17+
// *********************************************************************************************
1718
// TODO CLIP ANIMATION
1819
var path: Path? = null
1920

21+
// *********************************************************************************************
2022
override fun dispatchDraw(canvas: Canvas?) {
2123
if (path == null) {
2224
super.dispatchDraw(canvas)

src/main/kotlin/com/lapism/search/internal/FocusEditText.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ class FocusEditText @JvmOverloads constructor(
1212
defStyleAttr: Int = 0
1313
) : AppCompatEditText(context, attrs, defStyleAttr) {
1414

15+
// *********************************************************************************************
1516
private var textClear: Boolean = false
1617

18+
// *********************************************************************************************
1719
override fun onKeyPreIme(keyCode: Int, event: KeyEvent?): Boolean {
1820
if (keyCode == KeyEvent.KEYCODE_BACK && event?.action == KeyEvent.ACTION_UP && textClear) {
1921
if (hasFocus()) {
@@ -29,6 +31,7 @@ class FocusEditText @JvmOverloads constructor(
2931
text?.clear()
3032
}
3133

34+
// *********************************************************************************************
3235
fun setTextClearOnBackPressed(clear: Boolean) {
3336
textClear = clear
3437
}

src/main/kotlin/com/lapism/search/widget/MaterialSearchBar.kt

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
package com.lapism.search.widget
22

33
import android.content.Context
4+
import android.content.res.ColorStateList
45
import android.content.res.TypedArray
56
import android.graphics.Color
67
import android.graphics.drawable.Drawable
78
import android.util.AttributeSet
89
import android.view.LayoutInflater
910
import android.view.View
10-
import androidx.annotation.ColorInt
11-
import androidx.annotation.DrawableRes
12-
import androidx.annotation.Nullable
13-
import androidx.annotation.StringRes
11+
import androidx.annotation.*
1412
import androidx.coordinatorlayout.widget.CoordinatorLayout
1513
import androidx.core.view.ViewCompat
1614
import com.google.android.material.appbar.AppBarLayout
1715
import com.lapism.search.R
1816
import com.lapism.search.databinding.MaterialSearchBarBinding
1917

2018

19+
@Suppress("unused", "MemberVisibilityCanBePrivate")
2120
class MaterialSearchBar @JvmOverloads constructor(
2221
context: Context,
2322
attrs: AttributeSet? = null,
@@ -157,37 +156,32 @@ class MaterialSearchBar @JvmOverloads constructor(
157156
binding.searchBarToolbar.setHint(hint)
158157
}
159158

160-
/*
161-
fun setForegroundColor(){
162-
163-
}
164-
165-
fun setBackgroundColor(){
166-
167-
}
159+
fun setForegroundColor(@Nullable foregroundColor: ColorStateList?) {
160+
binding.searchBarCard.setCardForegroundColor(foregroundColor)
161+
}
168162

169-
fun setStrokeWidth(){
163+
fun setStrokeWidth(@Dimension strokeWidth: Int) {
164+
binding.searchBarCard.strokeWidth = strokeWidth
165+
}
170166

171-
}
167+
fun setStrokeColor(strokeColor: ColorStateList) {
168+
binding.searchBarCard.setStrokeColor(strokeColor)
169+
}
172170

173-
fun setStrokeColor{
174-
card?.setStrokeColor()
175-
}
176-
*/
171+
fun setRadius(radius: Float) {
172+
binding.searchBarCard.radius = radius
173+
}
177174

178-
fun setMargins(left: Int, top: Int, right: Int, bottom: Int) {
175+
// *********************************************************************************************
176+
// TODO PUBLIC ? and requestLayout()
177+
private fun setMargins(left: Int, top: Int, right: Int, bottom: Int) {
179178
if (binding.searchBarCard.layoutParams is MarginLayoutParams) {
180179
val params = binding.searchBarCard.layoutParams as? MarginLayoutParams
181180
params?.setMargins(left, top, right, bottom)
182181
binding.searchBarCard.layoutParams = params
183-
// requestLayout() TODO
184182
}
185183
}
186184

187-
fun setRadius(radius: Float) {
188-
binding.searchBarCard.radius = radius
189-
}
190-
191185
// *********************************************************************************************
192186
@Suppress("unused")
193187
class ScrollingViewBehavior : AppBarLayout.ScrollingViewBehavior {

src/main/kotlin/com/lapism/search/widget/MaterialSearchLayout.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ abstract class MaterialSearchLayout @JvmOverloads constructor(
1818
defStyleRes: Int = 0
1919
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
2020

21+
// *********************************************************************************************
2122
@NavigationIconCompat
2223
@get:NavigationIconCompat
2324
var navigationIconCompat: Int = 0
@@ -47,6 +48,7 @@ abstract class MaterialSearchLayout @JvmOverloads constructor(
4748
}
4849
}
4950

51+
// *********************************************************************************************
5052
abstract fun setNavigationIcon(@DrawableRes resId: Int)
5153

5254
abstract fun setNavigationIcon(@Nullable drawable: Drawable?)

src/main/kotlin/com/lapism/search/widget/MaterialSearchToolbar.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import com.lapism.search.databinding.MaterialSearchToolbarBinding
1414

1515
class MaterialSearchToolbar : MaterialToolbar {
1616

17+
// *********************************************************************************************
1718
private var binding: MaterialSearchToolbarBinding
1819

20+
// *********************************************************************************************
1921
constructor(context: Context) : super(context)
2022

2123
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
@@ -26,11 +28,13 @@ class MaterialSearchToolbar : MaterialToolbar {
2628
defStyleAttr
2729
)
2830

31+
// *********************************************************************************************
2932
init {
3033
val inflater = LayoutInflater.from(context)
3134
binding = MaterialSearchToolbarBinding.inflate(inflater, this, true)
3235
}
3336

37+
// *********************************************************************************************
3438
override fun setTitle(resId: Int) {
3539

3640
}
@@ -58,17 +62,17 @@ class MaterialSearchToolbar : MaterialToolbar {
5862
}
5963
}
6064

61-
override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo?) {
65+
override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo) {
6266
super.onInitializeAccessibilityNodeInfo(info)
63-
info?.className = TextView::class.java.canonicalName
67+
info.className = TextView::class.java.canonicalName
6468
var text: CharSequence? = getText()
6569
val isEmpty = TextUtils.isEmpty(text)
66-
info?.hintText = getHint()
67-
info?.isShowingHintText = isEmpty
70+
info.hintText = getHint()
71+
info.isShowingHintText = isEmpty
6872
if (isEmpty) {
6973
text = getHint()
7074
}
71-
info?.text = text
75+
info.text = text
7276
}
7377

7478
// *********************************************************************************************

src/main/kotlin/com/lapism/search/widget/MaterialSearchView.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.lapism.search.R
2222
import com.lapism.search.databinding.MaterialSearchViewBinding
2323

2424

25+
@Suppress("MemberVisibilityCanBePrivate", "unused")
2526
class MaterialSearchView @JvmOverloads constructor(
2627
context: Context,
2728
attrs: AttributeSet? = null,
@@ -33,7 +34,6 @@ class MaterialSearchView @JvmOverloads constructor(
3334
private var binding: MaterialSearchViewBinding
3435
private var focusListener: OnFocusChangeListener? = null
3536
private var queryListener: OnQueryTextListener? = null
36-
private var clearClickListener: OnClearClickListener? = null
3737

3838
// *********************************************************************************************
3939
init {
@@ -79,7 +79,6 @@ class MaterialSearchView @JvmOverloads constructor(
7979

8080
binding.searchViewClearButton.visibility = View.GONE
8181
binding.searchViewClearButton.setOnClickListener {
82-
clearClickListener?.onClearClick()
8382
binding.searchViewEditText.text?.clear()
8483
}
8584

@@ -151,11 +150,18 @@ class MaterialSearchView @JvmOverloads constructor(
151150

152151
a.recycle()
153152

154-
// TODO ANIMATE binding.seachViewClip.path
155-
156153
visibility = View.GONE
157154
}
158155

156+
/* TODO styles + codes, ANIMATE binding.searchViewClip.path, SCALE, path
157+
private fun setTransition() {
158+
val mTransition = LayoutTransition()
159+
mTransition.enableTransitionType(LayoutTransition.CHANGING)
160+
mTransition.setDuration(3000L)
161+
162+
binding.searchViewBackground.layoutTransition = mTransition
163+
}*/
164+
159165
// *********************************************************************************************
160166
override fun setNavigationIcon(@DrawableRes resId: Int) {
161167
binding.searchViewToolbar.setNavigationIcon(resId)
@@ -182,7 +188,7 @@ class MaterialSearchView @JvmOverloads constructor(
182188
binding.searchViewBackground.setBackgroundColor(color)
183189
}
184190

185-
override fun addView(child: View?) {
191+
override fun addView(child: View) {
186192
binding.searchViewContentContainer.addView(child)
187193
}
188194

@@ -219,7 +225,6 @@ class MaterialSearchView @JvmOverloads constructor(
219225
}
220226

221227
// *********************************************************************************************
222-
// TODO ANOTACE, NAZVY PROMENNCYH
223228
fun setClearIcon(@Nullable drawable: Drawable?) {
224229
binding.searchViewClearButton.setImageDrawable(drawable)
225230
}
@@ -340,14 +345,9 @@ class MaterialSearchView @JvmOverloads constructor(
340345
fun onQueryTextSubmit(query: CharSequence): Boolean
341346
}
342347

343-
interface OnClearClickListener {
344-
345-
fun onClearClick()
346-
}
347-
348348
// *********************************************************************************************
349349
@Suppress("unused")
350-
class SavedState : AbsSavedState {
350+
private class SavedState : AbsSavedState {
351351

352352
var text: String? = null
353353
var focus: Boolean = false

0 commit comments

Comments
 (0)