diff --git a/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt b/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt index 08de5f2dcd..577e7ba65e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt @@ -21,7 +21,7 @@ import org.mozilla.fenix.ext.components import org.mozilla.fenix.helpers.HomeActivityTestRule // BEFORE INCREASING THESE VALUES, PLEASE CONSULT WITH THE PERF TEAM. -private const val EXPECTED_SUPPRESSION_COUNT = 21 +private const val EXPECTED_SUPPRESSION_COUNT = 19 @Suppress("TopLevelPropertyNaming") // it's silly this would have a different naming convention b/c no const private val EXPECTED_RUNBLOCKING_RANGE = 0..1 // CI has +1 counts compared to local runs: increment these together private const val EXPECTED_RECYCLER_VIEW_CONSTRAINT_LAYOUT_CHILDREN = 4 diff --git a/app/src/main/java/org/mozilla/fenix/components/tips/TipManager.kt b/app/src/main/java/org/mozilla/fenix/components/tips/TipManager.kt deleted file mode 100644 index 9a58953d74..0000000000 --- a/app/src/main/java/org/mozilla/fenix/components/tips/TipManager.kt +++ /dev/null @@ -1,39 +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.components.tips - -import android.graphics.drawable.Drawable - -sealed class TipType { - data class Button(val text: String, val action: () -> Unit) : TipType() -} - -open class Tip( - val type: TipType, - val identifier: String, - val title: String, - val description: String, - val learnMoreURL: String?, - val titleDrawable: Drawable? = null -) - -interface TipProvider { - val tip: Tip? - val shouldDisplay: Boolean -} - -interface TipManager { - fun getTip(): Tip? -} - -class FenixTipManager( - private val providers: List -) : TipManager { - override fun getTip(): Tip? { - return providers - .firstOrNull { it.shouldDisplay } - ?.tip - } -} diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 0aef9018cc..9da4359c63 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -89,7 +89,6 @@ import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.components.TabCollectionStorage import org.mozilla.fenix.components.accounts.AccountState import org.mozilla.fenix.components.metrics.Event -import org.mozilla.fenix.components.tips.FenixTipManager import org.mozilla.fenix.components.toolbar.FenixTabCounterMenu import org.mozilla.fenix.components.toolbar.ToolbarPosition import org.mozilla.fenix.databinding.FragmentHomeBinding @@ -244,11 +243,6 @@ class HomeFragment : Fragment() { expandedCollections = emptySet(), mode = currentMode.getCurrentMode(), topSites = getTopSites(components), - tip = components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { - FenixTipManager( - listOf() - ).getTip() - }, recentBookmarks = emptyList(), showCollectionPlaceholder = components.settings.showCollectionsPlaceholderOnHome, showSetAsDefaultBrowserCard = components.settings.shouldShowSetAsDefaultBrowserCard(), @@ -696,11 +690,6 @@ class HomeFragment : Fragment() { collections = components.core.tabCollectionStorage.cachedTabCollections, mode = currentMode.getCurrentMode(), topSites = getTopSites(components), - tip = components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { - FenixTipManager( - listOf() - ).getTip() - }, showCollectionPlaceholder = components.settings.showCollectionsPlaceholderOnHome, // Provide an initial state for recent tabs to prevent re-rendering on the home screen. // This will otherwise cause a visual jump as the section gets rendered from no state diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragmentStore.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragmentStore.kt index f11f582048..76230f4b92 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragmentStore.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragmentStore.kt @@ -13,7 +13,6 @@ import mozilla.components.lib.state.Middleware import mozilla.components.lib.state.State import mozilla.components.lib.state.Store import mozilla.components.service.pocket.PocketRecommendedStory -import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.ext.filterOutTab import org.mozilla.fenix.ext.getFilteredStories import org.mozilla.fenix.ext.recentSearchGroup @@ -45,7 +44,6 @@ class HomeFragmentStore( * in the [HomeFragment]. * @property mode The state of the [HomeFragment] UI. * @property topSites The list of [TopSite] in the [HomeFragment]. - * @property tip The current [Tip] to show on the [HomeFragment]. * @property showCollectionPlaceholder If true, shows a placeholder when there are no collections. * @property showSetAsDefaultBrowserCard If true, shows the default browser card * @property recentTabs The list of recent [RecentTab] in the [HomeFragment]. @@ -60,7 +58,6 @@ data class HomeFragmentState( val expandedCollections: Set = emptySet(), val mode: Mode = Mode.Normal, val topSites: List = emptyList(), - val tip: Tip? = null, val showCollectionPlaceholder: Boolean = false, val showSetAsDefaultBrowserCard: Boolean = false, val recentTabs: List = emptyList(), @@ -76,7 +73,6 @@ sealed class HomeFragmentAction : Action { val topSites: List, val mode: Mode, val collections: List, - val tip: Tip? = null, val showCollectionPlaceholder: Boolean, val recentTabs: List, val recentBookmarks: List, @@ -90,7 +86,6 @@ sealed class HomeFragmentAction : Action { data class CollectionsChange(val collections: List) : HomeFragmentAction() data class ModeChange(val mode: Mode) : HomeFragmentAction() data class TopSitesChange(val topSites: List) : HomeFragmentAction() - data class RemoveTip(val tip: Tip) : HomeFragmentAction() data class RecentTabsChange(val recentTabs: List) : HomeFragmentAction() data class RemoveRecentTab(val recentTab: RecentTab) : HomeFragmentAction() data class RecentBookmarksChange(val recentBookmarks: List) : HomeFragmentAction() @@ -122,7 +117,6 @@ private fun homeFragmentStateReducer( collections = action.collections, mode = action.mode, topSites = action.topSites, - tip = action.tip, recentBookmarks = action.recentBookmarks, recentTabs = action.recentTabs, recentHistory = if (action.recentHistory.isNotEmpty() && action.recentTabs.isNotEmpty()) { @@ -146,9 +140,6 @@ private fun homeFragmentStateReducer( is HomeFragmentAction.CollectionsChange -> state.copy(collections = action.collections) is HomeFragmentAction.ModeChange -> state.copy(mode = action.mode) is HomeFragmentAction.TopSitesChange -> state.copy(topSites = action.topSites) - is HomeFragmentAction.RemoveTip -> { - state.copy(tip = null) - } is HomeFragmentAction.RemoveCollectionsPlaceholder -> { state.copy(showCollectionPlaceholder = false) } diff --git a/app/src/main/java/org/mozilla/fenix/home/blocklist/BlocklistMiddleware.kt b/app/src/main/java/org/mozilla/fenix/home/blocklist/BlocklistMiddleware.kt index 879c730006..9855fc0cfb 100644 --- a/app/src/main/java/org/mozilla/fenix/home/blocklist/BlocklistMiddleware.kt +++ b/app/src/main/java/org/mozilla/fenix/home/blocklist/BlocklistMiddleware.kt @@ -92,7 +92,6 @@ class BlocklistMiddleware( topSites = topSites, mode = mode, collections = collections, - tip = tip, showCollectionPlaceholder = showCollectionPlaceholder ) } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt index dc3f9f184f..614d255b18 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt @@ -17,7 +17,6 @@ import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.top.sites.TopSite import mozilla.components.ui.widgets.WidgetSiteItemView import org.mozilla.fenix.components.Components -import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.home.BottomSpacerViewHolder import org.mozilla.fenix.home.HomeFragmentStore import org.mozilla.fenix.home.TopPlaceholderViewHolder @@ -45,15 +44,11 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingSe import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingThemePickerViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingToolbarPositionPickerViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingTrackingProtectionViewHolder -import org.mozilla.fenix.home.tips.ButtonTipViewHolder import org.mozilla.fenix.home.topsites.TopSitePagerViewHolder import mozilla.components.feature.tab.collections.Tab as ComponentTab sealed class AdapterItem(@LayoutRes val viewType: Int) { object TopPlaceholderItem : AdapterItem(TopPlaceholderViewHolder.LAYOUT_ID) - data class TipItem(val tip: Tip) : AdapterItem( - ButtonTipViewHolder.LAYOUT_ID - ) /** * Contains a set of [Pair]s where [Pair.first] is the index of the changed [TopSite] and @@ -260,7 +255,6 @@ class SessionControlAdapter( val view = LayoutInflater.from(parent.context).inflate(viewType, parent, false) return when (viewType) { TopPlaceholderViewHolder.LAYOUT_ID -> TopPlaceholderViewHolder(view) - ButtonTipViewHolder.LAYOUT_ID -> ButtonTipViewHolder(view, interactor) TopSitePagerViewHolder.LAYOUT_ID -> TopSitePagerViewHolder(view, viewLifecycleOwner, interactor) PrivateBrowsingDescriptionViewHolder.LAYOUT_ID -> PrivateBrowsingDescriptionViewHolder( view, @@ -350,10 +344,6 @@ class SessionControlAdapter( override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { val item = getItem(position) when (holder) { - is ButtonTipViewHolder -> { - val tipItem = item as AdapterItem.TipItem - holder.bind(tipItem.tip) - } is TopPlaceholderViewHolder -> { holder.bind() } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt index c312399185..45ad9f84fe 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt @@ -40,7 +40,6 @@ import org.mozilla.fenix.components.TabCollectionStorage import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.components.metrics.MetricsUtils -import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.nav @@ -148,11 +147,6 @@ interface SessionControlController { */ fun handleToggleCollectionExpanded(collection: TabCollection, expand: Boolean) - /** - * @see [TipInteractor.onCloseTip] - */ - fun handleCloseTip(tip: Tip) - /** * @see [ToolbarInteractor.onPasteAndGo] */ @@ -530,10 +524,6 @@ class DefaultSessionControlController( fragmentStore.dispatch(HomeFragmentAction.CollectionExpanded(collection, expand)) } - override fun handleCloseTip(tip: Tip) { - fragmentStore.dispatch(HomeFragmentAction.RemoveTip(tip)) - } - private fun showTabTrayCollectionCreation() { val directions = HomeFragmentDirections.actionGlobalTabsTrayFragment( enterMultiselect = true diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt index ed197eb7d9..4def57b25c 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt @@ -9,7 +9,6 @@ import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.top.sites.TopSite import mozilla.components.service.pocket.PocketRecommendedStory import org.mozilla.fenix.browser.browsingmode.BrowsingMode -import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.home.HomeFragmentState import org.mozilla.fenix.home.pocket.PocketRecommendedStoriesCategory import org.mozilla.fenix.home.pocket.PocketStoriesController @@ -167,13 +166,6 @@ interface OnboardingInteractor { fun showOnboardingDialog() } -interface TipInteractor { - /** - * Dismisses the tip view adapter - */ - fun onCloseTip(tip: Tip) -} - interface CustomizeHomeIteractor { /** * Opens the customize home settings page. @@ -247,8 +239,8 @@ interface ExperimentCardInteractor { /** * Interactor for the Home screen. Provides implementations for the CollectionInteractor, - * OnboardingInteractor, TopSiteInteractor, TipInteractor, TabSessionInteractor, - * ToolbarInteractor, ExperimentCardInteractor, RecentTabInteractor, RecentBookmarksInteractor + * OnboardingInteractor, TopSiteInteractor, TabSessionInteractor, ToolbarInteractor, + * ExperimentCardInteractor, RecentTabInteractor, RecentBookmarksInteractor * and others. */ @SuppressWarnings("TooManyFunctions") @@ -261,7 +253,6 @@ class SessionControlInteractor( ) : CollectionInteractor, OnboardingInteractor, TopSiteInteractor, - TipInteractor, TabSessionInteractor, ToolbarInteractor, ExperimentCardInteractor, @@ -343,10 +334,6 @@ class SessionControlInteractor( controller.handleCreateCollection() } - override fun onCloseTip(tip: Tip) { - controller.handleCloseTip(tip) - } - override fun onPrivateBrowsingLearnMoreClicked() { controller.handlePrivateBrowsingLearnMoreClicked() } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt index 7517d0d293..170c55cd97 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt @@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.top.sites.TopSite import mozilla.components.service.pocket.PocketRecommendedStory -import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.home.HomeFragmentState @@ -34,7 +33,6 @@ internal fun normalModeAdapterItems( topSites: List, collections: List, expandedCollections: Set, - tip: Tip?, recentBookmarks: List, showCollectionsPlaceholder: Boolean, showSetAsDefaultBrowserCard: Boolean, @@ -48,8 +46,6 @@ internal fun normalModeAdapterItems( // Add a synchronous, unconditional and invisible placeholder so home is anchored to the top when created. items.add(AdapterItem.TopPlaceholderItem) - tip?.let { items.add(AdapterItem.TipItem(it)) } - if (showSetAsDefaultBrowserCard) { items.add(AdapterItem.ExperimentDefaultBrowserCard) } @@ -157,7 +153,6 @@ private fun HomeFragmentState.toAdapterList(): List = when (mode) { topSites, collections, expandedCollections, - tip, recentBookmarks, showCollectionPlaceholder, showSetAsDefaultBrowserCard, diff --git a/app/src/main/java/org/mozilla/fenix/home/tips/ButtonTipViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/tips/ButtonTipViewHolder.kt deleted file mode 100644 index 972659b78c..0000000000 --- a/app/src/main/java/org/mozilla/fenix/home/tips/ButtonTipViewHolder.kt +++ /dev/null @@ -1,74 +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.home.tips - -import android.view.View -import androidx.core.view.isVisible -import org.mozilla.fenix.BrowserDirection -import org.mozilla.fenix.HomeActivity -import org.mozilla.fenix.R -import org.mozilla.fenix.components.tips.Tip -import org.mozilla.fenix.components.tips.TipType -import org.mozilla.fenix.databinding.ButtonTipItemBinding -import org.mozilla.fenix.ext.addUnderline -import org.mozilla.fenix.ext.components -import org.mozilla.fenix.home.sessioncontrol.SessionControlInteractor -import org.mozilla.fenix.utils.Settings -import org.mozilla.fenix.utils.view.ViewHolder - -class ButtonTipViewHolder( - private val view: View, - private val interactor: SessionControlInteractor, - private val settings: Settings = view.context.components.settings -) : ViewHolder(view) { - - var tip: Tip? = null - - fun bind(tip: Tip) { - val binding = ButtonTipItemBinding.bind(view) - require(tip.type is TipType.Button) - - this.tip = tip - - with(binding) { - tipHeaderText.text = tip.title - tip.titleDrawable?.let { - tipHeaderText.setCompoundDrawablesWithIntrinsicBounds(it, null, null, null) - } - tipDescriptionText.text = tip.description - tipButton.text = tip.type.text - - tipLearnMore.isVisible = tip.learnMoreURL != null - if (tip.learnMoreURL != null) { - tipLearnMore.addUnderline() - - tipLearnMore.setOnClickListener { - (itemView.context as HomeActivity).openToBrowserAndLoad( - searchTermOrURL = tip.learnMoreURL, - newTab = true, - from = BrowserDirection.FromHome - ) - } - } - - tipButton.setOnClickListener { - tip.type.action.invoke() - } - - tipClose.setOnClickListener { - settings.preferences - .edit() - .putBoolean(tip.identifier, false) - .apply() - - interactor.onCloseTip(tip) - } - } - } - - companion object { - const val LAYOUT_ID = R.layout.button_tip_item - } -} diff --git a/app/src/main/res/layout/button_tip_item.xml b/app/src/main/res/layout/button_tip_item.xml deleted file mode 100644 index 5cd8d139a1..0000000000 --- a/app/src/main/res/layout/button_tip_item.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - -