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

[SDK-279] Adds a way to switch to the "preview" collection in Nimbus

This adds a toggle/switch to the debug settings menu that causes Nimbus to use the "preview" collection rather than the "main" collection when it initializes.  Since it is only applied during init, it does require a restart in order to take effect.
This commit is contained in:
Travis Long 2021-06-23 11:56:51 -05:00 committed by mergify[bot]
parent 9d9761e267
commit a2984e6863
6 changed files with 23 additions and 1 deletions

View File

@ -31,7 +31,11 @@ fun createNimbus(context: Context, url: String?): NimbusApi {
// Eventually we'll want to use `NimbusDisabled` when we have no NIMBUS_ENDPOINT. // Eventually we'll want to use `NimbusDisabled` when we have no NIMBUS_ENDPOINT.
// but we keep this here to not mix feature flags and how we configure Nimbus. // but we keep this here to not mix feature flags and how we configure Nimbus.
val serverSettings = if (!url.isNullOrBlank()) { val serverSettings = if (!url.isNullOrBlank()) {
if (context.settings().nimbusUsePreview) {
NimbusServerSettings(url = Uri.parse(url), collection = "nimbus-preview")
} else {
NimbusServerSettings(url = Uri.parse(url)) NimbusServerSettings(url = Uri.parse(url))
}
} else { } else {
null null
} }

View File

@ -41,5 +41,11 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
} }
} }
} }
requirePreference<SwitchPreference>(R.string.pref_key_nimbus_use_preview).apply {
isVisible = true
isChecked = context.settings().nimbusUsePreview
onPreferenceChangeListener = SharedPreferenceUpdater()
}
} }
} }

View File

@ -353,6 +353,11 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = false default = false
) )
var nimbusUsePreview by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_nimbus_use_preview),
default = false
)
/** /**
* Indicates the last time when the user was interacting with the [BrowserFragment], * Indicates the last time when the user was interacting with the [BrowserFragment],
* This is useful to determine if the user has to start on the [HomeFragment] * This is useful to determine if the user has to start on the [HomeFragment]

View File

@ -284,4 +284,5 @@
<!-- Secret Settings --> <!-- Secret Settings -->
<string name="pref_key_show_address_feature" translatable="false">pref_key_show_address_feature</string> <string name="pref_key_show_address_feature" translatable="false">pref_key_show_address_feature</string>
<string name="pref_key_nimbus_experiments" translatable="false">pref_key_nimbus_experiments</string> <string name="pref_key_nimbus_experiments" translatable="false">pref_key_nimbus_experiments</string>
<string name="pref_key_nimbus_use_preview" translatable="false">pref_key_nimbus_use_preview</string>
</resources> </resources>

View File

@ -1764,5 +1764,6 @@
<!-- Content description for privacy content close button --> <!-- Content description for privacy content close button -->
<string name="privacy_content_close_button_content_description">Close</string> <string name="privacy_content_close_button_content_description">Close</string>
<string name="mozac_service_nimbus_use_preview_collection">Use Nimbus Preview Collection (requires restart)</string>
</resources> </resources>

View File

@ -15,4 +15,9 @@
android:title="@string/preferences_debug_settings_allow_third_party_root_certs" android:title="@string/preferences_debug_settings_allow_third_party_root_certs"
android:summary="@string/preferences_debug_settings_allow_third_party_root_certs_summary" android:summary="@string/preferences_debug_settings_allow_third_party_root_certs_summary"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_nimbus_use_preview"
android:title="@string/mozac_service_nimbus_use_preview_collection"
app:iconSpaceReserved="false" />
</PreferenceScreen> </PreferenceScreen>