Commit fb27b78c authored by clairehurst's avatar clairehurst 🌱
Browse files

fixup! [android] Disable features and functionality

#42230 Remove or disable search settings we do not use

Also cleaned up commented out code
parent af879fe5
Loading
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -135,12 +135,6 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
            onPreferenceChangeListener = SharedPreferenceUpdater()
        }

        requirePreference<SwitchPreference>(R.string.pref_key_enable_recent_searches).apply {
            isVisible = true
            isChecked = context.settings().isRecentSearchesVisible
            onPreferenceChangeListener = SharedPreferenceUpdater()
        }

        requirePreference<SwitchPreference>(R.string.pref_key_enable_shortcuts_suggestions).apply {
            isVisible = true
            isChecked = context.settings().isShortcutSuggestionsVisible
+0 −86
Original line number Diff line number Diff line
@@ -38,29 +38,6 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
            isVisible = !context.settings().shouldDisableNormalMode
        }

        findPreference<SwitchPreference>(getString(R.string.pref_key_search_browsing_history))?.apply {
            isVisible = !context.settings().shouldDisableNormalMode
        }

        // requirePreference<SwitchPreference>(R.string.pref_key_show_sponsored_suggestions).apply {
        //     isVisible = context.settings().enableFxSuggest
        // }
        // requirePreference<SwitchPreference>(R.string.pref_key_show_nonsponsored_suggestions).apply {
        //     isVisible = context.settings().enableFxSuggest
        // }
        // requirePreference<Preference>(R.string.pref_key_learn_about_fx_suggest).apply {
        //     isVisible = context.settings().enableFxSuggest
        // }
        // requirePreference<CheckBoxPreference>(R.string.pref_key_show_trending_search_suggestions).apply {
        //     isVisible = context.settings().isTrendingSearchesVisible
        // }
        // 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()
    }

