mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/16759: Prevent crash on showing info banner.
This commit is contained in:
parent
9b853166ac
commit
255e8aab73
@ -53,6 +53,7 @@ import org.mozilla.fenix.ext.settings
|
|||||||
import org.mozilla.fenix.ext.updateAccessibilityCollectionInfo
|
import org.mozilla.fenix.ext.updateAccessibilityCollectionInfo
|
||||||
import org.mozilla.fenix.tabtray.SaveToCollectionsButtonAdapter.MultiselectModeChange
|
import org.mozilla.fenix.tabtray.SaveToCollectionsButtonAdapter.MultiselectModeChange
|
||||||
import org.mozilla.fenix.tabtray.TabTrayDialogFragmentState.Mode
|
import org.mozilla.fenix.tabtray.TabTrayDialogFragmentState.Mode
|
||||||
|
import org.mozilla.fenix.utils.Settings
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@ -266,11 +267,15 @@ class TabTrayView(
|
|||||||
|
|
||||||
adjustNewTabButtonsForNormalMode()
|
adjustNewTabButtonsForNormalMode()
|
||||||
|
|
||||||
|
displayInfoBannerIfNeccessary(tabs, view.context.settings())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun displayInfoBannerIfNeccessary(tabs: List<TabSessionState>, settings: Settings) {
|
||||||
@Suppress("ComplexCondition")
|
@Suppress("ComplexCondition")
|
||||||
if (
|
val infoBanner = if (
|
||||||
view.context.settings().shouldShowGridViewBanner &&
|
settings.shouldShowGridViewBanner &&
|
||||||
view.context.settings().canShowCfr &&
|
settings.canShowCfr &&
|
||||||
view.context.settings().listTabView &&
|
settings.listTabView &&
|
||||||
tabs.size >= TAB_COUNT_SHOW_CFR
|
tabs.size >= TAB_COUNT_SHOW_CFR
|
||||||
) {
|
) {
|
||||||
InfoBanner(
|
InfoBanner(
|
||||||
@ -280,17 +285,14 @@ class TabTrayView(
|
|||||||
actionText = view.context.getString(R.string.tab_tray_grid_view_banner_positive_button_text),
|
actionText = view.context.getString(R.string.tab_tray_grid_view_banner_positive_button_text),
|
||||||
container = view.infoBanner,
|
container = view.infoBanner,
|
||||||
dismissByHiding = true,
|
dismissByHiding = true,
|
||||||
dismissAction = { view.context.settings().shouldShowGridViewBanner = false }
|
dismissAction = { settings.shouldShowGridViewBanner = false }
|
||||||
) {
|
) {
|
||||||
interactor.onGoToTabsSettings()
|
interactor.onGoToTabsSettings()
|
||||||
view.context.settings().shouldShowGridViewBanner = false
|
settings.shouldShowGridViewBanner = false
|
||||||
}.apply {
|
|
||||||
view.infoBanner.visibility = View.VISIBLE
|
|
||||||
showBanner()
|
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
view.context.settings().shouldShowAutoCloseTabsBanner &&
|
settings.shouldShowAutoCloseTabsBanner &&
|
||||||
view.context.settings().canShowCfr &&
|
settings.canShowCfr &&
|
||||||
tabs.size >= TAB_COUNT_SHOW_CFR
|
tabs.size >= TAB_COUNT_SHOW_CFR
|
||||||
) {
|
) {
|
||||||
InfoBanner(
|
InfoBanner(
|
||||||
@ -300,16 +302,20 @@ class TabTrayView(
|
|||||||
actionText = view.context.getString(R.string.tab_tray_close_tabs_banner_positive_button_text),
|
actionText = view.context.getString(R.string.tab_tray_close_tabs_banner_positive_button_text),
|
||||||
container = view.infoBanner,
|
container = view.infoBanner,
|
||||||
dismissByHiding = true,
|
dismissByHiding = true,
|
||||||
dismissAction = { view.context.settings().shouldShowAutoCloseTabsBanner = false }
|
dismissAction = { settings.shouldShowAutoCloseTabsBanner = false }
|
||||||
) {
|
) {
|
||||||
interactor.onGoToTabsSettings()
|
interactor.onGoToTabsSettings()
|
||||||
view.context.settings().shouldShowAutoCloseTabsBanner = false
|
settings.shouldShowAutoCloseTabsBanner = false
|
||||||
}.apply {
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
infoBanner?.apply {
|
||||||
view.infoBanner.visibility = View.VISIBLE
|
view.infoBanner.visibility = View.VISIBLE
|
||||||
showBanner()
|
showBanner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun getTabs(isPrivate: Boolean): List<TabSessionState> = if (isPrivate) {
|
private fun getTabs(isPrivate: Boolean): List<TabSessionState> = if (isPrivate) {
|
||||||
view.context.components.core.store.state.privateTabs
|
view.context.components.core.store.state.privateTabs
|
||||||
|
Loading…
Reference in New Issue
Block a user