[fenix] For https://github.com/mozilla-mobile/fenix/issues/26756 - Don't show Jump Back In CFR if the synced tab CFR is shown

pull/600/head
Gabriel Luong 2 years ago committed by mergify[bot]
parent a5e3c1ab73
commit 980594f218

@ -218,14 +218,13 @@ class SessionControlView(
super.onLayoutCompleted(state) super.onLayoutCompleted(state)
if (!context.settings().showHomeOnboardingDialog) { if (!context.settings().showHomeOnboardingDialog) {
JumpBackInCFRDialog(view).showIfNeeded() if (context.settings().shouldShowJumpBackInCFR) {
JumpBackInCFRDialog(view).showIfNeeded()
if (context.settings().showSyncCFR) { } else if (context.settings().showSyncCFR) {
SyncCFRPresenter( SyncCFRPresenter(
context = context, context = context,
recyclerView = view, recyclerView = view,
).showSyncCFR() ).showSyncCFR()
context.settings().showSyncCFR = false
} }
} }

@ -14,6 +14,7 @@ import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.mozilla.fenix.databinding.OnboardingJumpBackInCfrBinding import org.mozilla.fenix.databinding.OnboardingJumpBackInCfrBinding
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.home.recentsyncedtabs.view.RecentSyncedTabViewHolder
import org.mozilla.fenix.home.recenttabs.view.RecentTabsHeaderViewHolder import org.mozilla.fenix.home.recenttabs.view.RecentTabsHeaderViewHolder
/** /**
@ -48,14 +49,30 @@ class JumpBackInCFRDialog(val recyclerView: RecyclerView) {
return null return null
} }
private fun hasSyncTabsView(): Boolean {
val count = recyclerView.adapter?.itemCount ?: return false
for (index in count downTo 0) {
val viewHolder = recyclerView.findViewHolderForAdapterPosition(index)
if (viewHolder is RecentSyncedTabViewHolder) {
return true
}
}
return false
}
private fun createJumpCRF(anchor: View): Dialog? { private fun createJumpCRF(anchor: View): Dialog? {
val context: Context = recyclerView.context val context: Context = recyclerView.context
if (!context.settings().showSyncCFR) {
if (context.settings().showSyncCFR && hasSyncTabsView()) {
context.settings().shouldShowJumpBackInCFR = false context.settings().shouldShowJumpBackInCFR = false
} }
if (!context.settings().shouldShowJumpBackInCFR) { if (!context.settings().shouldShowJumpBackInCFR) {
return null return null
} }
val anchorPosition = IntArray(2) val anchorPosition = IntArray(2)
val popupBinding = OnboardingJumpBackInCfrBinding.inflate(LayoutInflater.from(context)) val popupBinding = OnboardingJumpBackInCfrBinding.inflate(LayoutInflater.from(context))
val popup = Dialog(context) val popup = Dialog(context)

@ -13,6 +13,7 @@ import org.mozilla.fenix.GleanMetrics.Onboarding
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.compose.cfr.CFRPopup import org.mozilla.fenix.compose.cfr.CFRPopup
import org.mozilla.fenix.compose.cfr.CFRPopupProperties import org.mozilla.fenix.compose.cfr.CFRPopupProperties
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.home.recentsyncedtabs.view.RecentSyncedTabViewHolder import org.mozilla.fenix.home.recentsyncedtabs.view.RecentSyncedTabViewHolder
/** /**
@ -21,10 +22,10 @@ import org.mozilla.fenix.home.recentsyncedtabs.view.RecentSyncedTabViewHolder
private const val CFR_TO_ANCHOR_VERTICAL_PADDING = -16 private const val CFR_TO_ANCHOR_VERTICAL_PADDING = -16
/** /**
* Delegate for handling sync onboarding CFR. * Delegate for handling synced tab onboarding CFR.
* *
* @param [Context] used for various Android interactions. * @param context [Context] used for various Android interactions.
* @param [RecyclerView] will serve as anchor for the sync CFR. * @param recyclerView [RecyclerView] will serve as anchor for the sync CFR.
*/ */
class SyncCFRPresenter( class SyncCFRPresenter(
private val context: Context, private val context: Context,
@ -34,7 +35,7 @@ class SyncCFRPresenter(
private var syncCFR: CFRPopup? = null private var syncCFR: CFRPopup? = null
/** /**
* Check if [view] is available to show sync CFR. * Find the synced view and if it is available, then show the synced tab CFR.
*/ */
fun showSyncCFR() { fun showSyncCFR() {
findSyncTabsView()?.let { findSyncTabsView()?.let {
@ -51,12 +52,15 @@ class SyncCFRPresenter(
false -> Onboarding.syncCfrImplicitDismissal.record(NoExtras()) false -> Onboarding.syncCfrImplicitDismissal.record(NoExtras())
} }
} }
) { ).apply {
}.apply {
syncCFR = this syncCFR = this
show() show()
Onboarding.synCfrShown.record(NoExtras())
} }
context.settings().showSyncCFR = false
context.settings().shouldShowJumpBackInCFR = false
Onboarding.synCfrShown.record(NoExtras())
} }
} }

Loading…
Cancel
Save