tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 78fa1febc0781adb03fd3fa706d729270116bc50
parent 9ca8631c1dfe0e21be7d64376b46e5b7bee98fc8
Author: Roger Yang <royang@mozilla.com>
Date:   Thu, 23 Oct 2025 15:16:00 +0000

Bug 1994722 - Remove top sites suggestions. r=android-reviewers,skhan

Differential Revision: https://phabricator.services.mozilla.com/D268891

Diffstat:
Dmobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/TopSitesSuggestionProvider.kt | 92-------------------------------------------------------------------------------
Dmobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/TopSitesSuggestionProviderTest.kt | 175-------------------------------------------------------------------------------
Mmobile/android/fenix/app/nimbus.fml.yaml | 13-------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/FenixSearchMiddleware.kt | 2+-
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt | 2+-
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt | 9---------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchFragmentStateMapper.kt | 1-
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilder.kt | 17-----------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt | 6------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineFragment.kt | 9---------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt | 15---------------
Mmobile/android/fenix/app/src/main/res/values/preference_keys.xml | 1-
Mmobile/android/fenix/app/src/main/res/values/static_strings.xml | 2--
Mmobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml | 4----
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt | 39---------------------------------------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt | 2--
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilderTest.kt | 29-----------------------------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/fixtures/SearchFragmentState.kt | 1-
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt | 16----------------
19 files changed, 2 insertions(+), 433 deletions(-)

