pull/600/head
Gabriel Luong 4 years ago committed by GitHub
parent ab1e56ef5b
commit a1e4f02882

@ -52,7 +52,7 @@ interface TabTrayController {
fun handleOpenTab(tab: Tab) fun handleOpenTab(tab: Tab)
fun handleEnterMultiselect() fun handleEnterMultiselect()
fun handleRecentlyClosedClicked() fun handleRecentlyClosedClicked()
fun handleSetUpAutoCloseTabsClicked() fun handleGoToTabsSettingClicked()
} }
/** /**
@ -239,7 +239,7 @@ class DefaultTabTrayController(
navController.navigate(directions) navController.navigate(directions)
} }
override fun handleSetUpAutoCloseTabsClicked() { override fun handleGoToTabsSettingClicked() {
val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment() val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
navController.navigate(directions) navController.navigate(directions)
} }

@ -70,9 +70,10 @@ interface TabTrayInteractor {
fun onModeRequested(): TabTrayDialogFragmentState.Mode 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. * Called when a tab should be opened in the browser.
@ -173,7 +174,7 @@ class TabTrayFragmentInteractor(private val controller: TabTrayController) : Tab
controller.handleEnterMultiselect() controller.handleEnterMultiselect()
} }
override fun onSetUpAutoCloseTabsClicked() { override fun onGoToTabsSettings() {
controller.handleSetUpAutoCloseTabsClicked() controller.handleGoToTabsSettingClicked()
} }
} }

@ -270,7 +270,29 @@ class TabTrayView(
adjustNewTabButtonsForNormalMode() adjustNewTabButtonsForNormalMode()
@Suppress("ComplexCondition")
if ( 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().shouldShowAutoCloseTabsBanner &&
view.context.settings().canShowCfr && view.context.settings().canShowCfr &&
tabs.size >= TAB_COUNT_SHOW_CFR tabs.size >= TAB_COUNT_SHOW_CFR
@ -284,7 +306,7 @@ class TabTrayView(
dismissByHiding = true, dismissByHiding = true,
dismissAction = { view.context.settings().shouldShowAutoCloseTabsBanner = false } dismissAction = { view.context.settings().shouldShowAutoCloseTabsBanner = false }
) { ) {
interactor.onSetUpAutoCloseTabsClicked() interactor.onGoToTabsSettings()
view.context.settings().shouldShowAutoCloseTabsBanner = false view.context.settings().shouldShowAutoCloseTabsBanner = false
}.apply { }.apply {
view.infoBanner.visibility = View.VISIBLE view.infoBanner.visibility = View.VISIBLE
@ -713,7 +735,7 @@ class TabTrayView(
layoutManager?.scrollToPosition(recyclerViewIndex) layoutManager?.scrollToPosition(recyclerViewIndex)
smoothScrollBy( smoothScrollBy(
0, 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 default = true
) )
var shouldShowGridViewBanner by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_should_show_grid_view_banner),
default = true
)
@VisibleForTesting(otherwise = PRIVATE) @VisibleForTesting(otherwise = PRIVATE)
internal val trackingProtectionOnboardingCount = counterPreference( internal val trackingProtectionOnboardingCount = counterPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_onboarding), 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 --> <!-- 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> <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_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_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> <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. --> <!-- Text for the negative action button to dismiss the Close Tabs Banner. -->
<string name="tab_tray_close_tabs_banner_negative_button_text">Dismiss</string> <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 --> <!-- Home screen icons - Long press shortcuts -->
<!-- Shortcut action to open new tab --> <!-- Shortcut action to open new tab -->
<string name="home_screen_shortcut_open_new_tab_2">New tab</string> <string name="home_screen_shortcut_open_new_tab_2">New tab</string>

@ -315,7 +315,7 @@ class DefaultTabTrayControllerTest {
@Test @Test
fun handleSetUpAutoCloseTabsClicked() { fun handleSetUpAutoCloseTabsClicked() {
controller.handleSetUpAutoCloseTabsClicked() controller.handleGoToTabsSettingClicked()
val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment() val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
verify { verify {

@ -135,8 +135,8 @@ class TabTrayFragmentInteractorTest {
} }
@Test @Test
fun onSetUpAutoCloseTabsClicked() { fun onGoToTabsSettingClicked() {
interactor.onSetUpAutoCloseTabsClicked() interactor.onGoToTabsSettings()
verify { controller.handleSetUpAutoCloseTabsClicked() } verify { controller.handleGoToTabsSettingClicked() }
} }
} }

Loading…
Cancel
Save