For #7059 - Allow search engines to scroll
This commit is contained in:
parent
d989616f62
commit
e1187ebf31
|
@ -30,6 +30,7 @@ import mozilla.components.feature.qr.QrFeature
|
|||
import mozilla.components.lib.state.ext.consumeFrom
|
||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import mozilla.components.support.ktx.android.content.hasCamera
|
||||
import mozilla.components.support.ktx.android.content.isPermissionGranted
|
||||
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText
|
||||
|
@ -116,7 +117,7 @@ class SearchFragment : Fragment(), UserInteractionHandler {
|
|||
searchController
|
||||
)
|
||||
|
||||
awesomeBarView = AwesomeBarView(view.search_layout, searchInteractor)
|
||||
awesomeBarView = AwesomeBarView(view.scrollable_area, searchInteractor)
|
||||
|
||||
toolbarView = ToolbarView(
|
||||
view.toolbar_component_wrapper,
|
||||
|
@ -194,6 +195,10 @@ class SearchFragment : Fragment(), UserInteractionHandler {
|
|||
qrFeature.get()?.scan(R.id.container)
|
||||
}
|
||||
|
||||
view.search_shortcuts_button.setOnClickListener {
|
||||
searchInteractor.onSearchShortcutsButtonClicked()
|
||||
}
|
||||
|
||||
val stubListener = ViewStub.OnInflateListener { _, inflated ->
|
||||
inflated.learn_more.setOnClickListener {
|
||||
(activity as HomeActivity)
|
||||
|
@ -243,6 +248,7 @@ class SearchFragment : Fragment(), UserInteractionHandler {
|
|||
|
||||
consumeFrom(searchStore) {
|
||||
awesomeBarView.update(it)
|
||||
updateSearchShortcutsIcon(it)
|
||||
toolbarView.update(it)
|
||||
updateSearchWithLabel(it)
|
||||
updateClipboardSuggestion(it, requireContext().components.clipboardHandler.url)
|
||||
|
@ -351,6 +357,18 @@ class SearchFragment : Fragment(), UserInteractionHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateSearchShortcutsIcon(searchState: SearchFragmentState) {
|
||||
view?.apply {
|
||||
val showShortcuts = searchState.showSearchShortcuts
|
||||
search_shortcuts_button.isChecked = showShortcuts
|
||||
|
||||
val color = if (showShortcuts) R.attr.contrastText else R.attr.primaryText
|
||||
search_shortcuts_button.compoundDrawables[0]?.setTint(
|
||||
requireContext().getColorFromAttr(color)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val SHARED_TRANSITION_MS = 250L
|
||||
private const val REQUEST_CODE_CAMERA_PERMISSIONS = 1
|
||||
|
|
|
@ -192,9 +192,6 @@ class AwesomeBarView(
|
|||
)
|
||||
|
||||
searchSuggestionProviderMap = HashMap()
|
||||
search_shortcuts_button.setOnClickListener {
|
||||
interactor.onSearchShortcutsButtonClicked()
|
||||
}
|
||||
|
||||
val recyclerListener = object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
|
@ -215,7 +212,6 @@ class AwesomeBarView(
|
|||
}
|
||||
|
||||
fun update(state: SearchFragmentState) {
|
||||
updateSearchShortcutsIcon(state)
|
||||
updateSuggestionProvidersVisibility(state)
|
||||
|
||||
// Do not make suggestions based on user's current URL unless it's a search shortcut
|
||||
|
@ -226,17 +222,6 @@ class AwesomeBarView(
|
|||
view.onInputChanged(state.query)
|
||||
}
|
||||
|
||||
private fun updateSearchShortcutsIcon(searchState: SearchFragmentState) {
|
||||
with(container.context) {
|
||||
val showShortcuts = searchState.showSearchShortcuts
|
||||
search_shortcuts_button?.isChecked = showShortcuts
|
||||
|
||||
val color = if (showShortcuts) R.attr.contrastText else R.attr.primaryText
|
||||
|
||||
search_shortcuts_button.compoundDrawables[0]?.setTint(getColorFromAttr(color))
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSuggestionProvidersVisibility(state: SearchFragmentState) {
|
||||
if (state.showSearchShortcuts) {
|
||||
handleDisplayShortcutsProviders()
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/awesomeBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdge="horizontal"
|
||||
android:fadingEdgeLength="40dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:requiresFadingEdge="vertical"
|
||||
app:layout_constraintBottom_toTopOf="@id/pill_wrapper"
|
||||
app:layout_constraintTop_toTopOf="@id/awesomeBar_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/search_with_shortcuts"
|
||||
mozac:awesomeBarDescriptionTextColor="?secondaryText"
|
||||
mozac:awesomeBarTitleTextColor="?primaryText" />
|
|
@ -11,27 +11,6 @@
|
|||
android:background="?foundation"
|
||||
tools:context=".search.SearchFragment">
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/search_suggestions_onboarding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inflatedId="@+id/search_suggestions_onboarding"
|
||||
android:layout="@layout/search_suggestions_onboarding"
|
||||
app:layout_constraintBottom_toTopOf="@id/awesomeBar_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" />
|
||||
|
||||
<View
|
||||
android:id="@+id/search_suggestions_onboarding_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?neutralFaded"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/search_suggestions_onboarding"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/toolbar_wrapper"
|
||||
android:layout_width="0dp"
|
||||
|
@ -53,6 +32,40 @@
|
|||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/search_divider"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/scrollable_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/search_suggestions_onboarding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inflatedId="@+id/search_suggestions_onboarding"
|
||||
android:layout="@layout/search_suggestions_onboarding"
|
||||
app:layout_constraintBottom_toTopOf="@id/awesomeBar_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/search_suggestions_onboarding_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?neutralFaded"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/search_suggestions_onboarding"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/fill_link_from_clipboard"
|
||||
android:layout_width="0dp"
|
||||
|
@ -64,17 +77,16 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/awesomeBar_barrier"
|
||||
app:layout_constraintEnd_toEndOf="@id/toolbar_wrapper"
|
||||
app:layout_constraintEnd_toEndOf="@id/scrollable_area"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper">
|
||||
app:layout_constraintTop_toTopOf="@id/scrollable_area">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/link_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:importantForAccessibility="no"
|
||||
android:tint="?primaryText"
|
||||
app:tint="?primaryText"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -124,8 +136,8 @@
|
|||
android:layout_marginEnd="@dimen/search_fragment_shortcuts_label_margin_horizontal"
|
||||
android:visibility="gone"
|
||||
android:text="@string/search_shortcuts_search_with_2"
|
||||
app:layout_constraintStart_toStartOf="@id/toolbar_wrapper"
|
||||
app:layout_constraintTop_toBottomOf="@id/awesomeBar_barrier"
|
||||
app:layout_constraintStart_toStartOf="@id/scrollable_area"
|
||||
app:layout_constraintTop_toBottomOf="@id/divider_line"
|
||||
tools:text="This time, search with:" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
|
@ -133,7 +145,11 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="fill_link_from_clipboard,search_suggestions_onboarding" />
|
||||
app:constraint_referenced_ids="fill_link_from_clipboard,search_with_shortcuts,search_suggestions_onboarding" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<View
|
||||
android:id="@+id/search_divider"
|
||||
|
|
Loading…
Reference in New Issue
Block a user