Bug 1811976 - Hide Sync FAB in TabsTray when user not signed in

If there is no user signed in, the SYNC FAB should not be displayed
in the sync page of the tabs tray.
fenix/119.0
DreVla 8 months ago committed by mergify[bot]
parent 0e6eb7ab38
commit 78cdc095ff

@ -40,7 +40,6 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
import org.mozilla.fenix.helpers.MatcherHelper.assertItemContainingTextExists
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndDescriptionExists
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdExists
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
@ -297,12 +296,6 @@ class TabDrawerRobot {
itemContainingText(getStringResource(R.string.synced_tabs_sign_in_message)),
itemContainingText(getStringResource(R.string.sync_sign_in)),
)
assertItemWithResIdAndDescriptionExists(
itemWithResIdAndDescription(
"$packageName:id/new_tab_button",
getStringResource(R.string.resync_button_content_description),
),
)
}
class Transition {

@ -21,6 +21,7 @@ class FloatingActionButtonBinding(
store: TabsTrayStore,
private val actionButton: ExtendedFloatingActionButton,
private val interactor: TabsTrayFabInteractor,
private val isSignedIn: Boolean,
) : AbstractBinding<TabsTrayState>(store) {
override suspend fun onState(flow: Flow<TabsTrayState>) {
@ -62,20 +63,25 @@ class FloatingActionButtonBinding(
}
}
Page.SyncedTabs -> {
actionButton.apply {
setText(
when (syncing) {
true -> R.string.sync_syncing_in_progress
false -> R.string.tab_drawer_fab_sync
},
)
contentDescription = context.getString(R.string.resync_button_content_description)
extend()
show()
setIconResource(R.drawable.ic_fab_sync)
setOnClickListener {
interactor.onSyncedTabsFabClicked()
if (isSignedIn) {
actionButton.apply {
setText(
when (syncing) {
true -> R.string.sync_syncing_in_progress
false -> R.string.tab_drawer_fab_sync
},
)
contentDescription =
context.getString(R.string.resync_button_content_description)
extend()
show()
setIconResource(R.drawable.ic_fab_sync)
setOnClickListener {
interactor.onSyncedTabsFabClicked()
}
}
} else {
actionButton.hide()
}
}
}

@ -22,6 +22,7 @@ import org.mozilla.fenix.theme.FirefoxTheme
* Floating action button for tabs tray.
*
* @param tabsTrayStore [TabsTrayStore] used to listen for changes to [TabsTrayState].
* @param isSignedIn Used to know when to show the SYNC FAB when [Page.SyncedTabs] is displayed.
* @param onNormalTabsFabClicked Invoked when the fab is clicked in [Page.NormalTabs].
* @param onPrivateTabsFabClicked Invoked when the fab is clicked in [Page.PrivateTabs].
* @param onSyncedTabsFabClicked Invoked when the fab is clicked in [Page.SyncedTabs].
@ -29,6 +30,7 @@ import org.mozilla.fenix.theme.FirefoxTheme
@Composable
fun TabsTrayFab(
tabsTrayStore: TabsTrayStore,
isSignedIn: Boolean,
onNormalTabsFabClicked: () -> Unit,
onPrivateTabsFabClicked: () -> Unit,
onSyncedTabsFabClicked: () -> Unit,
@ -75,7 +77,7 @@ fun TabsTrayFab(
}
}
if (isInNormalMode) {
if (isInNormalMode && !(currentPage == Page.SyncedTabs && !isSignedIn)) {
FloatingActionButton(
icon = icon,
modifier = Modifier
@ -99,7 +101,13 @@ private fun TabsTraySyncFabPreview() {
)
FirefoxTheme {
TabsTrayFab(store, {}, {}, {})
TabsTrayFab(
tabsTrayStore = store,
isSignedIn = true,
onNormalTabsFabClicked = {},
onPrivateTabsFabClicked = {},
onSyncedTabsFabClicked = {},
)
}
}
@ -112,6 +120,12 @@ private fun TabsTrayPrivateFabPreview() {
),
)
FirefoxTheme {
TabsTrayFab(store, {}, {}, {})
TabsTrayFab(
tabsTrayStore = store,
isSignedIn = true,
onNormalTabsFabClicked = {},
onPrivateTabsFabClicked = {},
onSyncedTabsFabClicked = {},
)
}
}

@ -313,6 +313,7 @@ class TabsTrayFragment : AppCompatDialogFragment() {
FirefoxTheme(theme = Theme.getTheme(allowPrivateTheme = false)) {
TabsTrayFab(
tabsTrayStore = tabsTrayStore,
isSignedIn = requireContext().settings().signedInFxaAccount,
onNormalTabsFabClicked = tabsTrayInteractor::onNormalTabsFabClicked,
onPrivateTabsFabClicked = tabsTrayInteractor::onPrivateTabsFabClicked,
onSyncedTabsFabClicked = tabsTrayInteractor::onSyncedTabsFabClicked,
@ -463,6 +464,7 @@ class TabsTrayFragment : AppCompatDialogFragment() {
store = tabsTrayStore,
actionButton = fabButtonBinding.newTabButton,
interactor = tabsTrayInteractor,
isSignedIn = requireContext().settings().signedInFxaAccount,
),
owner = this,
view = view,

@ -48,6 +48,7 @@ class FloatingActionButtonBindingTest {
tabsTrayStore,
actionButton,
interactor,
true,
)
fabBinding.start()
@ -65,6 +66,7 @@ class FloatingActionButtonBindingTest {
tabsTrayStore,
actionButton,
interactor,
true,
)
fabBinding.start()
@ -82,6 +84,7 @@ class FloatingActionButtonBindingTest {
tabsTrayStore,
actionButton,
interactor,
true,
)
fabBinding.start()
@ -92,6 +95,24 @@ class FloatingActionButtonBindingTest {
verify(exactly = 0) { actionButton.hide() }
}
@Test
fun `GIVEN the selected tab page is sync WHEN the user is not signed in THEN extend and show is called`() {
val tabsTrayStore = TabsTrayStore(TabsTrayState(selectedPage = Page.SyncedTabs))
val fabBinding = FloatingActionButtonBinding(
tabsTrayStore,
actionButton,
interactor,
false,
)
fabBinding.start()
verify(exactly = 0) { actionButton.extend() }
verify(exactly = 0) { actionButton.show() }
verify(exactly = 0) { actionButton.shrink() }
verify(exactly = 1) { actionButton.hide() }
}
@Test
fun `WHEN selected page is updated THEN button is updated`() {
val tabsTrayStore = TabsTrayStore(TabsTrayState(selectedPage = Page.NormalTabs))
@ -99,6 +120,7 @@ class FloatingActionButtonBindingTest {
tabsTrayStore,
actionButton,
interactor,
true,
)
fabBinding.start()

Loading…
Cancel
Save