mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/1019 Add option to enable search suggestions in private mode
This commit is contained in:
parent
b8537c205e
commit
f9a51fa99f
@ -81,13 +81,20 @@ class SearchFragment : Fragment(), BackHandler {
|
||||
requireComponents.search.provider.getDefaultEngine(requireContext())
|
||||
)
|
||||
|
||||
val showSearchSuggestions = if ((activity as HomeActivity).browsingModeManager.mode.isPrivate) {
|
||||
requireContext().settings().shouldShowSearchSuggestions &&
|
||||
requireContext().settings().shouldShowSearchSuggestionsInPrivate
|
||||
} else {
|
||||
requireContext().settings().shouldShowSearchSuggestions
|
||||
}
|
||||
|
||||
searchStore = StoreProvider.get(this) {
|
||||
SearchFragmentStore(
|
||||
SearchFragmentState(
|
||||
query = url,
|
||||
searchEngineSource = currentSearchEngine,
|
||||
defaultEngineSource = currentSearchEngine,
|
||||
showSearchSuggestions = requireContext().settings().shouldShowSearchSuggestions,
|
||||
showSearchSuggestions = showSearchSuggestions,
|
||||
showSearchShortcuts = requireContext().settings().shouldShowSearchShortcuts && url.isEmpty(),
|
||||
showClipboardSuggestions = requireContext().settings().shouldShowClipboardSuggestions,
|
||||
showHistorySuggestions = requireContext().settings().shouldShowHistorySuggestions,
|
||||
|
@ -8,6 +8,7 @@ import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.SwitchPreference
|
||||
import org.mozilla.fenix.R
|
||||
@ -31,6 +32,12 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||
isChecked = context.settings().shouldShowSearchSuggestions
|
||||
}
|
||||
|
||||
val searchSuggestionsInPrivatePreference =
|
||||
findPreference<CheckBoxPreference>(getPreferenceKey(R.string.pref_key_show_search_suggestions_in_private))
|
||||
?.apply {
|
||||
isChecked = context.settings().shouldShowSearchSuggestionsInPrivate
|
||||
}
|
||||
|
||||
val showSearchShortcuts =
|
||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_search_shortcuts))?.apply {
|
||||
isChecked = context.settings().shouldShowSearchShortcuts
|
||||
@ -60,6 +67,15 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
showBookmarkSuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
showClipboardSuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
searchSuggestionsInPrivatePreference?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
|
||||
searchSuggestionsPreference?.setOnPreferenceClickListener {
|
||||
if (!searchSuggestionsPreference.isChecked) {
|
||||
searchSuggestionsInPrivatePreference?.isChecked = false
|
||||
searchSuggestionsInPrivatePreference?.callChangeListener(false)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
|
@ -263,6 +263,11 @@ class Settings private constructor(
|
||||
default = true
|
||||
)
|
||||
|
||||
val shouldShowSearchSuggestionsInPrivate by booleanPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions_in_private),
|
||||
default = false
|
||||
)
|
||||
|
||||
@VisibleForTesting(otherwise = PRIVATE)
|
||||
internal val trackingProtectionOnboardingCount by intPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_onboarding),
|
||||
|
@ -11,7 +11,6 @@
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="?android:attr/scrollbarSize">
|
||||
|
||||
|
@ -74,6 +74,8 @@
|
||||
<string name="pref_key_show_clipboard_suggestions" translatable="false">pref_key_show_clipboard_suggestions</string>
|
||||
<string name="pref_key_search_browsing_history" translatable="false">pref_key_search_browsing_history</string>
|
||||
<string name="pref_key_search_bookmarks" translatable="false">pref_key_search_bookmarks</string>
|
||||
<string name="pref_key_show_search_suggestions_in_private" translatable="false">pref_key_show_search_suggestions_in_private</string>
|
||||
|
||||
|
||||
<!-- Site Permissions Settings -->
|
||||
<string name="pref_key_optimize" translatable="false">pref_key_optimize</string>
|
||||
|
@ -134,6 +134,8 @@
|
||||
<string name="preferences_default_search_engine">Default search engine</string>
|
||||
<!-- Preference for settings related to Search -->
|
||||
<string name="preferences_search">Search</string>
|
||||
<!-- Preference for settings related to Search address bar -->
|
||||
<string name="preferences_search_address_bar">Address bar</string>
|
||||
<!-- Preference linking to help about Fenix -->
|
||||
<string name="preferences_help">Help</string>
|
||||
<!-- Preference link to rating Fenix on the Play Store -->
|
||||
@ -191,6 +193,8 @@
|
||||
<string name="preferences_show_search_shortcuts">Show search shortcuts</string>
|
||||
<!-- Preference title for switch preference to show search suggestions -->
|
||||
<string name="preferences_show_search_suggestions">Show search suggestions</string>
|
||||
<!-- Preference title for switch preference to show search suggestions also in private mode -->
|
||||
<string name="preferences_show_search_suggestions_in_private">Show in private sessions</string>
|
||||
<!-- Preference title for switch preference to show a clipboard suggestion when searching -->
|
||||
<string name="preferences_show_clipboard_suggestions">Show clipboard suggestions</string>
|
||||
<!-- Preference title for switch preference to suggest browsing history when searching -->
|
||||
|
@ -12,16 +12,17 @@
|
||||
<org.mozilla.fenix.settings.search.RadioSearchEngineListPreference
|
||||
android:key="@string/pref_key_search_engine_list"
|
||||
android:selectable="false"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/preferences_search_address_bar"
|
||||
android:selectable="false"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<Preference
|
||||
android:key="@string/pref_key_add_search_engine"
|
||||
android:title="@string/search_engine_add_custom_search_engine_title"
|
||||
android:layout="@layout/preference_search_add_engine"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/pref_key_show_search_suggestions"
|
||||
android:title="@string/preferences_show_search_suggestions"
|
||||
app:iconSpaceReserved="false"
|
||||
app:allowDividerAbove="false"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/pref_key_show_search_shortcuts"
|
||||
@ -42,5 +43,19 @@
|
||||
android:key="@string/pref_key_search_bookmarks"
|
||||
android:title='@string/preferences_search_bookmarks'
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/pref_key_show_search_suggestions"
|
||||
android:title="@string/preferences_show_search_suggestions"
|
||||
app:iconSpaceReserved="false"
|
||||
app:allowDividerAbove="false"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/pref_key_show_search_suggestions"
|
||||
android:key="@string/pref_key_show_search_suggestions_in_private"
|
||||
android:title="@string/preferences_show_search_suggestions_in_private"
|
||||
android:layout="@layout/checkbox_left_preference"
|
||||
app:allowDividerAbove="false"
|
||||
app:iconSpaceReserved="true" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user