For #20586 - Put everything behing a secret setting

Not ready for prime-time. Lot of work still to be done.
upstream-sync
Mugurell 3 years ago committed by mergify[bot]
parent 6ae8c90f41
commit 05f74eb620

@ -4,6 +4,7 @@
package org.mozilla.fenix.home.sessioncontrol
import android.content.Context
import android.view.View
import androidx.annotation.VisibleForTesting
import androidx.lifecycle.LifecycleOwner
@ -17,6 +18,7 @@ import mozilla.components.feature.top.sites.TopSite
import mozilla.components.service.pocket.PocketRecommendedStory
import org.mozilla.fenix.components.tips.Tip
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
import org.mozilla.fenix.home.HomeFragmentState
import org.mozilla.fenix.home.HomeFragmentStore
@ -29,6 +31,7 @@ import org.mozilla.fenix.home.recenttabs.view.RecentTabsItemPosition
// When we remove the tabs from the home screen this will get much simpler again.
@Suppress("ComplexMethod", "LongParameterList")
private fun normalModeAdapterItems(
context: Context,
topSites: List<TopSite>,
collections: List<TabCollection>,
expandedCollections: Set<Long>,
@ -72,7 +75,7 @@ private fun normalModeAdapterItems(
showCollections(collections, expandedCollections, items)
}
if (pocketArticles.isNotEmpty()) {
if (context.settings().pocketRecommendations && pocketArticles.isNotEmpty()) {
items.add(AdapterItem.PocketStoriesItem)
}
@ -191,8 +194,9 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List<Adapt
return items
}
private fun HomeFragmentState.toAdapterList(): List<AdapterItem> = when (mode) {
private fun HomeFragmentState.toAdapterList(context: Context): List<AdapterItem> = when (mode) {
is Mode.Normal -> normalModeAdapterItems(
context,
topSites,
collections,
expandedCollections,
@ -245,7 +249,7 @@ class SessionControlView(
}
fun update(state: HomeFragmentState) {
val stateAdapterList = state.toAdapterList()
val stateAdapterList = state.toAdapterList(view.context)
if (homeScreenViewModel.shouldScrollToTopSites) {
sessionControlAdapter.submitList(stateAdapterList) {

@ -1131,4 +1131,9 @@ class Settings(private val appContext: Context) : PreferencesHolder {
appContext.getPreferenceKey(R.string.pref_key_credit_cards_save_and_autofill_cards),
default = true
)
var pocketRecommendations by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_pocket_homescreen_recommendations),
default = false
)
}

@ -280,4 +280,5 @@
<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>
<string name="pref_key_history_metadata_feature" translatable="false">pref_key_history_metadata_feature</string>
<string name="pref_key_pocket_homescreen_recommendations" translatable="false">pref_key_pocket_homescreen_recommendations</string>
</resources>

@ -49,6 +49,8 @@
<string name="preferences_nimbus_experiments">Nimbus Experiments</string>
<!-- Label for using the nimbus collections preview -->
<string name="preferences_nimbus_use_preview_collection">Use Nimbus Preview Collection (requires restart)</string>
<!-- Label for the Pocket articles recommendations on homescreen -->
<string name="preferences_pocket_homescreen_recommendations">Debug only. Enable Pocket recommended articles on homescreen.</string>
<!-- A secret menu option in the tabs tray for making a tab inactive for testing. -->
<string name="inactive_tabs_menu_item">Make inactive</string>

@ -25,4 +25,9 @@
android:key="@string/pref_key_nimbus_use_preview"
android:title="@string/preferences_nimbus_use_preview_collection"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_pocket_homescreen_recommendations"
android:title="@string/preferences_pocket_homescreen_recommendations"
app:iconSpaceReserved="false" />
</PreferenceScreen>

Loading…
Cancel
Save