For #24967 - Enable address autofill for Nightly and Debug

This commit is contained in:
Gabriel Luong 2022-06-28 12:13:20 -04:00 committed by mergify[bot]
parent a4681de2ec
commit 83e19be385
10 changed files with 26 additions and 25 deletions

View File

@ -71,7 +71,7 @@ class SettingsBasicsTest {
verifyHomepageButton()
verifyCustomizeButton()
verifyLoginsAndPasswordsButton()
verifyCreditCardsButton()
verifyAutofillButton()
verifyAccessibilityButton()
verifyLanguageButton()
verifySetAsDefaultBrowserButton()

View File

@ -67,7 +67,7 @@ class SettingsRobot {
fun verifySetAsDefaultBrowserButton() = assertSetAsDefaultBrowserButton()
fun verifyTabsButton() = assertTabsButton()
fun verifyHomepageButton() = assertHomepageButton()
fun verifyCreditCardsButton() = assertCreditCardsButton()
fun verifyAutofillButton() = assertAutofillButton()
fun verifyLanguageButton() = assertLanguageButton()
fun verifyDefaultBrowserIsDisabled() = assertDefaultBrowserIsDisabled()
fun clickDefaultBrowserSwitch() = toggleDefaultBrowserSwitch()
@ -344,8 +344,8 @@ private fun assertSearchButton() {
private fun assertHomepageButton() =
onView(withText(R.string.preferences_home_2)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertCreditCardsButton() =
onView(withText(R.string.preferences_credit_cards)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertAutofillButton() =
onView(withText(R.string.preferences_autofill)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertLanguageButton() =
onView(withText(R.string.preferences_language)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))

View File

@ -19,9 +19,9 @@ object FeatureFlags {
val pullToRefreshEnabled = Config.channel.isNightlyOrDebug
/**
* Enables the Addresses autofill feature.
* Enables the Sync Addresses feature.
*/
val addressesFeature = Config.channel.isNightlyOrDebug
const val syncAddressesFeature = false
/**
* Enables the "recent" tabs feature in the home screen.

View File

@ -602,7 +602,7 @@ abstract class BaseBrowserFragment :
context.settings().shouldAutofillCreditCardDetails
},
isAddressAutofillEnabled = {
context.settings().shouldAutofillAddressDetails && FeatureFlags.addressesFeature
context.settings().addressFeature && context.settings().shouldAutofillAddressDetails
},
loginExceptionStorage = context.components.core.loginExceptionStorage,
shareDelegate = object : ShareDelegate {

View File

@ -97,7 +97,7 @@ class BackgroundServices(
SyncEngine.Passwords,
SyncEngine.Tabs,
SyncEngine.CreditCards,
if (FeatureFlags.addressesFeature) SyncEngine.Addresses else null
if (FeatureFlags.syncAddressesFeature) SyncEngine.Addresses else null
)
private val syncConfig =
SyncConfig(supportedEngines, PeriodicSyncConfig(periodMinutes = 240)) // four hours
@ -119,7 +119,7 @@ class BackgroundServices(
storePair = SyncEngine.CreditCards to creditCardsStorage,
keyProvider = lazy { creditCardKeyProvider }
)
if (FeatureFlags.addressesFeature) {
if (FeatureFlags.syncAddressesFeature) {
GlobalSyncableStoreProvider.configureStore(SyncEngine.Addresses to creditCardsStorage)
}
}

View File

@ -24,12 +24,6 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.secret_settings_preferences, rootKey)
requirePreference<SwitchPreference>(R.string.pref_key_show_address_feature).apply {
isVisible = FeatureFlags.addressesFeature
isChecked = context.settings().addressFeature
onPreferenceChangeListener = SharedPreferenceUpdater()
}
requirePreference<SwitchPreference>(R.string.pref_key_allow_third_party_root_certs).apply {
isVisible = true
isChecked = context.settings().allowThirdPartyRootCerts

View File

@ -315,7 +315,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Tabs) { true }
}
requirePreference<CheckBoxPreference>(R.string.pref_key_sync_address).apply {
isVisible = FeatureFlags.addressesFeature
isVisible = FeatureFlags.syncAddressesFeature
isEnabled = syncEnginesStatus.containsKey(SyncEngine.Addresses)
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Addresses) { true }
}

View File

@ -27,6 +27,7 @@ import mozilla.components.support.ktx.android.content.intPreference
import mozilla.components.support.ktx.android.content.longPreference
import mozilla.components.support.ktx.android.content.stringPreference
import mozilla.components.support.ktx.android.content.stringSetPreference
import mozilla.components.support.locale.LocaleManager
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.FeatureFlags
@ -1194,10 +1195,23 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var addressFeature by featureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_show_address_feature),
default = false,
featureFlag = FeatureFlags.addressesFeature
default = true,
featureFlag = isAddressFeatureEnabled(appContext)
)
/**
* Show the Addresses autofill feature.
*/
private fun isAddressFeatureEnabled(context: Context): Boolean {
val langTag = LocaleManager.getCurrentLocale(context)
?.toLanguageTag() ?: LocaleManager.getSystemDefault().toLanguageTag()
return listOf(
"en-US",
"en-CA",
"fr-CA"
).contains(langTag) && Config.channel.isNightlyOrDebug
}
private var isHistoryMetadataEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_history_metadata_feature),
default = false

View File

@ -31,8 +31,6 @@
<string name="preferences_debug_settings">Secret Settings</string>
<!-- Label for the secret settings preference -->
<string name="preferences_debug_info" translatable="false">Secret Debug Info</string>
<!-- Label for enabling Address Autofill -->
<string name="preferences_debug_settings_enable_address_feature" translatable="false">Enable Address Autofill</string>
<!-- Label for allowing third party root certificates from the Android OS CA store preference -->
<string name="preferences_debug_settings_allow_third_party_root_certs">Use third party CA certificates</string>
<!-- Label for a longer description of allowing third party root certificates from the Android OS CA store preference -->

View File

@ -4,11 +4,6 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_show_address_feature"
android:title="@string/preferences_debug_settings_enable_address_feature"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_allow_third_party_root_certs"