For #26739 - Display MR onboarding dialog to existing users as soon as the app is opened

pull/543/head
Gabriel Luong 2 years ago committed by mergify[bot]
parent 3033b26f67
commit c43271fc0d

@ -82,7 +82,7 @@ object FeatureFlags {
/**
* Enables showing the homescreen onboarding card.
*/
const val showHomeOnboarding = false
val showHomeOnboarding = Config.channel.isNightlyOrDebug
/**
* Enables history improvement features.

@ -101,6 +101,7 @@ import org.mozilla.fenix.library.history.HistoryFragmentDirections
import org.mozilla.fenix.library.historymetadata.HistoryMetadataGroupFragmentDirections
import org.mozilla.fenix.library.recentlyclosed.RecentlyClosedFragmentDirections
import org.mozilla.fenix.onboarding.DefaultBrowserNotificationWorker
import org.mozilla.fenix.onboarding.FenixOnboarding
import org.mozilla.fenix.perf.MarkersActivityLifecycleCallbacks
import org.mozilla.fenix.perf.MarkersFragmentLifecycleCallbacks
import org.mozilla.fenix.perf.Performance
@ -171,6 +172,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
supportFragmentManager.findFragmentById(R.id.container) as NavHostFragment
}
private val onboarding by lazy { FenixOnboarding(applicationContext) }
private val externalSourceIntentProcessors by lazy {
listOf(
HomeDeepLinkIntentProcessor(this),
@ -252,6 +255,10 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
StartOnHome.enterHomeScreen.record(NoExtras())
}
if (settings().showHomeOnboardingDialog && onboarding.userHasBeenOnboarded()) {
navHost.navController.navigate(NavGraphDirections.actionGlobalHomeOnboardingDialog())
}
Performance.processIntentIfPerformanceTest(intent, this)
if (settings().isTelemetryEnabled) {

@ -389,7 +389,6 @@ class HomeFragment : Fragment() {
containerView = binding.sessionControlRecyclerView,
viewLifecycleOwner = viewLifecycleOwner,
interactor = sessionControlInteractor,
onboarding = onboarding,
)
updateSessionControlView()

@ -197,11 +197,6 @@ interface SessionControlController {
*/
fun handleCustomizeHomeTapped()
/**
* @see [OnboardingInteractor.showOnboardingDialog]
*/
fun handleShowOnboardingDialog()
/**
* @see [SessionControlInteractor.reportSessionMetrics]
*/
@ -506,13 +501,6 @@ class DefaultSessionControlController(
HomeScreen.customizeHomeClicked.record(NoExtras())
}
override fun handleShowOnboardingDialog() {
navController.nav(
R.id.homeFragment,
HomeFragmentDirections.actionGlobalHomeOnboardingDialog()
)
}
override fun handleReadPrivacyNoticeClicked() {
activity.openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getMozillaPageUrl(SupportUtils.MozillaPage.PRIVATE_NOTICE),

@ -162,12 +162,6 @@ interface OnboardingInteractor {
* Opens a custom tab to privacy notice url. Called when a user clicks on the "read our privacy notice" button.
*/
fun onReadPrivacyNoticeClicked()
/**
* Show the onboarding dialog to onboard users about recentTabs,recentBookmarks,
* historyMetadata and pocketArticles sections.
*/
fun showOnboardingDialog()
}
interface CustomizeHomeIteractor {
@ -328,10 +322,6 @@ class SessionControlInteractor(
controller.handleReadPrivacyNoticeClicked()
}
override fun showOnboardingDialog() {
controller.handleShowOnboardingDialog()
}
override fun onToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
controller.handleToggleCollectionExpanded(collection, expand)
}

@ -23,7 +23,6 @@ import org.mozilla.fenix.home.Mode
import org.mozilla.fenix.home.OnboardingState
import org.mozilla.fenix.home.recentbookmarks.RecentBookmark
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem
import org.mozilla.fenix.onboarding.FenixOnboarding
import org.mozilla.fenix.onboarding.JumpBackInCFRDialog
import org.mozilla.fenix.onboarding.SyncCFRPresenter
import org.mozilla.fenix.utils.Settings
@ -192,14 +191,11 @@ private fun collectionTabItems(collection: TabCollection) =
* @param viewLifecycleOwner [LifecycleOwner] for the view.
* @property interactor [SessionControlInteractor] which will have delegated to all user
* interactions.
* @property onboarding [FenixOnboarding] that is used to determine whether or not the user has
* been onboarded.
*/
class SessionControlView(
containerView: View,
viewLifecycleOwner: LifecycleOwner,
private val interactor: SessionControlInteractor,
private val onboarding: FenixOnboarding,
) {
val view: RecyclerView = containerView as RecyclerView
@ -242,10 +238,6 @@ class SessionControlView(
}
fun update(state: AppState, shouldReportMetrics: Boolean = false) {
if (view.context.settings().showHomeOnboardingDialog && onboarding.userHasBeenOnboarded()) {
interactor.showOnboardingDialog()
}
if (shouldReportMetrics) interactor.reportSessionMetrics(state)
sessionControlAdapter.submitList(state.toAdapterList(view.context.settings()))

@ -192,21 +192,6 @@ class DefaultSessionControlControllerTest {
}
}
@Test
@Ignore("Until the feature is enabled again")
fun handleShowOnboardingDialog() {
createController().handleShowOnboardingDialog()
verify {
navController.navigate(
match<NavDirections> {
it.actionId == R.id.action_global_home_onboarding_dialog
},
null
)
}
}
@Test
fun `handleCollectionOpenTabClicked onFailure`() {
val tab = mockk<ComponentTab> {

@ -197,12 +197,6 @@ class SessionControlInteractorTest {
verify { controller.handleCustomizeHomeTapped() }
}
@Test
fun `WHEN calling showOnboardingDialog THEN handleShowOnboardingDialog`() {
interactor.showOnboardingDialog()
verify { controller.handleShowOnboardingDialog() }
}
@Test
fun `WHEN Show All recently saved bookmarks button is clicked THEN the click is handled`() {
interactor.onShowAllBookmarksClicked()

@ -19,6 +19,7 @@ import kotlinx.coroutines.cancel
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.components.AppStore
@ -84,6 +85,7 @@ class WallpapersObserverTest {
}
@Test
@Ignore("Intermittent test: https://github.com/mozilla-mobile/fenix/issues/26760")
fun `WHEN the wallpaper is updated to a new one THEN show the wallpaper`() {
val appStore = AppStore()
val wallpapersUseCases: WallpapersUseCases = mockk {

@ -4,21 +4,16 @@
package org.mozilla.fenix.home.sessioncontrol
import androidx.recyclerview.widget.RecyclerView
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.top.sites.TopSite
import mozilla.components.service.pocket.PocketStory
import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.components.appstate.AppState
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.gleanplumb.Message
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.recentbookmarks.RecentBookmark
@ -28,27 +23,6 @@ import org.mozilla.fenix.utils.Settings
@RunWith(FenixRobolectricTestRunner::class)
class SessionControlViewTest {
@Test
fun `GIVENs updates WHEN sections recentTabs, recentBookmarks, historyMetadata or pocketArticles are NOT available THEN DO NOT show the dialog`() {
every { testContext.components.settings } returns mockk(relaxed = true)
val interactor = mockk<SessionControlInteractor>(relaxed = true)
val view = RecyclerView(testContext)
val controller = SessionControlView(
view,
mockk(relaxed = true),
interactor,
mockk(relaxed = true),
)
val state = AppState()
controller.update(state)
verify(exactly = 0) {
interactor.showOnboardingDialog()
}
}
@Test
fun `GIVEN recent Bookmarks WHEN normalModeAdapterItems is called THEN add a customize home button`() {
val settings: Settings = mockk()

Loading…
Cancel
Save