Unverified Commit ebadbdb3 authored by Gabriel Luong's avatar Gabriel Luong Committed by GitHub
Browse files

For #14920 - Show a Tabs Tray CFR Banner for grid view tip (#16466)

parent 5530e102
......@@ -52,7 +52,7 @@ interface TabTrayController {
fun handleOpenTab(tab: Tab)
fun handleEnterMultiselect()
fun handleRecentlyClosedClicked()
fun handleSetUpAutoCloseTabsClicked()
fun handleGoToTabsSettingClicked()
}
/**
......@@ -239,7 +239,7 @@ class DefaultTabTrayController(
navController.navigate(directions)
}
override fun handleSetUpAutoCloseTabsClicked() {
override fun handleGoToTabsSettingClicked() {
val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
navController.navigate(directions)
}
......
......@@ -70,9 +70,10 @@ interface TabTrayInteractor {
fun onModeRequested(): TabTrayDialogFragmentState.Mode
/**
* Called when user clicks on the "set it up" prompt for automatically closing tabs
* Called when user clicks on the action button prompt in the info banner CFR for
* automatically closing tabs or changing the layout of open tabs.
*/
fun onSetUpAutoCloseTabsClicked()
fun onGoToTabsSettings()
/**
* Called when a tab should be opened in the browser.
......@@ -173,7 +174,7 @@ class TabTrayFragmentInteractor(private val controller: TabTrayController) : Tab
controller.handleEnterMultiselect()
}
override fun onSetUpAutoCloseTabsClicked() {
controller.handleSetUpAutoCloseTabsClicked()
override fun onGoToTabsSettings() {
controller.handleGoToTabsSettingClicked()
}
}
......@@ -270,7 +270,29 @@ class TabTrayView(
adjustNewTabButtonsForNormalMode()
@Suppress("ComplexCondition")
if (
view.context.settings().showGridViewInTabsSettings &&
view.context.settings().shouldShowGridViewBanner &&
view.context.settings().canShowCfr &&
tabs.size >= TAB_COUNT_SHOW_CFR
) {
InfoBanner(
context = view.context,
message = view.context.getString(R.string.tab_tray_grid_view_banner_message),
dismissText = view.context.getString(R.string.tab_tray_grid_view_banner_negative_button_text),
actionText = view.context.getString(R.string.tab_tray_grid_view_banner_positive_button_text),
container = view.infoBanner,
dismissByHiding = true,
dismissAction = { view.context.settings().shouldShowGridViewBanner = false }
) {
interactor.onGoToTabsSettings()
view.context.settings().shouldShowGridViewBanner = false
}.apply {
view.infoBanner.visibility = View.VISIBLE
showBanner()
}
} else if (
view.context.settings().shouldShowAutoCloseTabsBanner &&
view.context.settings().canShowCfr &&
tabs.size >= TAB_COUNT_SHOW_CFR
......@@ -284,7 +306,7 @@ class TabTrayView(
dismissByHiding = true,
dismissAction = { view.context.settings().shouldShowAutoCloseTabsBanner = false }
) {
interactor.onSetUpAutoCloseTabsClicked()
interactor.onGoToTabsSettings()
view.context.settings().shouldShowAutoCloseTabsBanner = false
}.apply {
view.infoBanner.visibility = View.VISIBLE
......@@ -713,7 +735,7 @@ class TabTrayView(
layoutManager?.scrollToPosition(recyclerViewIndex)
smoothScrollBy(
0,
- resources.getDimensionPixelSize(R.dimen.tab_tray_tab_item_height) / 2
-resources.getDimensionPixelSize(R.dimen.tab_tray_tab_item_height) / 2
)
}
}
......
......@@ -682,6 +682,11 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = true
)
var shouldShowGridViewBanner by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_should_show_grid_view_banner),
default = true
)
@VisibleForTesting(otherwise = PRIVATE)
internal val trackingProtectionOnboardingCount = counterPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_onboarding),
......
......@@ -197,6 +197,9 @@
<!-- A value of `true` means the Auto Close Tabs Banner has not been shown yet -->
<string name="pref_key_should_show_auto_close_tabs_banner" translatable="false">pref_key_should_show_auto_close_tabs_banner</string>
<!-- A value of `true` means the Grid View Banner has not been shown yet -->
<string name="pref_key_should_show_grid_view_banner" translatable="false">pref_key_should_show_grid_view_banner</string>
<string name="pref_key_migrating_from_fenix_nightly_tip" translatable="false">pref_key_migrating_from_fenix_nightly_tip</string>
<string name="pref_key_migrating_from_firefox_nightly_tip" translatable="false">pref_key_migrating_from_firefox_nightly_tip</string>
<string name="pref_key_migrating_from_fenix_tip" translatable="false">pref_key_migrating_from_fenix_tip</string>
......
......@@ -92,6 +92,13 @@
<!-- Text for the negative action button to dismiss the Close Tabs Banner. -->
<string name="tab_tray_close_tabs_banner_negative_button_text">Dismiss</string>
<!-- Text for the banner message to tell users about our grid view feature. -->
<string name="tab_tray_grid_view_banner_message">Change the layout of open tabs. Go to settings and select grid under tab view.</string>
<!-- Text for the positive action button to go to Settings for auto close tabs. -->
<string name="tab_tray_grid_view_banner_positive_button_text">Go to settings</string>
<!-- Text for the negative action button to dismiss the Close Tabs Banner. -->
<string name="tab_tray_grid_view_banner_negative_button_text">Dismiss</string>
<!-- Home screen icons - Long press shortcuts -->
<!-- Shortcut action to open new tab -->
<string name="home_screen_shortcut_open_new_tab_2">New tab</string>
......
......@@ -315,7 +315,7 @@ class DefaultTabTrayControllerTest {
@Test
fun handleSetUpAutoCloseTabsClicked() {
controller.handleSetUpAutoCloseTabsClicked()
controller.handleGoToTabsSettingClicked()
val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
verify {
......
......@@ -135,8 +135,8 @@ class TabTrayFragmentInteractorTest {
}
@Test
fun onSetUpAutoCloseTabsClicked() {
interactor.onSetUpAutoCloseTabsClicked()
verify { controller.handleSetUpAutoCloseTabsClicked() }
fun onGoToTabsSettingClicked() {
interactor.onGoToTabsSettings()
verify { controller.handleGoToTabsSettingClicked() }
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment