2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/13251 - Use bottomSheetCallback in multiselect mode

This commit is contained in:
ekager 2020-08-04 17:07:36 -04:00 committed by Emily Kager
parent 05fe44c96a
commit bfb30d200f

View File

@ -45,6 +45,7 @@ import org.mozilla.fenix.components.toolbar.TabCounter.Companion.SO_MANY_TABS_OP
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.tabtray.SaveToCollectionsButtonAdapter.MultiselectModeChange
import org.mozilla.fenix.tabtray.TabTrayDialogFragmentState.Mode
import java.text.NumberFormat
/**
@ -75,7 +76,6 @@ class TabTrayView(
private val tabTrayItemMenu: TabTrayItemMenu
private var menu: BrowserMenu? = null
private val bottomSheetCallback: BottomSheetBehavior.BottomSheetCallback
private var tabsTouchHelper: TabsTouchHelper
private val collectionsButtonAdapter = SaveToCollectionsButtonAdapter(interactor, isPrivate)
@ -89,9 +89,9 @@ class TabTrayView(
toggleFabText(isPrivate)
bottomSheetCallback = object : BottomSheetBehavior.BottomSheetCallback() {
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, slideOffset: Float) {
if (!hasAccessibilityEnabled) {
if (interactor.onModeRequested() is Mode.Normal && !hasAccessibilityEnabled) {
if (slideOffset >= SLIDE_OFFSET) {
fabView.new_tab_button.show()
} else {
@ -106,9 +106,7 @@ class TabTrayView(
interactor.onTabTrayDismissed()
}
}
}
behavior.addBottomSheetCallback(bottomSheetCallback)
})
val selectedTabIndex = if (!isPrivate) {
DEFAULT_TAB_ID
@ -275,17 +273,17 @@ class TabTrayView(
override fun onTabUnselected(tab: TabLayout.Tab?) { /*noop*/
}
var mode: TabTrayDialogFragmentState.Mode = TabTrayDialogFragmentState.Mode.Normal
var mode: Mode = Mode.Normal
private set
fun updateState(state: TabTrayDialogFragmentState) {
val oldMode = mode
if (oldMode::class != state.mode::class) {
updateTabsForMultiselectModeChanged(state.mode is TabTrayDialogFragmentState.Mode.MultiSelect)
updateTabsForMultiselectModeChanged(state.mode is Mode.MultiSelect)
if (view.context.settings().accessibilityServicesEnabled) {
view.announceForAccessibility(
if (state.mode == TabTrayDialogFragmentState.Mode.Normal) view.context.getString(
if (state.mode == Mode.Normal) view.context.getString(
R.string.tab_tray_exit_multiselect_content_description
) else view.context.getString(R.string.tab_tray_enter_multiselect_content_description)
)
@ -294,20 +292,18 @@ class TabTrayView(
mode = state.mode
when (state.mode) {
TabTrayDialogFragmentState.Mode.Normal -> {
Mode.Normal -> {
view.tabsTray.apply {
tabsTouchHelper.attachToRecyclerView(this)
}
behavior.addBottomSheetCallback(bottomSheetCallback)
toggleUIMultiselect(multiselect = false)
updateUINormalMode(state.browserState)
}
is TabTrayDialogFragmentState.Mode.MultiSelect -> {
is Mode.MultiSelect -> {
// Disable swipe to delete while in multiselect
tabsTouchHelper.attachToRecyclerView(null)
behavior.removeBottomSheetCallback(bottomSheetCallback)
toggleUIMultiselect(multiselect = true)