Skip to content

Commit

Permalink
Ability to disable QR scan search in urlbar
Browse files Browse the repository at this point in the history
  • Loading branch information
akliuxingyuan committed May 1, 2024
1 parent 01ca30e commit f4eedc3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
private fun updateQrButton(searchFragmentState: SearchFragmentState) {
val searchEngine = searchFragmentState.searchEngineSource.searchEngine
when (
searchEngine?.isGeneral == true || searchEngine?.type == SearchEngine.Type.CUSTOM
requireContext().settings().shouldShowQRScanSearch &&
(searchEngine?.isGeneral == true || searchEngine?.type == SearchEngine.Type.CUSTOM)
) {
true -> {
if (qrButtonAction == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
isChecked = context.settings().shouldShowVoiceSearch
}

val showQRScanSearchPreference =
requirePreference<SwitchPreference>(R.string.pref_key_show_qr_scan_search).apply {
isChecked = context.settings().shouldShowQRScanSearch
}

val showSponsoredSuggestionsPreference =
requirePreference<SwitchPreference>(R.string.pref_key_show_sponsored_suggestions).apply {
isChecked = context.settings().showSponsoredSuggestions
Expand Down Expand Up @@ -138,6 +143,7 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
return true
}
}
showQRScanSearchPreference.onPreferenceChangeListener = SharedPreferenceUpdater()
autocompleteURLsPreference.onPreferenceChangeListener = SharedPreferenceUpdater()

searchSuggestionsPreference.setOnPreferenceClickListener {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,11 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = true,
)

var shouldShowQRScanSearch by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_qr_scan_search),
default = true,
)

/**
* Used in [SearchDialogFragment.kt], [SearchFragment.kt] (deprecated), and [PairFragment.kt]
* to see if we need to check for camera permissions before using the QR code scanner.
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,8 @@
<string name="confirm_addons_delete_cache_no">取消</string>
<string name="preferences_search_opened_tabs" >搜索已打开的标签页</string>
<string name="preferences_show_success_download_dialog">完成时的对话框</string>
<string name="preferences_show_qr_scan_search">显示二维码扫描搜索</string>

<!-- Content description for headings announced by accessibility service. The first parameter is the text of the heading. Talkback will announce the first parameter and then speak the word "Heading" indicating to the user that this text is a heading for a section. -->
<string name="a11y_heading">%s,标题</string>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,8 @@
<string name="confirm_addons_delete_cache_no">取消</string>
<string name="preferences_search_opened_tabs">搜尋已開啟的標籤頁</string>
<string name="preferences_show_success_download_dialog">完成時的對話方塊</string>
<string name="preferences_show_qr_scan_search">顯示 QR 掃描搜尋</string>

<!-- Content description for headings announced by accessibility service. The first parameter is the text of the heading. Talkback will announce the first parameter and then speak the word "Heading" indicating to the user that this text is a heading for a section. -->
<string name="a11y_heading">標題 %s</string>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@
<string name="pref_key_search_opened_tabs" translatable="false">pref_key_search_opened_tabs</string>
<!-- success download notification settings -->
<string name="pref_key_success_download_dialog" translatable="false">pref_key_success_download_dialog</string>
<string name="pref_key_show_qr_scan_search" translatable="false">pref_key_show_qr_scan_search</string>

<!--Shopping -->
<string name="pref_key_is_review_quality_check_enabled">pref_key_is_review_quality_check_enabled</string>
<string name="pref_key_is_review_quality_check_product_recommendations_enabled">pref_key_is_review_quality_check_product_recommendations_enabled</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,8 @@
<string name="confirm_addons_delete_cache_no">Cancel</string>
<string name="preferences_search_opened_tabs" >Search opened tabs</string>
<string name="preferences_show_success_download_dialog">Completion dialog box</string>
<string name="preferences_show_qr_scan_search">Show QR scan search</string>

<!-- Content description for headings announced by accessibility service. The first parameter is the text of the heading. Talkback will announce the first parameter and then speak the word "Heading" indicating to the user that this text is a heading for a section. -->
<string name="a11y_heading">%s, Heading</string>
<!-- Title for dialog displayed when trying to access links present in a text. -->
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/search_settings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
android:defaultValue="true"
android:key="@string/pref_key_show_voice_search"
android:title="@string/preferences_show_voice_search" />
<SwitchPreference
app:iconSpaceReserved="false"
android:defaultValue="true"
android:key="@string/pref_key_show_qr_scan_search"
android:title="@string/preferences_show_qr_scan_search" />
<SwitchPreference
app:iconSpaceReserved="false"
android:defaultValue="true"
Expand Down

0 comments on commit f4eedc3

Please sign in to comment.