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

This commit is contained in:
Gabriel Luong 2022-08-31 18:17:16 -04:00 committed by mergify[bot]
parent 3033b26f67
commit c43271fc0d
10 changed files with 10 additions and 79 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 @Test
fun `handleCollectionOpenTabClicked onFailure`() { fun `handleCollectionOpenTabClicked onFailure`() {
val tab = mockk<ComponentTab> { val tab = mockk<ComponentTab> {

View File

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

View File

@ -19,6 +19,7 @@ import kotlinx.coroutines.cancel
import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.libstate.ext.waitUntilIdle
import org.junit.Assert.assertNotNull import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.components.AppStore import org.mozilla.fenix.components.AppStore
@ -84,6 +85,7 @@ class WallpapersObserverTest {
} }
@Test @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`() { fun `WHEN the wallpaper is updated to a new one THEN show the wallpaper`() {
val appStore = AppStore() val appStore = AppStore()
val wallpapersUseCases: WallpapersUseCases = mockk { val wallpapersUseCases: WallpapersUseCases = mockk {

View File

@ -4,21 +4,16 @@
package org.mozilla.fenix.home.sessioncontrol package org.mozilla.fenix.home.sessioncontrol
import androidx.recyclerview.widget.RecyclerView
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.verify
import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.top.sites.TopSite import mozilla.components.feature.top.sites.TopSite
import mozilla.components.service.pocket.PocketStory import mozilla.components.service.pocket.PocketStory
import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith 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.gleanplumb.Message
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.recentbookmarks.RecentBookmark import org.mozilla.fenix.home.recentbookmarks.RecentBookmark
@ -28,27 +23,6 @@ import org.mozilla.fenix.utils.Settings
@RunWith(FenixRobolectricTestRunner::class) @RunWith(FenixRobolectricTestRunner::class)
class SessionControlViewTest { 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 @Test
fun `GIVEN recent Bookmarks WHEN normalModeAdapterItems is called THEN add a customize home button`() { fun `GIVEN recent Bookmarks WHEN normalModeAdapterItems is called THEN add a customize home button`() {
val settings: Settings = mockk() val settings: Settings = mockk()