|
|
|
@ -7,6 +7,7 @@ package org.mozilla.fenix.quickactionsheet
|
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
|
import androidx.core.widget.NestedScrollView
|
|
|
|
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|
|
|
|
import io.reactivex.Observable
|
|
|
|
@ -15,6 +16,8 @@ import io.reactivex.functions.Consumer
|
|
|
|
|
import kotlinx.android.synthetic.main.fragment_browser.*
|
|
|
|
|
import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.*
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
import org.mozilla.fenix.mvi.UIView
|
|
|
|
|
|
|
|
|
|
class QuickActionUIView(
|
|
|
|
@ -31,6 +34,23 @@ class QuickActionUIView(
|
|
|
|
|
val quickActionSheetBehavior =
|
|
|
|
|
BottomSheetBehavior.from(nestedScrollQuickAction as View) as QuickActionSheetBehavior
|
|
|
|
|
|
|
|
|
|
quickActionSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
|
|
|
|
override fun onStateChanged(v: View, state: Int) {
|
|
|
|
|
updateImportantForAccessibility(state)
|
|
|
|
|
|
|
|
|
|
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
|
|
|
|
actionEmitter.onNext(QuickActionAction.Opened)
|
|
|
|
|
} else if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
|
|
|
|
actionEmitter.onNext(QuickActionAction.Closed)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onSlide(p0: View, p1: Float) {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
updateImportantForAccessibility(quickActionSheetBehavior.state)
|
|
|
|
|
|
|
|
|
|
view.quick_action_share.setOnClickListener {
|
|
|
|
|
actionEmitter.onNext(QuickActionAction.SharePressed)
|
|
|
|
|
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
|
|
|
@ -49,6 +69,23 @@ class QuickActionUIView(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun updateImportantForAccessibility(state: Int) {
|
|
|
|
|
view.findViewById<LinearLayout>(R.id.quick_action_buttons_layout).importantForAccessibility =
|
|
|
|
|
if (state == BottomSheetBehavior.STATE_COLLAPSED || state == BottomSheetBehavior.STATE_HIDDEN)
|
|
|
|
|
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
|
|
|
|
else
|
|
|
|
|
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun sendTelemetryEvent(state: Int) {
|
|
|
|
|
when (state) {
|
|
|
|
|
BottomSheetBehavior.STATE_EXPANDED ->
|
|
|
|
|
view.context.components.analytics.metrics.track(Event.QuickActionSheetOpened)
|
|
|
|
|
BottomSheetBehavior.STATE_COLLAPSED ->
|
|
|
|
|
view.context.components.analytics.metrics.track(Event.QuickActionSheetClosed)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun updateView() = Consumer<QuickActionState> {
|
|
|
|
|
view.quick_action_read.visibility = if (it.readable) View.VISIBLE else View.GONE
|
|
|
|
|
}
|
|
|
|
|