diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/AccessibleNewTabButtonBinding.kt b/app/src/main/java/org/mozilla/fenix/tabstray/AccessibleNewTabButtonBinding.kt deleted file mode 100644 index 5f759b462a..0000000000 --- a/app/src/main/java/org/mozilla/fenix/tabstray/AccessibleNewTabButtonBinding.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.tabstray - -import android.annotation.SuppressLint -import android.view.View -import android.widget.ImageButton -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.map -import mozilla.components.lib.state.helpers.AbstractBinding -import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged -import org.mozilla.fenix.R -import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor -import org.mozilla.fenix.utils.Settings - -/** - * A binding for an accessible [actionButton] that is updated on the selected page. - * - * Do not show accessible new tab button when accessibility service is disabled - * - * This binding is coupled with [FloatingActionButtonBinding]. - * When [FloatingActionButtonBinding] is visible this should not be visible - */ -@OptIn(ExperimentalCoroutinesApi::class) -class AccessibleNewTabButtonBinding( - private val store: TabsTrayStore, - private val settings: Settings, - private val actionButton: ImageButton, - private val browserTrayInteractor: BrowserTrayInteractor -) : AbstractBinding(store) { - - // suppressing for the intentional behaviour of this feature. - @SuppressLint("MissingSuperCall") - override fun start() { - if (!settings.accessibilityServicesEnabled) { - actionButton.visibility = View.GONE - return - } - super.start() - } - - override suspend fun onState(flow: Flow) { - flow.map { it } - .ifAnyChanged { state -> - arrayOf( - state.selectedPage, - state.syncing - ) - } - .collect { state -> - setAccessibleNewTabButton(state.selectedPage, state.syncing) - } - } - - private fun setAccessibleNewTabButton(selectedPage: Page, syncing: Boolean) { - when (selectedPage) { - Page.NormalTabs -> { - actionButton.apply { - visibility = View.VISIBLE - contentDescription = context.getString(R.string.add_tab) - setImageResource(R.drawable.ic_new) - setOnClickListener { - browserTrayInteractor.onFabClicked(false) - } - } - } - Page.PrivateTabs -> { - actionButton.apply { - visibility = View.VISIBLE - contentDescription = context.getString(R.string.add_private_tab) - setImageResource(R.drawable.ic_new) - setOnClickListener { - browserTrayInteractor.onFabClicked(true) - } - } - } - Page.SyncedTabs -> { - actionButton.apply { - visibility = when (syncing) { - true -> View.GONE - false -> View.VISIBLE - } - contentDescription = context.getString(R.string.tab_drawer_fab_sync) - setImageResource(R.drawable.ic_fab_sync) - setOnClickListener { - // Notify the store observers (one of which is the SyncedTabsFeature), that - // a sync was requested. - if (!syncing) { - store.dispatch(TabsTrayAction.SyncNow) - } - } - } - } - } - } -} diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/FloatingActionButtonBinding.kt b/app/src/main/java/org/mozilla/fenix/tabstray/FloatingActionButtonBinding.kt index bc7f95a6e4..3d2b1796e3 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/FloatingActionButtonBinding.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/FloatingActionButtonBinding.kt @@ -13,32 +13,17 @@ import mozilla.components.lib.state.helpers.AbstractBinding import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged import org.mozilla.fenix.R import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor -import org.mozilla.fenix.utils.Settings /** - * A binding for an accessible [actionButton] that is updated on the selected page. - * - * Do not show fab when accessibility service is enabled - * - * This binding is coupled with [AccessibleNewTabButtonBinding]. - * When [AccessibleNewTabButtonBinding] is visible this should not be visible + * A binding that show a FAB in tab tray used to open a new tab. */ @OptIn(ExperimentalCoroutinesApi::class) class FloatingActionButtonBinding( private val store: TabsTrayStore, - private val settings: Settings, private val actionButton: ExtendedFloatingActionButton, private val browserTrayInteractor: BrowserTrayInteractor ) : AbstractBinding(store) { - override fun start() { - if (settings.accessibilityServicesEnabled) { - actionButton.hide() - return - } - super.start() - } - override suspend fun onState(flow: Flow) { flow.map { it } .ifAnyChanged { state -> diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt b/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt index be75b9833a..c0f90708f0 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt @@ -21,8 +21,6 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.tabs.TabLayout import kotlinx.android.synthetic.main.component_tabstray2.* import kotlinx.android.synthetic.main.component_tabstray2.view.* -import kotlinx.android.synthetic.main.component_tabstray2.view.tab_tray_overflow -import kotlinx.android.synthetic.main.component_tabstray2.view.tab_wrapper import kotlinx.android.synthetic.main.component_tabstray_fab.* import kotlinx.android.synthetic.main.fragment_tab_tray_dialog.* import kotlinx.android.synthetic.main.tabs_tray_tab_counter2.* @@ -35,6 +33,7 @@ import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavGraphDirections import org.mozilla.fenix.R +import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components @@ -44,17 +43,16 @@ import org.mozilla.fenix.ext.settings import org.mozilla.fenix.home.HomeScreenViewModel import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor import org.mozilla.fenix.tabstray.browser.DefaultBrowserTrayInteractor -import org.mozilla.fenix.tabstray.browser.SelectionHandleBinding import org.mozilla.fenix.tabstray.browser.SelectionBannerBinding import org.mozilla.fenix.tabstray.browser.SelectionBannerBinding.VisibilityModifier -import org.mozilla.fenix.tabstray.ext.showWithTheme +import org.mozilla.fenix.tabstray.browser.SelectionHandleBinding import org.mozilla.fenix.tabstray.ext.anchorWithAction -import org.mozilla.fenix.utils.allowUndo -import kotlin.math.max -import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.tabstray.ext.make -import org.mozilla.fenix.tabstray.ext.orDefault import org.mozilla.fenix.tabstray.ext.message +import org.mozilla.fenix.tabstray.ext.orDefault +import org.mozilla.fenix.tabstray.ext.showWithTheme +import org.mozilla.fenix.utils.allowUndo +import kotlin.math.max @Suppress("TooManyFunctions", "LargeClass") class TabsTrayFragment : AppCompatDialogFragment() { @@ -68,7 +66,6 @@ class TabsTrayFragment : AppCompatDialogFragment() { private val tabLayoutMediator = ViewBoundFeatureWrapper() private val tabCounterBinding = ViewBoundFeatureWrapper() private val floatingActionButtonBinding = ViewBoundFeatureWrapper() - private val newTabButtonBinding = ViewBoundFeatureWrapper() private val selectionBannerBinding = ViewBoundFeatureWrapper() private val selectionHandleBinding = ViewBoundFeatureWrapper() private val tabsTrayCtaBinding = ViewBoundFeatureWrapper() @@ -215,7 +212,6 @@ class TabsTrayFragment : AppCompatDialogFragment() { floatingActionButtonBinding.set( feature = FloatingActionButtonBinding( store = tabsTrayStore, - settings = requireComponents.settings, actionButton = new_tab_button, browserTrayInteractor = browserTrayInteractor ), @@ -223,17 +219,6 @@ class TabsTrayFragment : AppCompatDialogFragment() { view = view ) - newTabButtonBinding.set( - feature = AccessibleNewTabButtonBinding( - store = tabsTrayStore, - settings = requireComponents.settings, - actionButton = tab_tray_new_tab, - browserTrayInteractor = browserTrayInteractor - ), - owner = this, - view = view - ) - selectionBannerBinding.set( feature = SelectionBannerBinding( context = requireContext(), diff --git a/app/src/main/res/layout/component_tabstray2.xml b/app/src/main/res/layout/component_tabstray2.xml index 3460785cc4..a14b3354f3 100644 --- a/app/src/main/res/layout/component_tabstray2.xml +++ b/app/src/main/res/layout/component_tabstray2.xml @@ -111,19 +111,6 @@ - -