mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
For #26756 - Don't show Jump Back In CFR if the synced tab CFR is shown
This commit is contained in:
parent
df2780cd01
commit
ca0cfd79e8
@ -218,14 +218,13 @@ class SessionControlView(
|
||||
super.onLayoutCompleted(state)
|
||||
|
||||
if (!context.settings().showHomeOnboardingDialog) {
|
||||
JumpBackInCFRDialog(view).showIfNeeded()
|
||||
|
||||
if (context.settings().showSyncCFR) {
|
||||
if (context.settings().shouldShowJumpBackInCFR) {
|
||||
JumpBackInCFRDialog(view).showIfNeeded()
|
||||
} else if (context.settings().showSyncCFR) {
|
||||
SyncCFRPresenter(
|
||||
context = context,
|
||||
recyclerView = view,
|
||||
).showSyncCFR()
|
||||
context.settings().showSyncCFR = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.mozilla.fenix.databinding.OnboardingJumpBackInCfrBinding
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.home.recentsyncedtabs.view.RecentSyncedTabViewHolder
|
||||
import org.mozilla.fenix.home.recenttabs.view.RecentTabsHeaderViewHolder
|
||||
|
||||
/**
|
||||
@ -48,14 +49,30 @@ class JumpBackInCFRDialog(val recyclerView: RecyclerView) {
|
||||
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? {
|
||||
val context: Context = recyclerView.context
|
||||
if (!context.settings().showSyncCFR) {
|
||||
|
||||
if (context.settings().showSyncCFR && hasSyncTabsView()) {
|
||||
context.settings().shouldShowJumpBackInCFR = false
|
||||
}
|
||||
|
||||
if (!context.settings().shouldShowJumpBackInCFR) {
|
||||
return null
|
||||
}
|
||||
|
||||
val anchorPosition = IntArray(2)
|
||||
val popupBinding = OnboardingJumpBackInCfrBinding.inflate(LayoutInflater.from(context))
|
||||
val popup = Dialog(context)
|
||||
|
@ -13,6 +13,7 @@ import org.mozilla.fenix.GleanMetrics.Onboarding
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.compose.cfr.CFRPopup
|
||||
import org.mozilla.fenix.compose.cfr.CFRPopupProperties
|
||||
import org.mozilla.fenix.ext.settings
|
||||
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
|
||||
|
||||
/**
|
||||
* Delegate for handling sync onboarding CFR.
|
||||
* Delegate for handling synced tab onboarding CFR.
|
||||
*
|
||||
* @param [Context] used for various Android interactions.
|
||||
* @param [RecyclerView] will serve as anchor for the sync CFR.
|
||||
* @param context [Context] used for various Android interactions.
|
||||
* @param recyclerView [RecyclerView] will serve as anchor for the sync CFR.
|
||||
*/
|
||||
class SyncCFRPresenter(
|
||||
private val context: Context,
|
||||
@ -34,7 +35,7 @@ class SyncCFRPresenter(
|
||||
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() {
|
||||
findSyncTabsView()?.let {
|
||||
@ -51,12 +52,15 @@ class SyncCFRPresenter(
|
||||
false -> Onboarding.syncCfrImplicitDismissal.record(NoExtras())
|
||||
}
|
||||
}
|
||||
) {
|
||||
}.apply {
|
||||
).apply {
|
||||
syncCFR = this
|
||||
show()
|
||||
Onboarding.synCfrShown.record(NoExtras())
|
||||
}
|
||||
|
||||
context.settings().showSyncCFR = false
|
||||
context.settings().shouldShowJumpBackInCFR = false
|
||||
|
||||
Onboarding.synCfrShown.record(NoExtras())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user