-
Notifications
You must be signed in to change notification settings - Fork 1.3k
For #21900 - Converted the Tabs Tray Synced Tabs to Compose #22798
For #21900 - Converted the Tabs Tray Synced Tabs to Compose #22798
Conversation
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabsComposables.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabsComposables.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabsComposables.kt
Outdated
Show resolved
Hide resolved
Apologizes for the early drive by. I couldn't help myself to admiring some new Compose code. |
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabsComposables.kt
Outdated
Show resolved
Hide resolved
This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏 |
1 similar comment
This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏 |
app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/TrayPagerAdapter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Just some nits and questions, but it looks good.
I'll leave the final review for gl though since I only focused on Synced Tabs feature and not the Compose code.
app/src/test/java/org/mozilla/fenix/tabstray/FloatingActionButtonBindingTest.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabsListItem.kt
Outdated
Show resolved
Hide resolved
*/ | ||
@Composable | ||
fun SyncedTabsDeviceItem(deviceName: String) { | ||
PrimaryText( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in the designs, we needed to add a horizontal line above the device name. I think it's fine to leave out if you're planning on picking up #19942 next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I noticed that without sticky headers it did become hard to tell one section from the other. My intent was to immediately do the sticky header issue next.
Most recent push was to fix some of the previews. Fun fact: the Compose previews don't like using stuff in the Components class, so the preview builds error out since Components is dependent on FenixApplication. So the most recent changes were to move the URL parsing to make URLs text-friendly out of the Composables and into one of the helper functions. |
This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏 |
app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/viewholders/SyncedTabsPageViewHolder.kt
Outdated
Show resolved
Hide resolved
@@ -69,4 +70,18 @@ class TabsTrayStoreReducerTest { | |||
|
|||
assertEquals(expectedState, resultState) | |||
} | |||
|
|||
@Test | |||
fun `WHEN UpdateSyncedTabs THEN synced tabs are added`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonalmeida Hm.. it's actually interesting to see that we have a Reducer and Store test separately. Usually I see we use the Store test to test the underlying Reducer. Is there any benefit from having them separate like this? I can imagine we end up picking and choosing which actions are dispatched and resulting state in different files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this comment.
What does the store add that needs to be tested? In most of the stores, the store doesn't do anything for us within the structure. The logic is within the state/reducer. Put state in, reduce, test state out.
The store holds an executor and provides single access to the state and to dispatch actions. Nothing worth testing in tabs tray.
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
@@ -76,30 +70,38 @@ class TrayPagerAdapter( | |||
} | |||
PrivateBrowserPageViewHolder.LAYOUT_ID -> { | |||
PrivateBrowserPageViewHolder( | |||
itemView, | |||
LayoutInflater.from(parent.context).inflate(viewType, parent, false), | |||
tabsTrayStore, | |||
browserStore, | |||
interactor | |||
) | |||
} | |||
SyncedTabsPageViewHolder.LAYOUT_ID -> { | |||
SyncedTabsPageViewHolder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we need to do something similar to ComposeViewHolder
to avoid #22383
when (viewHolder) { | ||
is NormalBrowserPageViewHolder -> viewHolder.bind(normalAdapter) | ||
is PrivateBrowserPageViewHolder -> viewHolder.bind(privateAdapter) | ||
is SyncedTabsPageViewHolder -> viewHolder.bind() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worthwhile to align more closely with SessionControlAdapter
. https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt#361
Also wondering if we need to do something like https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt#293.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with which part? not needing bind() call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya not needing to call bind(), I don't think we need to do this in the current PR. This can be a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading back through this, we also may not even need to file a separate follow-up, since the real follow-up is converting the rest of TabsTray to Compose. I'm happy to still do so though, since the timeline for the rest of the stuff is fluctuating.
app/src/main/java/org/mozilla/fenix/tabstray/viewholders/SyncedTabsPageViewHolder.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/viewholders/SyncedTabsPageViewHolder.kt
Outdated
Show resolved
Hide resolved
@@ -191,7 +191,7 @@ | |||
<!-- Browser menu toggle that installs a Progressive Web App shortcut to the site on the device home screen. --> | |||
<string name="browser_menu_install_on_homescreen">Install</string> | |||
<!-- Menu option on the toolbar that takes you to synced tabs page--> | |||
<string name="synced_tabs">Synced tabs</string> | |||
<string name="synced_tabs" moz:removedIn="98" tools:ignore="UnusedResources">Synced tabs</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering about this removal. Are we removing view_synced_tabs_title
because it is never used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Based on some context clues of git annotations, I am under the impression that Sync previously lived under its own screen + screen title, and the layout + string are leftover from that era after synced tabs were moved to the tabs tray.
accountManager = accountManager, | ||
view = this, | ||
lifecycleOwner = lifecycleOwner, | ||
onTabClicked = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe file something for AC about cleaning this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume it'd be a part of this mozilla-mobile/android-components#11552
SyncButtonBinding(store) { listener?.onRefresh() } | ||
} | ||
|
||
override var listener: SyncedTabsView.Listener? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a followup. Same as above about cleaning this up in AC. I would verify with @jonalmeida and make sure there's no other consumers here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I am here, is there an actual listener that is attached to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is some of the weirdness of the Observable<SyncedTabsView.Listener> by ObserverRegistry()
. From my understanding it's initialized at runtime but none of that should be necessary, hopefully, after mozilla-mobile/android-components#11552.
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabsIntegration.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
Most recent push simply increases the spacing between the error text and the error button from 8dp to 12dp. |
Push to update from main to fix colors + build issue |
This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏 |
onClick = onClick | ||
) | ||
.padding(horizontal = 16.dp) | ||
.defaultMinSize(minHeight = 56.dp), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question outside of the review, I am wondering how we decide to uses defaultMinSize
and height(IntrinsicSize.Min)
(in general, nothing in particular about the current code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used defaultMinSize
to be a more direct 1:1 to android:minHeight
in XML (to help ensure with a default text size that there would be enough padding), and the height(IntrinsicSize.Min)
was used when I was specifically trying out random things to get the dashed border for the error UI to show. The documentation for Modifier.height()
and Modifier.defaultMinSize()
aren't the clearest though on when to use either.
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/tabstray/syncedtabs/SyncedTabs.kt
Outdated
Show resolved
Hide resolved
This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏 |
Fixes #21900
Pull Request checklist
To download an APK when reviewing a PR: