mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-18 11:55:38 -04:00
#3764 Added ripple into FIND IN PAGE
This commit is contained in:
parent
75a7068a04
commit
dad5e7a319
@ -88,7 +88,7 @@ class SearchFragment : BaseFragment() {
|
|||||||
|
|
||||||
private var searchView: SearchView? = null
|
private var searchView: SearchView? = null
|
||||||
private var searchInTextMenuItem: MenuItem? = null
|
private var searchInTextMenuItem: MenuItem? = null
|
||||||
private var searchInTextTextView: TextView? = null
|
private var findInPageTextView: TextView? = null
|
||||||
private var fragmentSearchBinding: FragmentSearchBinding? = null
|
private var fragmentSearchBinding: FragmentSearchBinding? = null
|
||||||
|
|
||||||
private val searchViewModel by lazy { viewModel<SearchViewModel>(viewModelFactory) }
|
private val searchViewModel by lazy { viewModel<SearchViewModel>(viewModelFactory) }
|
||||||
@ -208,7 +208,7 @@ class SearchFragment : BaseFragment() {
|
|||||||
activity?.intent?.action = null
|
activity?.intent?.action = null
|
||||||
searchView = null
|
searchView = null
|
||||||
searchInTextMenuItem = null
|
searchInTextMenuItem = null
|
||||||
searchInTextTextView = null
|
findInPageTextView = null
|
||||||
searchAdapter = null
|
searchAdapter = null
|
||||||
fragmentSearchBinding = null
|
fragmentSearchBinding = null
|
||||||
}
|
}
|
||||||
@ -231,8 +231,7 @@ class SearchFragment : BaseFragment() {
|
|||||||
searchView?.setOnQueryTextListener(
|
searchView?.setOnQueryTextListener(
|
||||||
SimpleTextListener { query, isSubmit ->
|
SimpleTextListener { query, isSubmit ->
|
||||||
if (query.isNotEmpty()) {
|
if (query.isNotEmpty()) {
|
||||||
searchInTextMenuItem?.actionView?.isEnabled = true
|
setIsPageSearchEnabled(true)
|
||||||
searchInTextTextView?.alpha = ENABLED_SEARCH_IN_TEXT_OPACITY
|
|
||||||
when {
|
when {
|
||||||
isSubmit -> {
|
isSubmit -> {
|
||||||
// if user press the search/enter button on keyboard,
|
// if user press the search/enter button on keyboard,
|
||||||
@ -243,8 +242,7 @@ class SearchFragment : BaseFragment() {
|
|||||||
else -> searchViewModel.actions.trySend(Filter(query)).isSuccess
|
else -> searchViewModel.actions.trySend(Filter(query)).isSuccess
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
searchInTextMenuItem?.actionView?.isEnabled = false
|
setIsPageSearchEnabled(false)
|
||||||
searchInTextTextView?.alpha = DISABLED_SEARCH_IN_TEXT_OPACITY
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -259,8 +257,8 @@ class SearchFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
searchInTextMenuItem = menu.findItem(R.id.menu_searchintext)
|
searchInTextMenuItem = menu.findItem(R.id.menu_searchintext)
|
||||||
searchInTextTextView =
|
findInPageTextView =
|
||||||
searchInTextMenuItem?.actionView?.findViewById(R.id.search_in_text_text_view)
|
searchInTextMenuItem?.actionView?.findViewById(R.id.find_in_page_text_view)
|
||||||
searchInTextMenuItem?.actionView?.setOnClickListener {
|
searchInTextMenuItem?.actionView?.setOnClickListener {
|
||||||
searchViewModel.actions.trySend(ClickedSearchInText).isSuccess
|
searchViewModel.actions.trySend(ClickedSearchInText).isSuccess
|
||||||
}
|
}
|
||||||
@ -292,12 +290,7 @@ class SearchFragment : BaseFragment() {
|
|||||||
renderingJob?.cancelAndJoin()
|
renderingJob?.cancelAndJoin()
|
||||||
isDataLoading = false
|
isDataLoading = false
|
||||||
searchInTextMenuItem?.actionView?.isVisible = state.searchOrigin == FromWebView
|
searchInTextMenuItem?.actionView?.isVisible = state.searchOrigin == FromWebView
|
||||||
searchInTextMenuItem?.actionView?.isEnabled = state.searchTerm.isNotBlank()
|
setIsPageSearchEnabled(state.searchTerm.isNotBlank())
|
||||||
searchInTextTextView?.alpha = if (state.searchTerm.isBlank()) {
|
|
||||||
DISABLED_SEARCH_IN_TEXT_OPACITY
|
|
||||||
} else {
|
|
||||||
ENABLED_SEARCH_IN_TEXT_OPACITY
|
|
||||||
}
|
|
||||||
|
|
||||||
fragmentSearchBinding?.searchLoadingIndicator?.isShowing(true)
|
fragmentSearchBinding?.searchLoadingIndicator?.isShowing(true)
|
||||||
renderingJob = searchViewModel.viewModelScope.launch(Dispatchers.Main) {
|
renderingJob = searchViewModel.viewModelScope.launch(Dispatchers.Main) {
|
||||||
@ -315,6 +308,15 @@ class SearchFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setIsPageSearchEnabled(isEnabled: Boolean) {
|
||||||
|
searchInTextMenuItem?.actionView?.isEnabled = isEnabled
|
||||||
|
findInPageTextView?.alpha = if (isEnabled) {
|
||||||
|
ENABLED_SEARCH_IN_TEXT_OPACITY
|
||||||
|
} else {
|
||||||
|
DISABLED_SEARCH_IN_TEXT_OPACITY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun onItemClick(it: SearchListItem) {
|
private fun onItemClick(it: SearchListItem) {
|
||||||
searchViewModel.actions.trySend(OnItemClick(it)).isSuccess
|
searchViewModel.actions.trySend(OnItemClick(it)).isSuccess
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_in_text_text_view"
|
android:id="@+id/find_in_page_text_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user