Skip to content

Commit 93c89ff

Browse files
author
Martin Lapiš
committed
Fixes
1 parent 0982bce commit 93c89ff

File tree

7 files changed

+31
-71
lines changed

7 files changed

+31
-71
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
![API](https://img.shields.io/badge/API-26%2B-brightgreen.svg?style=flat)
2-
[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.5.30-blue.svg)](https://kotlinlang.org)
2+
[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.5.31-blue.svg)](https://kotlinlang.org)
3+
[![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/1.0.0/)
34
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
45

56
# Search
@@ -28,7 +29,7 @@ Add the dependency to your gradle file:
2829
}
2930
3031
dependencies {
31-
implementation 'io.github.lapism:search:1.1.0'
32+
implementation 'io.github.lapism:search:1.0.0'
3233
}
3334
```
3435

@@ -102,7 +103,7 @@ Add the dependency to your gradle file:
102103
```
103104

104105
### Layout
105-
You have to use app theme Theme.Material3.* or Theme.MaterialComponents.*
106+
You have to use app theme Theme.Material3.* or Theme.MaterialComponents.*.
106107

107108
```xml
108109
<?xml version="1.0" encoding="utf-8"?>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lapism.search.internal
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import android.widget.FrameLayout
6+
7+
8+
class TouchObserverFrameLayout @JvmOverloads constructor(
9+
context: Context,
10+
attrs: AttributeSet? = null,
11+
defStyleAttr: Int = 0,
12+
defStyleRes: Int = 0
13+
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
14+
15+
16+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MaterialSearchBar @JvmOverloads constructor(
2828
init {
2929
View.inflate(context, R.layout.material_search_bar, this)
3030

31-
/* TODO BINDING ?
31+
/* TODO BINDING ? pruhlednost, edittext ztraci focus
3232
private lateinit var binding: ViewSearchBinding
3333
val inflater = LayoutInflater.from(context)
3434
val binding = MaterialSearchBarBinding.inflate(inflater, this)*/

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

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.lapism.search.widget
33
import android.content.Context
44
import android.graphics.Rect
55
import android.graphics.drawable.Drawable
6-
import android.os.Build
76
import android.os.Parcel
87
import android.os.Parcelable
98
import android.text.Editable
@@ -16,11 +15,9 @@ import android.widget.FrameLayout
1615
import android.widget.ImageButton
1716
import android.widget.LinearLayout
1817
import androidx.annotation.*
19-
import androidx.coordinatorlayout.widget.CoordinatorLayout
2018
import androidx.core.content.ContextCompat
2119
import androidx.customview.view.AbsSavedState
2220
import androidx.transition.*
23-
import com.google.android.material.appbar.AppBarLayout
2421
import com.google.android.material.appbar.MaterialToolbar
2522
import com.lapism.search.R
2623
import com.lapism.search.internal.FocusEditText
@@ -32,8 +29,7 @@ class MaterialSearchView @JvmOverloads constructor(
3229
attrs: AttributeSet? = null,
3330
defStyleAttr: Int = 0,
3431
defStyleRes: Int = 0
35-
) : MaterialSearchLayout(context, attrs, defStyleAttr, defStyleRes),
36-
CoordinatorLayout.AttachedBehavior {
32+
) : MaterialSearchLayout(context, attrs, defStyleAttr, defStyleRes) {
3733

3834
private var scrim: View? = null
3935
private var background: LinearLayout? = null
@@ -234,6 +230,14 @@ class MaterialSearchView @JvmOverloads constructor(
234230
queryListener = listener
235231
}
236232

233+
private fun showAnimation() {
234+
// TODO
235+
}
236+
237+
private fun hideAnimation() {
238+
// TODO
239+
}
240+
237241
fun showKeyboard() {
238242
if (!isInEditMode) {
239243
val inputMethodManager =
@@ -245,14 +249,6 @@ class MaterialSearchView @JvmOverloads constructor(
245249
}
246250
}
247251

248-
private fun showAnimation() {
249-
// TODO
250-
}
251-
252-
private fun hideAnimation() {
253-
// TODO
254-
}
255-
256252
fun hideKeyboard() {
257253
if (!isInEditMode) {
258254
val inputMethodManager =
@@ -299,7 +295,6 @@ class MaterialSearchView @JvmOverloads constructor(
299295
superState?.let {
300296
val state = SavedState(it)
301297
state.text = getTextQuery().toString()
302-
state.hasFocus = editText?.hasFocus()!!
303298
return state
304299
} ?: run {
305300
return superState
@@ -310,18 +305,11 @@ class MaterialSearchView @JvmOverloads constructor(
310305
if (state is SavedState) {
311306
super.onRestoreInstanceState(state.superState)
312307
setTextQuery(state.text, false)
313-
if (state.hasFocus) {
314-
editText?.requestFocus()
315-
}
316308
} else {
317309
super.onRestoreInstanceState(state)
318310
}
319311
}
320312

321-
override fun getBehavior(): CoordinatorLayout.Behavior<*> {
322-
return Behavior()
323-
}
324-
325313
interface OnFocusChangeListener {
326314

327315
fun onFocusChange(hasFocus: Boolean)
@@ -339,35 +327,20 @@ class MaterialSearchView @JvmOverloads constructor(
339327
fun onClearClick()
340328
}
341329

342-
// NOT INNER CLASS = STATIC,
343330
@Suppress("unused")
344331
class SavedState : AbsSavedState {
345332

346333
var text: String? = null
347-
var textChar: CharSequence? = null // TODO unused
348-
var hasFocus = false
349334

350335
constructor(superState: Parcelable) : super(superState)
351336

352337
constructor(source: Parcel, loader: ClassLoader? = null) : super(source, loader) {
353338
text = source.readString()
354-
textChar = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source)
355-
hasFocus = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
356-
source.readBoolean()
357-
} else {
358-
source.readInt() == 1
359-
}
360339
}
361340

362341
override fun writeToParcel(dest: Parcel, flags: Int) {
363342
super.writeToParcel(dest, flags)
364343
dest.writeString(text)
365-
TextUtils.writeToParcel(textChar, dest, flags)
366-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
367-
dest.writeBoolean(hasFocus)
368-
} else {
369-
dest.writeInt(if (hasFocus) 1 else 0)
370-
}
371344
}
372345

373346
companion object {
@@ -392,31 +365,4 @@ class MaterialSearchView @JvmOverloads constructor(
392365

393366
}
394367

395-
class Behavior : CoordinatorLayout.Behavior<MaterialSearchView>() {
396-
397-
override fun layoutDependsOn(
398-
parent: CoordinatorLayout,
399-
child: MaterialSearchView,
400-
dependency: View
401-
): Boolean {
402-
return if (dependency is AppBarLayout) {
403-
true
404-
} else {
405-
super.layoutDependsOn(parent, child, dependency)
406-
}
407-
}
408-
409-
override fun onDependentViewChanged(
410-
parent: CoordinatorLayout,
411-
child: MaterialSearchView,
412-
dependency: View
413-
): Boolean {
414-
if (dependency is AppBarLayout) {
415-
return true
416-
}
417-
return super.onDependentViewChanged(parent, child, dependency)
418-
}
419-
420-
}
421-
422368
}

src/main/res/layout/material_search_view.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
android:background="?scrimBackground" />
1010

1111
<com.lapism.search.internal.ClippableFrameLayout
12-
android:id="@+id/clip"
12+
android:id="@+id/search_view_root"
1313
android:layout_width="match_parent"
1414
android:layout_height="match_parent"
1515
android:focusable="true"
@@ -19,7 +19,6 @@
1919
android:id="@+id/search_view_background"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
22-
android:background="?android:attr/colorBackground"
2322
android:orientation="vertical">
2423

2524
<com.google.android.material.appbar.MaterialToolbar

src/main/res/values/public.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
<public name="search_scrimColor" type="attr" />
1111

1212
<public name="material_search_bar_scrolling_view_behavior" type="string" />
13-
<public name="material_search_view_behavior" type="string" />
1413

1514
</resources>

src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
<resources>
33

44
<string name="material_search_bar_scrolling_view_behavior">com.lapism.search.widget.MaterialSearchBar$ScrollingViewBehavior</string>
5-
<string name="material_search_view_behavior">com.lapism.search.widget.MaterialSearchView$Behavior</string>
65

76
</resources>

0 commit comments

Comments
 (0)