2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

For #1216: Put voice search behind a nightly & debug flag

This commit is contained in:
Sawyer Blatz 2020-05-18 13:37:46 -07:00
parent d33edd8841
commit 535e020683
3 changed files with 10 additions and 2 deletions

View File

@ -48,4 +48,9 @@ object FeatureFlags {
* Enables new tab tray pref * Enables new tab tray pref
*/ */
val tabTray = Config.channel.isNightlyOrDebug val tabTray = Config.channel.isNightlyOrDebug
/**
* Enables new voice search feature
*/
val voiceSearch = Config.channel.isNightlyOrDebug
} }

View File

@ -43,6 +43,7 @@ import mozilla.components.ui.autocomplete.InlineAutocompleteEditText
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -138,7 +139,7 @@ class SearchFragment : Fragment(), UserInteractionHandler {
BrowserToolbar.Button( BrowserToolbar.Button(
ContextCompat.getDrawable(requireContext(), R.drawable.ic_microphone)!!, ContextCompat.getDrawable(requireContext(), R.drawable.ic_microphone)!!,
requireContext().getString(R.string.voice_search_content_description), requireContext().getString(R.string.voice_search_content_description),
visible = { requireContext().settings().shouldShowVoiceSearch }, visible = { requireContext().settings().shouldShowVoiceSearch && FeatureFlags.voiceSearch },
listener = ::launchVoiceSearch listener = ::launchVoiceSearch
) )
) )
@ -311,7 +312,7 @@ class SearchFragment : Fragment(), UserInteractionHandler {
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
if (requestCode == 0 && resultCode == RESULT_OK) { if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {
intent?.getStringArrayListExtra(EXTRA_RESULTS)?.first()?.also { intent?.getStringArrayListExtra(EXTRA_RESULTS)?.first()?.also {
toolbarView.view.edit.updateUrl(url = it, shouldHighlight = true) toolbarView.view.edit.updateUrl(url = it, shouldHighlight = true)
searchInteractor.onTextChanged(it) searchInteractor.onTextChanged(it)

View File

@ -10,6 +10,7 @@ import androidx.preference.CheckBoxPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
@ -62,6 +63,7 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
val showVoiceSearchPreference = val showVoiceSearchPreference =
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_voice_search))?.apply { findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_voice_search))?.apply {
isVisible = FeatureFlags.voiceSearch
isChecked = context.settings().shouldShowVoiceSearch isChecked = context.settings().shouldShowVoiceSearch
} }