diff --git a/mobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/TopSitesSuggestionProvider.kt b/mobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/TopSitesSuggestionProvider.kt @@ -1,92 +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 mozilla.components.feature.awesomebar.provider - -import mozilla.components.browser.icons.BrowserIcons -import mozilla.components.browser.icons.IconRequest -import mozilla.components.concept.awesomebar.AwesomeBar -import mozilla.components.concept.engine.Engine -import mozilla.components.feature.awesomebar.facts.emitTopSiteSuggestionClickedFact -import mozilla.components.feature.awesomebar.facts.emitTopSiteSuggestionsDisplayedFact -import mozilla.components.feature.session.SessionUseCases -import mozilla.components.feature.top.sites.DefaultTopSitesStorage -import mozilla.components.feature.top.sites.TopSite -import java.lang.Integer.MAX_VALUE -import java.util.UUID - -/** - * Return 4 top sites by default. - */ -const val DEFAULT_TOP_SITE_LIMIT = 4 - -/** - * A [AwesomeBar.SuggestionProvider] implementation that provides suggestions from [DefaultTopSitesStorage]. - * - * @param topSitesStorage an instance of [DefaultTopSitesStorage] used to query top sites. - * @param loadUrlUseCase the use case invoked to load the url when the user clicks on the suggestion. - * @param icons optional instance of [BrowserIcons] to load favicons for top site URLs. - * @param engine optional [Engine] instance to call [Engine.speculativeConnect] for the - * first suggestion URL. - * @param maxNumberOfSuggestions optional parameter to specify the maximum number of returned suggestions, - * defaults to [DEFAULT_TOP_SITE_LIMIT]. - * @param suggestionsHeader optional parameter to specify if the suggestion should have a header. - * @param topSitesFilter optional callback to filter the top sites obtained from [topSitesStorage] - */ -class TopSitesSuggestionProvider( - private val topSitesStorage: DefaultTopSitesStorage, - private val loadUrlUseCase: SessionUseCases.LoadUrlUseCase, - private val icons: BrowserIcons? = null, - internal val engine: Engine? = null, - private val maxNumberOfSuggestions: Int = DEFAULT_TOP_SITE_LIMIT, - private val suggestionsHeader: String? = null, - private val topSitesFilter: (List<TopSite>) -> List<TopSite> = { topSites -> - topSites.filter { it is TopSite.Frecent || it is TopSite.Pinned } - }, -) : AwesomeBar.SuggestionProvider { - override val id: String = UUID.randomUUID().toString() - - override fun groupTitle(): String? { - return suggestionsHeader - } - - override suspend fun onInputChanged(text: String): List<AwesomeBar.Suggestion> { - if (text.isNotEmpty()) { - return emptyList() - } - - val suggestions = topSitesFilter(topSitesStorage.cachedTopSites) - .take(maxNumberOfSuggestions) - - suggestions.firstOrNull()?.url?.let { url -> engine?.speculativeConnect(url) } - - if (suggestions.isNotEmpty()) { - emitTopSiteSuggestionsDisplayedFact(suggestions.size) - } - - return suggestions.toAwesomebarSuggestions(this, icons, loadUrlUseCase) - } -} - -internal suspend fun Iterable<TopSite>.toAwesomebarSuggestions( - provider: AwesomeBar.SuggestionProvider, - icons: BrowserIcons?, - loadUrlUseCase: SessionUseCases.LoadUrlUseCase, -): List<AwesomeBar.Suggestion> { - val iconRequests = this.map { icons?.loadIcon(IconRequest(url = it.url, waitOnNetworkLoad = false)) } - return this.withIndex().zip(iconRequests) { (index, result), icon -> - AwesomeBar.Suggestion( - provider = provider, - icon = icon?.await()?.bitmap, - flags = setOf(AwesomeBar.Suggestion.Flag.HISTORY), - title = result.title, - editSuggestion = null, - onSuggestionClicked = { - loadUrlUseCase(result.url) - emitTopSiteSuggestionClickedFact(index) - }, - score = MAX_VALUE - index, - ) - } -} diff --git a/mobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/TopSitesSuggestionProviderTest.kt b/mobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/TopSitesSuggestionProviderTest.kt @@ -1,175 +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 mozilla.components.feature.awesomebar.provider - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import kotlinx.coroutines.test.runTest -import mozilla.components.concept.engine.Engine -import mozilla.components.concept.storage.TopFrecentSiteInfo -import mozilla.components.feature.awesomebar.facts.AwesomeBarFacts -import mozilla.components.feature.top.sites.DefaultTopSitesStorage -import mozilla.components.feature.top.sites.TopSite -import mozilla.components.support.base.Component -import mozilla.components.support.base.facts.Action -import mozilla.components.support.base.facts.processor.CollectionProcessor -import mozilla.components.support.test.mock -import mozilla.components.support.test.whenever -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentMatchers.anyString -import org.mockito.Mockito.doReturn -import org.mockito.Mockito.never -import org.mockito.Mockito.times -import org.mockito.Mockito.verify - -@RunWith(AndroidJUnit4::class) -class TopSitesSuggestionProviderTest { - // Contains 4 top sites, one for every top site type - private val topSites = listOf( - TopSite.Frecent( - id = 0, - title = "mozilla frecent", - url = "http://www.mozilla.com/frecent", - createdAt = 0, - ), - TopSite.Pinned( - id = 1, - title = "mozilla pinned", - url = "http://www.mozilla.com/pinned", - createdAt = 0, - ), - TopSite.Default( - id = 2, - title = "mozilla default", - url = "http://www.mozilla.com/default", - createdAt = 0, - ), - TopSite.Provided( - id = 3, - title = "mozilla provided", - url = "http://www.mozilla.com/provided", - clickUrl = "", - imageUrl = "", - impressionUrl = "", - createdAt = 0, - ), - ) - - @Test - fun `GIVEN text is not empty WHEN input is changed THEN provider returns an empty list`() = runTest { - val provider = TopSitesSuggestionProvider(mock(), mock()) - - val suggestions = provider.onInputChanged("fire") - assertTrue(suggestions.isEmpty()) - } - - @Test - fun `GIVEN text is empty WHEN input is changed THEN provider returns suggestions for only pinned and frecent sites from top sites storage by default`() = runTest { - val storage: DefaultTopSitesStorage = mock() - - whenever(storage.cachedTopSites).thenReturn(topSites) - - val provider = TopSitesSuggestionProvider(storage, mock()) - val suggestions = provider.onInputChanged("") - assertEquals(2, suggestions.size) - assertEquals(topSites[0].title, suggestions[0].title) - assertEquals(topSites[1].title, suggestions[1].title) - } - - @Test - fun `GIVEN custom top sites filter WHEN input is changed THEN provider returns suggestions from top sites storage using the filter`() = runTest { - val storage: DefaultTopSitesStorage = mock() - - whenever(storage.cachedTopSites).thenReturn(topSites) - - val provider = TopSitesSuggestionProvider( - topSitesStorage = storage, - loadUrlUseCase = mock(), - topSitesFilter = { it.filterIsInstance<TopSite.Default>() }, - ) - - val suggestions = provider.onInputChanged("") - assertEquals(1, suggestions.size) - assertEquals(topSites[2].title, suggestions[0].title) - } - - @Test - fun `GIVEN limit that is less than total number of results WHEN input is changed THEN provider returns suggestions within the limit`() = runTest { - val storage: DefaultTopSitesStorage = mock() - - whenever(storage.cachedTopSites).thenReturn(topSites) - - val provider = TopSitesSuggestionProvider( - topSitesStorage = storage, - loadUrlUseCase = mock(), - maxNumberOfSuggestions = 1, - ) - - val suggestions = provider.onInputChanged("") - assertEquals(1, suggestions.size) - } - - @Test - fun `GIVEN top sites cache is empty WHEN input is changed THEN provider returns an empty list`() = runTest { - val storage: DefaultTopSitesStorage = mock() - doReturn(emptyList<TopFrecentSiteInfo>()).`when`(storage).cachedTopSites - val provider = TopSitesSuggestionProvider( - topSitesStorage = storage, - loadUrlUseCase = mock(), - ) - - val suggestions = provider.onInputChanged("") - assertEquals(0, suggestions.size) - } - - @Test - fun `WHEN input is changed THEN provider calls speculativeConnect for URL of highest scored suggestion`() = runTest { - val storage: DefaultTopSitesStorage = mock() - val engine: Engine = mock() - val provider = TopSitesSuggestionProvider(storage, mock(), engine = engine) - - var suggestions = provider.onInputChanged("") - assertTrue(suggestions.isEmpty()) - verify(engine, never()).speculativeConnect(anyString()) - - whenever(storage.cachedTopSites).thenReturn(topSites) - - suggestions = provider.onInputChanged("") - assertEquals(2, suggestions.size) - verify(engine, times(1)).speculativeConnect(topSites[0].url) - } - - @Test - fun `GIVEN top site suggestion is clicked THEN suggestion clicked fact is emitted`() { - runTest { - val storage: DefaultTopSitesStorage = mock() - val engine: Engine = mock() - val provider = TopSitesSuggestionProvider(storage, mock(), engine = engine) - - var suggestions = provider.onInputChanged("") - assertTrue(suggestions.isEmpty()) - verify(engine, never()).speculativeConnect(anyString()) - - whenever(storage.cachedTopSites).thenReturn(topSites) - - suggestions = provider.onInputChanged("") - assertEquals(2, suggestions.size) - verify(engine, times(1)).speculativeConnect(topSites[0].url) - - CollectionProcessor.withFactCollection { facts -> - suggestions[1].onSuggestionClicked!!.invoke() - - assertEquals(1, facts.size) - facts[0].apply { - assertEquals(Component.FEATURE_AWESOMEBAR, component) - assertEquals(Action.INTERACTION, action) - assertEquals(AwesomeBarFacts.Items.TOP_SITE_SUGGESTION_CLICKED, item) - } - } - } - } -} diff --git a/mobile/android/fenix/app/nimbus.fml.yaml b/mobile/android/fenix/app/nimbus.fml.yaml @@ -719,19 +719,6 @@ features: type: Int default: 5 - top-sites-suggestions: - description: Enables top sites suggestions. - variables: - enabled: - description: > - Whether or not to enable top sites suggestions. - type: Boolean - default: true - max-suggestions: - description: The number of maximum suggestions. - type: Int - default: 2 - search-suggestions-on-homepage: description: Enables search suggestions on homepage. variables: diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/FenixSearchMiddleware.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/FenixSearchMiddleware.kt @@ -262,7 +262,7 @@ class FenixSearchMiddleware( query: String, ) { val shouldShowTrendingSearches = context.state.run { - (showTrendingSearches || showRecentSearches || showShortcutsSuggestions) && + (showTrendingSearches || showRecentSearches) && (searchStartedForCurrentUrl || FxNimbus.features.searchSuggestionsOnHomepage.value().enabled) } val shouldShowSearchSuggestions = with(context.state) { diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt @@ -498,7 +498,7 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler { observeSuggestionProvidersState() val shouldShowSuggestions = store.state.run { - (showTrendingSearches || showRecentSearches || showShortcutsSuggestions) && + (showTrendingSearches || showRecentSearches) && (query.isNotEmpty() || FxNimbus.features.searchSuggestionsOnHomepage.value().enabled) } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt @@ -150,7 +150,6 @@ sealed class SearchEngineSource { * in the AwesomeBar. Always `false` in private mode, or when a non-default engine is selected. * @property showTrendingSearches Whether the setting for showing trending searches is enabled or disabled. * @property showRecentSearches Whether the setting for showing recent searches is enabled or disabled. - * @property showShortcutsSuggestions Whether the setting for showing shortcuts suggestions is enabled or disabled. * @property showQrButton Whether or not to show the QR button. * @property tabId The ID of the current tab. * @property pastedText The text pasted from the long press toolbar menu. @@ -186,7 +185,6 @@ data class SearchFragmentState( val showNonSponsoredSuggestions: Boolean, val showTrendingSearches: Boolean, val showRecentSearches: Boolean, - val showShortcutsSuggestions: Boolean, val showQrButton: Boolean, val tabId: String?, val pastedText: String? = null, @@ -229,7 +227,6 @@ data class SearchFragmentState( showNonSponsoredSuggestions = false, showTrendingSearches = false, showRecentSearches = false, - showShortcutsSuggestions = false, showQrButton = false, tabId = null, pastedText = null, @@ -300,7 +297,6 @@ fun createInitialSearchFragmentState( components.core.store.state.search.selectedOrDefaultSearchEngine?.trendingUrl != null, ), showRecentSearches = settings.shouldShowRecentSearchSuggestions, - showShortcutsSuggestions = settings.shouldShowShortcutSuggestions, showQrButton = !isAndroidAutomotiveAvailable, tabId = tabId, pastedText = pastedText, @@ -484,7 +480,6 @@ private fun searchStateReducer(state: SearchFragmentState, action: SearchFragmen isTrendingSuggestionSupported = action.engine.trendingUrl != null, ), showRecentSearches = action.settings.shouldShowRecentSearchSuggestions, - showShortcutsSuggestions = action.settings.shouldShowShortcutSuggestions, ) is SearchFragmentAction.SearchShortcutEngineSelected -> state.copy( @@ -530,7 +525,6 @@ private fun searchStateReducer(state: SearchFragmentState, action: SearchFragmen isTrendingSuggestionSupported = action.engine.trendingUrl != null, ), showRecentSearches = action.settings.shouldShowRecentSearchSuggestions, - showShortcutsSuggestions = action.settings.shouldShowShortcutSuggestions, ) is SearchFragmentAction.SearchHistoryEngineSelected -> state.copy( @@ -551,7 +545,6 @@ private fun searchStateReducer(state: SearchFragmentState, action: SearchFragmen showNonSponsoredSuggestions = false, showTrendingSearches = false, showRecentSearches = false, - showShortcutsSuggestions = false, ) is SearchFragmentAction.SearchBookmarksEngineSelected -> state.copy( @@ -572,7 +565,6 @@ private fun searchStateReducer(state: SearchFragmentState, action: SearchFragmen showNonSponsoredSuggestions = false, showTrendingSearches = false, showRecentSearches = false, - showShortcutsSuggestions = false, ) is SearchFragmentAction.SearchTabsEngineSelected -> state.copy( @@ -593,7 +585,6 @@ private fun searchStateReducer(state: SearchFragmentState, action: SearchFragmen showNonSponsoredSuggestions = false, showTrendingSearches = false, showRecentSearches = false, - showShortcutsSuggestions = false, ) is SearchFragmentAction.UpdateQuery -> state.copy(query = action.query) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchFragmentStateMapper.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchFragmentStateMapper.kt @@ -26,6 +26,5 @@ fun SearchFragmentState.toSearchProviderState() = SearchProviderState( showNonSponsoredSuggestions = showNonSponsoredSuggestions, showTrendingSearches = showTrendingSearches, showRecentSearches = showRecentSearches, - showShortcutsSuggestions = showShortcutsSuggestions, searchEngineSource = searchEngineSource, ) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilder.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilder.kt @@ -20,7 +20,6 @@ import mozilla.components.feature.awesomebar.provider.SearchEngineSuggestionProv import mozilla.components.feature.awesomebar.provider.SearchSuggestionProvider import mozilla.components.feature.awesomebar.provider.SearchTermSuggestionsProvider import mozilla.components.feature.awesomebar.provider.SessionSuggestionProvider -import mozilla.components.feature.awesomebar.provider.TopSitesSuggestionProvider import mozilla.components.feature.awesomebar.provider.TrendingSearchProvider import mozilla.components.feature.fxsuggest.FxSuggestSuggestionProvider import mozilla.components.feature.search.SearchUseCases @@ -62,7 +61,6 @@ class SearchSuggestionsProvidersBuilder( val defaultCombinedHistoryProvider: CombinedHistorySuggestionProvider val shortcutsEnginePickerProvider: ShortcutsSuggestionProvider val defaultSearchSuggestionProvider: SearchSuggestionProvider - val defaultTopSitesSuggestionProvider: TopSitesSuggestionProvider val defaultTrendingSearchProvider: TrendingSearchProvider val defaultSearchActionProvider: SearchActionProvider var searchEngineSuggestionProvider: SearchEngineSuggestionProvider? @@ -114,15 +112,6 @@ class SearchSuggestionsProvidersBuilder( suggestionsHeader = suggestionsStringsProvider.forSearchEngineSuggestion(), ) - defaultTopSitesSuggestionProvider = - TopSitesSuggestionProvider( - topSitesStorage = components.core.topSitesStorage, - loadUrlUseCase = loadUrlUseCase, - icons = components.core.icons, - engine = engineForSpeculativeConnects, - maxNumberOfSuggestions = FxNimbus.features.topSitesSuggestions.value().maxSuggestions, - ) - defaultTrendingSearchProvider = TrendingSearchProvider( fetchClient = components.core.client, @@ -278,10 +267,6 @@ class SearchSuggestionsProvidersBuilder( providersToAdd.add(requireNotNull(searchEngineSuggestionProvider)) - if (state.showShortcutsSuggestions) { - providersToAdd.add(defaultTopSitesSuggestionProvider) - } - if (state.showTrendingSearches) { val suggestionHeader = state.searchEngineSource.searchEngine?.let { searchEngine -> suggestionsStringsProvider.forTrendingSearches(searchEngine) @@ -537,7 +522,6 @@ class SearchSuggestionsProvidersBuilder( * @property showNonSponsoredSuggestions Whether to show non-sponsored suggestions. * @property showTrendingSearches Whether to show trending searches. * @property showRecentSearches Whether to show recent searches. - * @property showShortcutsSuggestions Whether to show shortcuts suggestions. * @property searchEngineSource Hoe the current search engine was selected. */ data class SearchProviderState( @@ -556,7 +540,6 @@ class SearchSuggestionsProvidersBuilder( val showNonSponsoredSuggestions: Boolean, val showTrendingSearches: Boolean, val showRecentSearches: Boolean, - val showShortcutsSuggestions: Boolean, val searchEngineSource: SearchEngineSource, ) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt @@ -218,12 +218,6 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { onPreferenceChangeListener = SharedPreferenceUpdater() } - requirePreference<SwitchPreference>(R.string.pref_key_enable_shortcuts_suggestions).apply { - isVisible = true - isChecked = context.settings().isShortcutSuggestionsVisible - onPreferenceChangeListener = SharedPreferenceUpdater() - } - requirePreference<SwitchPreference>(R.string.pref_key_allow_settings_search).apply { isVisible = Config.channel.isNightlyOrDebug isChecked = context.settings().isSettingsSearchEnabled diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineFragment.kt @@ -53,9 +53,6 @@ class SearchEngineFragment : PreferenceFragmentCompat() { requirePreference<SwitchPreference>(R.string.pref_key_show_recent_search_suggestions).apply { isVisible = context.settings().isRecentSearchesVisible } - requirePreference<SwitchPreference>(R.string.pref_key_show_shortcuts_suggestions).apply { - isVisible = context.settings().isShortcutSuggestionsVisible - } view?.hideKeyboard() } @@ -112,11 +109,6 @@ class SearchEngineFragment : PreferenceFragmentCompat() { isChecked = context.settings().shouldShowBookmarkSuggestions } - val showShortcutsSuggestions = - requirePreference<SwitchPreference>(R.string.pref_key_show_shortcuts_suggestions).apply { - isChecked = context.settings().shouldShowShortcutSuggestions - } - val showSyncedTabsSuggestions = requirePreference<SwitchPreference>(R.string.pref_key_search_synced_tabs).apply { isChecked = context.settings().shouldShowSyncedTabsSuggestions @@ -148,7 +140,6 @@ class SearchEngineFragment : PreferenceFragmentCompat() { searchSuggestionsPreference.onPreferenceChangeListener = SharedPreferenceUpdater() showHistorySuggestions.onPreferenceChangeListener = SharedPreferenceUpdater() showBookmarkSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater() - showShortcutsSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater() showSyncedTabsSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater() showClipboardSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater() searchSuggestionsInPrivatePreference.onPreferenceChangeListener = SharedPreferenceUpdater() diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -756,21 +756,6 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = false, ) - /** - * Returns true if shortcut suggestions feature should be shown to the user. - */ - var isShortcutSuggestionsVisible by lazyFeatureFlagPreference( - key = appContext.getPreferenceKey(R.string.pref_key_enable_shortcuts_suggestions), - default = { FxNimbus.features.topSitesSuggestions.value().enabled }, - featureFlag = true, - ) - - /** - * Returns true if shortcut suggestions should be shown to the user. - */ - val shouldShowShortcutSuggestions: Boolean - get() = shortcutSuggestionsEnabled && isShortcutSuggestionsVisible - val shouldShowSyncedTabsSuggestions by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_search_synced_tabs), default = true, diff --git a/mobile/android/fenix/app/src/main/res/values/preference_keys.xml b/mobile/android/fenix/app/src/main/res/values/preference_keys.xml @@ -435,7 +435,6 @@ <string name="pref_key_enable_unified_trust_panel" translatable="false">pref_key_enable_unified_trust_panel</string> <string name="pref_key_enable_trending_searches" translatable="false">pref_key_enable_trending_searches</string> <string name="pref_key_enable_recent_searches" translatable="false">pref_key_enable_recent_searches</string> - <string name="pref_key_enable_shortcuts_suggestions" translatable="false">pref_key_enable_shortcuts_suggestions</string> <string name="pref_key_enable_composable_toolbar" translatable="false">pref_key_enable_composable_toolbar</string>" <string name="pref_key_enable_toolbar_redesign" translatable="false">pref_key_enable_toolbar_redesign</string>" <string name="pref_key_enable_address_sync" translatable="false">pref_key_enable_address_sync</string>" diff --git a/mobile/android/fenix/app/src/main/res/values/static_strings.xml b/mobile/android/fenix/app/src/main/res/values/static_strings.xml @@ -115,8 +115,6 @@ <string name="preferences_debug_settings_remote_search_configuration" translatable="false">Enable Remote Search Configuration (requires restart)</string> <!-- Label for enabling Recent Searches --> <string name="preferences_debug_settings_recent_searches" translatable="false">Enable Recent Searches</string> - <!-- Label for enabling Shortcut Suggestions --> - <string name="preferences_debug_settings_shortcuts_suggestions" translatable="false">Enable Shortcut Suggestions</string> <!-- Label for enabling Address Sync --> <string name="preferences_debug_settings_address_sync" translatable="false">Enable Address Sync for supported regions</string> <!-- Label for enabling Settings Search--> diff --git a/mobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml b/mobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml @@ -95,10 +95,6 @@ android:title="@string/preferences_debug_settings_recent_searches" app:iconSpaceReserved="false" /> <SwitchPreference - android:key="@string/pref_key_enable_shortcuts_suggestions" - android:title="@string/preferences_debug_settings_shortcuts_suggestions" - app:iconSpaceReserved="false" /> - <SwitchPreference android:defaultValue="false" android:key="@string/pref_key_enable_debug_drawer" android:title="@string/preferences_debug_settings_debug_drawer" diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt @@ -226,31 +226,6 @@ class FenixSearchMiddlewareTest { } @Test - fun `GIVEN should show shortcut suggestions and a query is set WHEN search is started THEN show search suggestions`() { - val defaultSearchEngine = fakeSearchEnginesState().selectedOrDefaultSearchEngine!! - val wasEngineSelectedByUser = false - val isSearchInPrivateMode = true - every { settings.shouldShowShortcutSuggestions } returns true - every { settings.shouldShowSearchSuggestions } returns true - val (middleware, store) = buildMiddlewareAndAddToSearchStore() - val expectedSuggestionProviders = setOf(mockk<SuggestionProvider>(), mockk<SuggestionProvider>()) - val expectedSearchSuggestionsProvider: SearchSuggestionsProvidersBuilder = mockk { - every { getProvidersToAdd(any()) } returns expectedSuggestionProviders - } - every { middleware.buildSearchSuggestionsProvider(any()) } returns expectedSearchSuggestionsProvider - - store.dispatch(SearchFragmentAction.UpdateQuery("test")) - store.dispatch(SearchStarted(null, wasEngineSelectedByUser, isSearchInPrivateMode, false)) - store.waitUntilIdle() - - verify { engine.speculativeCreateSession(isSearchInPrivateMode) } - assertEquals(expectedSearchSuggestionsProvider, middleware.suggestionsProvidersBuilder) - assertEquals(expectedSuggestionProviders.toList(), store.state.searchSuggestionsProviders.toList()) - assertEquals(defaultSearchEngine.id, store.state.searchEngineSource.searchEngine?.id) - assertTrue(store.state.shouldShowSearchSuggestions) - } - - @Test fun `GIVEN the search query is updated WHEN it is different than the current URL and not empty THEN show search suggestions`() { val (_, store) = buildMiddlewareAndAddToSearchStore() every { settings.shouldShowSearchSuggestions } returns true @@ -308,20 +283,6 @@ class FenixSearchMiddlewareTest { } @Test - fun `GIVEN shortcuts suggestions are enabled WHEN search starts starts for the current webpage THEN show new search suggestions`() { - val (_, store) = buildMiddlewareAndAddToSearchStore() - every { settings.shouldShowShortcutSuggestions } returns true - every { settings.shouldShowSearchSuggestions } returns true - val defaultSearchEngine = fakeSearchEnginesState().selectedOrDefaultSearchEngine - - store.dispatch(SearchStarted(defaultSearchEngine, false, false, true)).joinBlocking() - - searchActionsCaptor.assertLastAction(SearchSuggestionsVisibilityUpdated::class) { - assertTrue(it.visible) - } - } - - @Test fun `GIVEN browsing mode is private and user has allowed suggestions in private mode WHEN search query is different than the current URL and not empty THEN show search suggestions`() { val (_, store) = buildMiddlewareAndAddToSearchStore() every { settings.shouldShowSearchSuggestions } returns true diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt @@ -768,7 +768,6 @@ class SearchFragmentStoreTest { every { settings.trendingSearchSuggestionsEnabled } returns true every { settings.isTrendingSearchesVisible } returns true every { settings.shouldShowRecentSearchSuggestions } returns true - every { settings.shouldShowShortcutSuggestions } returns true store.dispatch( SearchFragmentAction.SearchShortcutEngineSelected( @@ -796,7 +795,6 @@ class SearchFragmentStoreTest { assertFalse(store.state.showNonSponsoredSuggestions) assertFalse(store.state.showTrendingSearches) assertTrue(store.state.showRecentSearches) - assertTrue(store.state.showShortcutsSuggestions) } @Test diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilderTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilderTest.kt @@ -18,7 +18,6 @@ import mozilla.components.feature.awesomebar.provider.SearchEngineSuggestionProv import mozilla.components.feature.awesomebar.provider.SearchSuggestionProvider import mozilla.components.feature.awesomebar.provider.SearchTermSuggestionsProvider import mozilla.components.feature.awesomebar.provider.SessionSuggestionProvider -import mozilla.components.feature.awesomebar.provider.TopSitesSuggestionProvider import mozilla.components.feature.awesomebar.provider.TrendingSearchProvider import mozilla.components.feature.fxsuggest.FxSuggestSuggestionProvider import mozilla.components.feature.syncedtabs.SyncedTabsStorageSuggestionProvider @@ -1422,32 +1421,6 @@ class SearchSuggestionsProvidersBuilderTest { } @Test - fun `GIVEN should show shortcuts suggestions WHEN configuring providers THEN add the top sites provider and top sites suggestion providers`() { - val settings: Settings = mockk(relaxed = true) - every { components.settings } returns settings - val state = getSearchProviderState( - showShortcutsSuggestions = true, - ) - - val result = builder.getProvidersToAdd(state) - - assertEquals(1, result.filterIsInstance<TopSitesSuggestionProvider>().size) - } - - @Test - fun `GIVEN should not show shortcuts suggestions WHEN configuring providers THEN don't add the top sites provider`() { - val settings: Settings = mockk(relaxed = true) - every { components.settings } returns settings - val state = getSearchProviderState( - showShortcutsSuggestions = false, - ) - - val result = builder.getProvidersToAdd(state) - - assertEquals(0, result.filterIsInstance<TopSitesSuggestionProvider>().size) - } - - @Test fun `GIVEN should show recent searches WHEN configuring providers THEN add the recent search suggestions provider`() { val settings: Settings = mockk(relaxed = true) every { components.settings } returns settings @@ -1498,7 +1471,6 @@ private fun getSearchProviderState( showNonSponsoredSuggestions: Boolean = true, showTrendingSearches: Boolean = true, showRecentSearches: Boolean = true, - showShortcutsSuggestions: Boolean = true, ) = SearchProviderState( showSearchShortcuts = showSearchShortcuts, showSearchTermHistory = showSearchTermHistory, @@ -1515,6 +1487,5 @@ private fun getSearchProviderState( showNonSponsoredSuggestions = showNonSponsoredSuggestions, showTrendingSearches = showTrendingSearches, showRecentSearches = showRecentSearches, - showShortcutsSuggestions = showShortcutsSuggestions, searchEngineSource = searchEngineSource, ) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/fixtures/SearchFragmentState.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/fixtures/SearchFragmentState.kt @@ -40,7 +40,6 @@ val EMPTY_SEARCH_FRAGMENT_STATE = SearchFragmentState( showNonSponsoredSuggestions = false, showTrendingSearches = false, showRecentSearches = false, - showShortcutsSuggestions = false, showQrButton = false, tabId = null, pastedText = null, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt @@ -1132,22 +1132,6 @@ class SettingsTest { } @Test - fun `GIVEN shortcut suggestions is enable THEN should show shortcut suggestions only if shortcut suggestions is visible`() { - val settings = spyk(settings) - every { settings.shortcutSuggestionsEnabled } returns true - every { settings.isShortcutSuggestionsVisible } returns true - assertTrue(settings.shouldShowShortcutSuggestions) - - every { settings.shortcutSuggestionsEnabled } returns true - every { settings.isShortcutSuggestionsVisible } returns false - assertFalse(settings.shouldShowShortcutSuggestions) - - every { settings.shortcutSuggestionsEnabled } returns false - every { settings.isShortcutSuggestionsVisible } returns true - assertFalse(settings.shouldShowShortcutSuggestions) - } - - @Test fun `GIVEN the conditions to show a prompt are not met WHEN checking prompt eligibility THEN shouldShowSetAsDefaultPrompt is false`() { settings.numberOfSetAsDefaultPromptShownTimes = 0 settings.lastSetAsDefaultPromptShownTimeInMillis = System.currentTimeMillis()