@@ -80,45 +57,16 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
                isChecked = context.settings().shouldShowSearchSuggestions
            }

        val trendingSearchSuggestionsPreference =
            requirePreference<CheckBoxPreference>(R.string.pref_key_show_trending_search_suggestions).apply {
                isVisible = context.settings().isTrendingSearchesVisible
                isEnabled = requireContext().components.core.store.state.search
                    .selectedOrDefaultSearchEngine?.trendingUrl != null &&
                    context.settings().shouldShowSearchSuggestions
            }

        val recentSearchSuggestionsPreference =
            requirePreference<SwitchPreference>(R.string.pref_key_show_recent_search_suggestions).apply {
                isChecked = context.settings().shouldShowRecentSearchSuggestions
            }

        val autocompleteURLsPreference =
            requirePreference<SwitchPreference>(R.string.pref_key_enable_autocomplete_urls).apply {
                isChecked = context.settings().shouldAutocompleteInAwesomebar
            }

        val searchSuggestionsInPrivatePreference =
            requirePreference<CheckBoxPreference>(R.string.pref_key_show_search_suggestions_in_private).apply {
                isChecked = context.settings().shouldShowSearchSuggestionsInPrivate
                isEnabled = context.settings().shouldShowSearchSuggestions
            }

        val showHistorySuggestions =
            requirePreference<SwitchPreference>(R.string.pref_key_search_browsing_history).apply {
                isChecked = context.settings().shouldShowHistorySuggestions
            }

        val showBookmarkSuggestions =
            requirePreference<SwitchPreference>(R.string.pref_key_search_bookmarks).apply {
                isChecked = context.settings().shouldShowBookmarkSuggestions
            }

        // val showSyncedTabsSuggestions =
        //     requirePreference<SwitchPreference>(R.string.pref_key_search_synced_tabs).apply {
        //         isChecked = context.settings().shouldShowSyncedTabsSuggestions
        //     }

        val showClipboardSuggestions =
            requirePreference<SwitchPreference>(R.string.pref_key_show_clipboard_suggestions).apply {
                isChecked = context.settings().shouldShowClipboardSuggestions
@@ -129,32 +77,9 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
                isChecked = context.settings().shouldShowVoiceSearch
            }

        // val showSponsoredSuggestionsPreference =
        //     requirePreference<SwitchPreference>(R.string.pref_key_show_sponsored_suggestions).apply {
        //         isChecked = context.settings().showSponsoredSuggestions
        //         summary = getString(
        //             R.string.preferences_show_sponsored_suggestions_summary,
        //             getString(R.string.app_name),
        //         )
        //     }

        // val showNonSponsoredSuggestionsPreference =
        //     requirePreference<SwitchPreference>(R.string.pref_key_show_nonsponsored_suggestions).apply {
        //         isChecked = context.settings().showNonSponsoredSuggestions
        //         title = getString(
        //             R.string.preferences_show_nonsponsored_suggestions,
        //             getString(R.string.app_name),
        //         )
        //     }

        searchSuggestionsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()
        showHistorySuggestions.onPreferenceChangeListener = SharedPreferenceUpdater()
        showBookmarkSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater()
        // showSyncedTabsSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater()
        showClipboardSuggestions.onPreferenceChangeListener = SharedPreferenceUpdater()
        searchSuggestionsInPrivatePreference.onPreferenceChangeListener = SharedPreferenceUpdater()
        trendingSearchSuggestionsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()
        recentSearchSuggestionsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()
        showVoiceSearchPreference.onPreferenceChangeListener = object : Preference.OnPreferenceChangeListener {
            override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
                val newBooleanValue = newValue as? Boolean ?: return false
@@ -166,17 +91,6 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
            }
        }
        autocompleteURLsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()

        searchSuggestionsPreference.setOnPreferenceClickListener {
            searchSuggestionsInPrivatePreference.isEnabled = searchSuggestionsPreference.isChecked && !requireContext().settings().shouldDisableNormalMode
            trendingSearchSuggestionsPreference.isEnabled =
                requireContext().components.core.store.state.search.selectedOrDefaultSearchEngine
                    ?.trendingUrl != null && searchSuggestionsPreference.isChecked && !requireContext().settings().shouldDisableNormalMode
            true
        }

        // showSponsoredSuggestionsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()
        // showNonSponsoredSuggestionsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()
    }

    override fun onPreferenceTreeClick(preference: Preference): Boolean {
+2 −2
Original line number Diff line number Diff line
@@ -1224,7 +1224,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
    @VisibleForTesting
    internal var trendingSearchSuggestionsEnabled by booleanPreference(
        appContext.getPreferenceKey(R.string.pref_key_show_trending_search_suggestions),
        default = true,
        default = false,
    )

    /**
@@ -1233,7 +1233,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
    @VisibleForTesting
    internal var recentSearchSuggestionsEnabled by booleanPreference(
        appContext.getPreferenceKey(R.string.pref_key_show_recent_search_suggestions),
        default = true,
        default = false,
    )

    /**
+0 −55
Original line number Diff line number Diff line
@@ -30,58 +30,8 @@
            android:defaultValue="true"
            android:key="@string/pref_key_show_search_suggestions"
            android:title="@string/preferences_show_search_suggestions" />
        <CheckBoxPreference
            android:defaultValue="false"
            android:dependency="@string/pref_key_show_search_suggestions"
            android:key="@string/pref_key_show_search_suggestions_in_private"
            android:layout="@layout/checkbox_left_preference"
            android:title="@string/preferences_show_search_suggestions_in_private"
            app:iconSpaceReserved="false" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:dependency="@string/pref_key_show_search_suggestions"
            android:key="@string/pref_key_show_trending_search_suggestions"
            android:layout="@layout/checkbox_left_preference"
            android:title="@string/preferences_show_trending_search_suggestions"
            app:iconSpaceReserved="false" />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:defaultValue="true"
            android:key="@string/pref_key_show_recent_search_suggestions"
            android:title="@string/preferences_show_recent_search_suggestions" />
    </PreferenceCategory>

    <!-- <PreferenceCategory
        android:title="@string/preference_search_address_bar_fx_suggest"
        android:selectable="false"
        app:iconSpaceReserved="false"
        android:layout="@layout/preference_category_no_icon_style">
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:defaultValue="true"
            android:key="@string/pref_key_show_shortcuts_suggestions"
            android:title='@string/preferences_show_shortcuts' />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:defaultValue="true"
            android:key="@string/pref_key_search_synced_tabs"
            android:title='@string/preferences_search_synced_tabs' />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:key="@string/pref_key_show_nonsponsored_suggestions"
            android:title="@string/preferences_show_nonsponsored_suggestions"
            android:summary="@string/preferences_show_nonsponsored_suggestions_summary" />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:key="@string/pref_key_show_sponsored_suggestions"
            android:title="@string/preferences_show_sponsored_suggestions"
            android:summary="@string/preferences_show_sponsored_suggestions_summary" />
        <Preference
            app:iconSpaceReserved="false"
            android:key="@string/pref_key_learn_about_fx_suggest"
            android:title="@string/preference_search_learn_about_fx_suggest" />
    </PreferenceCategory> -->

    <PreferenceCategory
        android:title="@string/preferences_settings_address_bar"
        android:selectable="false"
@@ -92,11 +42,6 @@
            android:defaultValue="true"
            android:key="@string/pref_key_show_clipboard_suggestions"
            android:title="@string/preferences_show_clipboard_suggestions" />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:defaultValue="true"
            android:key="@string/pref_key_search_browsing_history"
            android:title='@string/preferences_search_browsing_history' />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:defaultValue="true"