For #13053 - Handles common dismiss interactions
parent
682b082100
commit
06ba8a0200
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.mozilla.fenix.searchdialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -15,12 +16,12 @@ import androidx.constraintlayout.widget.ConstraintProperties.TOP
|
|||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.fragment_search.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_search_dialog.*
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import mozilla.components.browser.state.selector.findTab
|
||||
import mozilla.components.lib.state.ext.consumeFrom
|
||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||
import mozilla.components.support.ktx.android.view.hideKeyboard
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
|
@ -46,7 +47,7 @@ fun Settings.shouldShowSearchSuggestions(isPrivate: Boolean): Boolean {
|
|||
}
|
||||
}
|
||||
|
||||
class SearchDialogFragment : AppCompatDialogFragment() {
|
||||
class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
|
||||
|
||||
private lateinit var interactor: SearchDialogInteractor
|
||||
private lateinit var store: SearchDialogFragmentStore
|
||||
|
@ -58,6 +59,14 @@ class SearchDialogFragment : AppCompatDialogFragment() {
|
|||
setStyle(STYLE_NO_TITLE, R.style.SearchDialogStyle)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return object : Dialog(requireContext(), this.theme) {
|
||||
override fun onBackPressed() {
|
||||
this@SearchDialogFragment.onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
@ -110,15 +119,20 @@ class SearchDialogFragment : AppCompatDialogFragment() {
|
|||
clear(toolbar.id, TOP)
|
||||
connect(toolbar.id, BOTTOM, PARENT_ID, BOTTOM)
|
||||
|
||||
clear(scrollView.id, TOP)
|
||||
clear(scrollView.id, BOTTOM)
|
||||
connect(scrollView.id, TOP, PARENT_ID, TOP)
|
||||
connect(scrollView.id, BOTTOM, toolbar.id, TOP)
|
||||
clear(awesomeBar.id, TOP)
|
||||
clear(awesomeBar.id, BOTTOM)
|
||||
connect(awesomeBar.id, TOP, PARENT_ID, TOP)
|
||||
connect(awesomeBar.id, BOTTOM, toolbar.id, TOP)
|
||||
|
||||
applyTo(search_wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
search_wrapper.setOnClickListener {
|
||||
it.hideKeyboard()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
consumeFrom(store) {
|
||||
awesomeBar?.visibility = if (it.query.isEmpty()) View.INVISIBLE else View.VISIBLE
|
||||
toolbarView.update(it)
|
||||
|
@ -126,6 +140,13 @@ class SearchDialogFragment : AppCompatDialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
view?.hideKeyboard()
|
||||
dismissAllowingStateLoss()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun setUpState(): SearchFragmentState {
|
||||
val activity = activity as HomeActivity
|
||||
val settings = activity.settings()
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:background="?attr/scrimBackground"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<mozilla.components.browser.toolbar.BrowserToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
@ -27,29 +28,22 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
||||
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/awesomeBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/scrollView"
|
||||
android:background="?attr/scrimBackground"
|
||||
android:fadingEdge="horizontal"
|
||||
android:fadingEdgeLength="40dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:background="?attr/foundation"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
android:scrollbars="vertical">
|
||||
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
||||
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/awesomeBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdge="horizontal"
|
||||
android:fadingEdgeLength="40dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:background="?attr/foundation"
|
||||
android:visibility="invisible"
|
||||
mozac:awesomeBarChipBackgroundColor="@color/photonGreen50"
|
||||
mozac:awesomeBarDescriptionTextColor="?secondaryText"
|
||||
mozac:awesomeBarTitleTextColor="?primaryText" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
mozac:awesomeBarChipBackgroundColor="@color/photonGreen50"
|
||||
mozac:awesomeBarDescriptionTextColor="?secondaryText"
|
||||
mozac:awesomeBarTitleTextColor="?primaryText" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue