From 5a507fbb92751077addd05c4b7605256d31d2635 Mon Sep 17 00:00:00 2001 From: Noah Bond Date: Wed, 4 Jan 2023 15:08:09 -0800 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/28261 - Rename solo `xInteractor` parameters in the Tabs Tray to `interactor` --- .../tabstray/FloatingActionButtonBinding.kt | 7 +++---- .../mozilla/fenix/tabstray/TabsTrayFragment.kt | 2 +- .../browser/AbstractBrowserTabViewHolder.kt | 6 +++--- .../tabstray/browser/BrowserTabViewHolder.kt | 8 ++++---- .../tabstray/browser/InactiveTabViewHolder.kt | 18 ++++++++---------- .../tabstray/browser/InactiveTabsAdapter.kt | 2 +- .../FloatingActionButtonBindingTest.kt | 10 +++++----- .../AbstractBrowserTabViewHolderTest.kt | 2 +- .../tabstray/browser/BrowserTabsAdapterTest.kt | 2 +- 9 files changed, 27 insertions(+), 30 deletions(-) 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 f4d5a52093..2ea7f3111a 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/FloatingActionButtonBinding.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/FloatingActionButtonBinding.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.tabstray import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton 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 @@ -21,7 +20,7 @@ import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor class FloatingActionButtonBinding( private val store: TabsTrayStore, private val actionButton: ExtendedFloatingActionButton, - private val browserTrayInteractor: BrowserTrayInteractor, + private val interactor: BrowserTrayInteractor, ) : AbstractBinding(store) { override suspend fun onState(flow: Flow) { @@ -46,7 +45,7 @@ class FloatingActionButtonBinding( contentDescription = context.getString(R.string.add_tab) setIconResource(R.drawable.ic_new) setOnClickListener { - browserTrayInteractor.onFabClicked(false) + interactor.onFabClicked(false) } } } @@ -58,7 +57,7 @@ class FloatingActionButtonBinding( contentDescription = context.getString(R.string.add_private_tab) setIconResource(R.drawable.ic_new) setOnClickListener { - browserTrayInteractor.onFabClicked(true) + interactor.onFabClicked(true) } } } 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 2730893f80..045957a4e4 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt @@ -332,7 +332,7 @@ class TabsTrayFragment : AppCompatDialogFragment() { feature = FloatingActionButtonBinding( store = tabsTrayStore, actionButton = fabButtonBinding.newTabButton, - browserTrayInteractor = browserTrayInteractor, + interactor = browserTrayInteractor, ), owner = this, view = view, diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolder.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolder.kt index ed5d0ca4ee..07449ad93e 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolder.kt @@ -73,7 +73,7 @@ abstract class AbstractBrowserTabViewHolder( internal val urlView: TextView? = itemView.findViewById(R.id.mozac_browser_tabstray_url) private val playPauseButtonView: ImageButton = itemView.findViewById(R.id.play_pause_button) - abstract val browserTrayInteractor: BrowserTrayInteractor + abstract val interactor: BrowserTrayInteractor abstract val thumbnailSize: Int override var tab: TabSessionState? = null @@ -102,10 +102,10 @@ abstract class AbstractBrowserTabViewHolder( updateMediaState(tab) if (selectionHolder != null) { - setSelectionInteractor(tab, selectionHolder, browserTrayInteractor) + setSelectionInteractor(tab, selectionHolder, interactor) } else { itemView.setOnClickListener { - browserTrayInteractor.onTabSelected(tab, featureName) + interactor.onTabSelected(tab, featureName) } } diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTabViewHolder.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTabViewHolder.kt index d2cf755918..7c412ae28c 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTabViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTabViewHolder.kt @@ -25,7 +25,7 @@ sealed class BrowserTabViewHolder(itemView: View) : RecyclerView.ViewHolder(item * A RecyclerView ViewHolder implementation for "tab" items with grid layout. * * @param imageLoader [ImageLoader] used to load tab thumbnails. - * @param browserTrayInteractor [BrowserTrayInteractor] handling tabs interactions in a tab tray. + * @param interactor [BrowserTrayInteractor] handling tabs interactions in a tab tray. * @param store [TabsTrayStore] containing the complete state of tabs tray and methods to update that. * @param selectionHolder [SelectionHolder]<[TabSessionState]> for helping with selecting * any number of displayed [TabSessionState]s. @@ -34,7 +34,7 @@ sealed class BrowserTabViewHolder(itemView: View) : RecyclerView.ViewHolder(item */ class GridViewHolder( imageLoader: ImageLoader, - override val browserTrayInteractor: BrowserTrayInteractor, + override val interactor: BrowserTrayInteractor, store: TabsTrayStore, selectionHolder: SelectionHolder? = null, itemView: View, @@ -79,7 +79,7 @@ sealed class BrowserTabViewHolder(itemView: View) : RecyclerView.ViewHolder(item * A RecyclerView ViewHolder implementation for "tab" items with list layout. * * @param imageLoader [ImageLoader] used to load tab thumbnails. - * @param browserTrayInteractor [BrowserTrayInteractor] handling tabs interactions in a tab tray. + * @param interactor [BrowserTrayInteractor] handling tabs interactions in a tab tray. * @param store [TabsTrayStore] containing the complete state of tabs tray and methods to update that. * @param selectionHolder [SelectionHolder]<[TabSessionState]> for helping with selecting * any number of displayed [TabSessionState]s. @@ -88,7 +88,7 @@ sealed class BrowserTabViewHolder(itemView: View) : RecyclerView.ViewHolder(item */ class ListViewHolder( imageLoader: ImageLoader, - override val browserTrayInteractor: BrowserTrayInteractor, + override val interactor: BrowserTrayInteractor, store: TabsTrayStore, selectionHolder: SelectionHolder? = null, itemView: View, diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt index 8e5464bdb1..bc0e34d80e 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt @@ -19,7 +19,6 @@ import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.components import org.mozilla.fenix.compose.ComposeViewHolder import org.mozilla.fenix.tabstray.TabsTrayFragment -import org.mozilla.fenix.tabstray.TabsTrayInteractor import org.mozilla.fenix.tabstray.TabsTrayState import org.mozilla.fenix.tabstray.TabsTrayStore import org.mozilla.fenix.tabstray.TrayPagerAdapter @@ -32,8 +31,7 @@ import org.mozilla.fenix.GleanMetrics.TabsTray as TabsTrayMetrics * @param composeView [ComposeView] which will be populated with Jetpack Compose UI content. * @param lifecycleOwner [LifecycleOwner] to which this Composable will be tied to. * @param tabsTrayStore [TabsTrayStore] used to listen for changes to [TabsTrayState.inactiveTabs]. - * @param tabsTrayInteractor [TabsTrayInteractor] used to handle deleting all inactive tabs. - * @param inactiveTabsInteractor [InactiveTabsInteractor] used to respond to interactions with the inactive tabs header + * @param interactor [InactiveTabsInteractor] used to respond to interactions with the inactive tabs header * and the auto close dialog. */ @Suppress("LongParameterList") @@ -41,7 +39,7 @@ class InactiveTabViewHolder( composeView: ComposeView, lifecycleOwner: LifecycleOwner, private val tabsTrayStore: TabsTrayStore, - private val inactiveTabsInteractor: InactiveTabsInteractor, + private val interactor: InactiveTabsInteractor, ) : ComposeViewHolder(composeView, lifecycleOwner) { @Composable @@ -63,19 +61,19 @@ class InactiveTabViewHolder( inactiveTabs = inactiveTabs, expanded = expanded, showAutoCloseDialog = showAutoClosePrompt, - onHeaderClick = { inactiveTabsInteractor.onHeaderClicked(!expanded) }, - onDeleteAllButtonClick = inactiveTabsInteractor::onDeleteAllInactiveTabsClicked, + onHeaderClick = { interactor.onHeaderClicked(!expanded) }, + onDeleteAllButtonClick = interactor::onDeleteAllInactiveTabsClicked, onAutoCloseDismissClick = { - inactiveTabsInteractor.onCloseClicked() + interactor.onCloseClicked() showAutoClosePrompt = !showAutoClosePrompt }, onEnableAutoCloseClick = { - inactiveTabsInteractor.onEnabledAutoCloseClicked() + interactor.onEnabledAutoCloseClicked() showAutoClosePrompt = !showAutoClosePrompt showConfirmationSnackbar() }, - onTabClick = inactiveTabsInteractor::onTabClicked, - onTabCloseClick = inactiveTabsInteractor::onTabClosed, + onTabClick = interactor::onTabClicked, + onTabCloseClick = interactor::onTabClosed, ) } } diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt index 2fbae6769a..f731f7903d 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt @@ -35,7 +35,7 @@ class InactiveTabsAdapter( composeView = ComposeView(parent.context), lifecycleOwner = lifecycleOwner, tabsTrayStore = tabsTrayStore, - inactiveTabsInteractor = inactiveTabsInteractor, + interactor = inactiveTabsInteractor, ) } diff --git a/app/src/test/java/org/mozilla/fenix/tabstray/FloatingActionButtonBindingTest.kt b/app/src/test/java/org/mozilla/fenix/tabstray/FloatingActionButtonBindingTest.kt index 44a8ba805a..c759832bfc 100644 --- a/app/src/test/java/org/mozilla/fenix/tabstray/FloatingActionButtonBindingTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabstray/FloatingActionButtonBindingTest.kt @@ -28,7 +28,7 @@ class FloatingActionButtonBindingTest { val coroutinesTestRule = MainCoroutineRule() private val actionButton: ExtendedFloatingActionButton = mockk(relaxed = true) - private val browserTrayInteractor: BrowserTrayInteractor = mockk(relaxed = true) + private val interactor: BrowserTrayInteractor = mockk(relaxed = true) @Before fun setup() { @@ -47,7 +47,7 @@ class FloatingActionButtonBindingTest { val fabBinding = FloatingActionButtonBinding( tabsTrayStore, actionButton, - browserTrayInteractor, + interactor, ) fabBinding.start() @@ -64,7 +64,7 @@ class FloatingActionButtonBindingTest { val fabBinding = FloatingActionButtonBinding( tabsTrayStore, actionButton, - browserTrayInteractor, + interactor, ) fabBinding.start() @@ -81,7 +81,7 @@ class FloatingActionButtonBindingTest { val fabBinding = FloatingActionButtonBinding( tabsTrayStore, actionButton, - browserTrayInteractor, + interactor, ) fabBinding.start() @@ -98,7 +98,7 @@ class FloatingActionButtonBindingTest { val fabBinding = FloatingActionButtonBinding( tabsTrayStore, actionButton, - browserTrayInteractor, + interactor, ) fabBinding.start() diff --git a/app/src/test/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolderTest.kt b/app/src/test/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolderTest.kt index 7b0739579d..e60e755666 100644 --- a/app/src/test/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolderTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabstray/browser/AbstractBrowserTabViewHolderTest.kt @@ -165,7 +165,7 @@ class AbstractBrowserTabViewHolderTest { trayStore: TabsTrayStore, selectionHolder: SelectionHolder?, store: BrowserStore, - override val browserTrayInteractor: BrowserTrayInteractor, + override val interactor: BrowserTrayInteractor, featureName: String = "Test", ) : AbstractBrowserTabViewHolder(itemView, imageLoader, trayStore, selectionHolder, featureName, store) { override val thumbnailSize: Int diff --git a/app/src/test/java/org/mozilla/fenix/tabstray/browser/BrowserTabsAdapterTest.kt b/app/src/test/java/org/mozilla/fenix/tabstray/browser/BrowserTabsAdapterTest.kt index 2ae860877c..3d9dc53cd5 100644 --- a/app/src/test/java/org/mozilla/fenix/tabstray/browser/BrowserTabsAdapterTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabstray/browser/BrowserTabsAdapterTest.kt @@ -64,7 +64,7 @@ class BrowserTabsAdapterTest { val holder = spyk( BrowserTabViewHolder.ListViewHolder( imageLoader = mockk(), - browserTrayInteractor = interactor, + interactor = interactor, store = store, selectionHolder = null, itemView = binding.root,