Skip to content

Commit

Permalink
Update the search library with new version
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelMess committed Apr 1, 2022
1 parent 4b94799 commit 5b56353
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "ch.acra:acra-core:5.7.0"

implementation "com.github.arimorty:floatingsearchview:2.1.1"
implementation "xyz.quaver:floatingsearchview:1.2.0-rc2"
}

configurations.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConsta
class AppBar(
mainActivity: MainActivity,
sharedPref: SharedPreferences,
onSearch: (queue: String) -> Unit
onSearch: (queue: String?) -> Unit
) {

val toolbar: Toolbar = mainActivity.findViewById(R.id.action_bar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import android.view.ViewAnimationUtils
import android.view.animation.AccelerateDecelerateInterpolator
import com.amaze.filemanager.R
import com.amaze.filemanager.ui.activities.MainActivity
import com.arlib.floatingsearchview.FloatingSearchView
import com.arlib.floatingsearchview.FloatingSearchView.OnSearchListener
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion
import xyz.quaver.floatingsearchview.FloatingSearchView
import xyz.quaver.floatingsearchview.FloatingSearchView.OnSearchListener
import xyz.quaver.floatingsearchview.suggestions.model.SearchSuggestion
import kotlin.math.max

/**
Expand All @@ -39,7 +39,7 @@ import kotlin.math.max
class SearchView(
private val appbar: AppBar,
private val mainActivity: MainActivity,
onSearch: (queue: String) -> Unit
onSearch: (queue: String?) -> Unit
) {

private val searchView: FloatingSearchView = mainActivity.findViewById(R.id.floating_search_view)
Expand All @@ -51,15 +51,22 @@ class SearchView(
get() = searchView.isShown

init {
searchView.setOnSearchListener(object : OnSearchListener {
override fun onSuggestionClicked(searchSuggestion: SearchSuggestion) = Unit

override fun onSearchAction(currentQuery: String) {
searchView.onSearchListener = object : OnSearchListener {
override fun onSearchAction(currentQuery: String?) {
onSearch(currentQuery)
hideSearchView()
}
})
searchView.setOnHomeActionClickListener { hideSearchView() }

override fun onSuggestionClicked(searchSuggestion: SearchSuggestion?) = Unit
}
searchView.onHomeActionClickListener = { hideSearchView() }
searchView.onFocusChangeListener = object : FloatingSearchView.OnFocusChangeListener {
override fun onFocus() = Unit

override fun onFocusCleared() {
hideSearchView()
}
}
}

/** show search view with a circular reveal animation */
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/layout-v21/layout_search.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<com.arlib.floatingsearchview.FloatingSearchView
<xyz.quaver.floatingsearchview.FloatingSearchView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/floating_search_view"
Expand All @@ -9,6 +9,7 @@
android:elevation="8dp"
android:gravity="center_vertical"
android:visibility="gone"
app:floatingSearch_searchHint="@string/search_hint"
app:floatingSearch_leftActionMode="showHome"
app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
app:dimBackground="false"
app:searchHint="@string/search_hint"
app:leftActionMode="showHome"
app:close_search_on_keyboard_dismiss="true"/>
9 changes: 5 additions & 4 deletions app/src/main/res/layout/layout_search.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<com.arlib.floatingsearchview.FloatingSearchView
<xyz.quaver.floatingsearchview.FloatingSearchView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/floating_search_view"
Expand All @@ -8,6 +8,7 @@
android:layout_height="?attr/actionBarSize"
android:gravity="center_vertical"
android:visibility="gone"
app:floatingSearch_searchHint="@string/search_hint"
app:floatingSearch_leftActionMode="showHome"
app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
app:dimBackground="false"
app:searchHint="@string/search_hint"
app:leftActionMode="showHome"
app:close_search_on_keyboard_dismiss="true"/>

0 comments on commit 5b56353

Please sign in to comment.