Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

room summary now has constant height #7145

Merged
merged 7 commits into from
Sep 19, 2022

Conversation

fedrunov
Copy link
Contributor

@fedrunov fedrunov commented Sep 15, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Currently room summary item height is not constant - it can vary depending if there is enough text in the last message/event to go on a second line. This cause some flickering and jumping scrolls when placeholders are replaced with actual items. To mitigate this I've forced last event text view to have constant amount of lines (2 normally, reduced to 1 if font scale is bigger than "Large"). Also Placeholder's items had height defined in dp, which caused them to have wrong height if font size is scaled.

Motivation and context

closes #7079

Screenshots / GIFs

before changes (look for first room item's height):

before

After changes:

normal

with font scaling (Huge):

huge

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking of fixing this issue since a long time, thanks for doing it! (I think I have a local branch with some attempt somewhere).
I was wondering if it would be possible to define a dimen resource for the cell height, which could be with unit sp, so that we ensure that the room item and the placeholder have the same height, and so we avoid regression. WDYT?

@@ -0,0 +1 @@
Fix text margin in QR code view when no display name is set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I wonder where I put the correct one 😅


if (useSingleLineForLastEvent) {
holder.subtitleView.setLines(1)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since items can be recycled, we need to add a else block here. But since the value is constant in the controller, I think this is fine.

return roomSummaryItemFactory.create(item, roomChangeMembershipStates.orEmpty(), emptySet(), displayMode, listener)
return if (item == null) {
val host = this
RoomSummaryItemPlaceHolder_().apply {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: roomSummaryItemPlaceHolder{ } could be used

Suggested change
RoomSummaryItemPlaceHolder_().apply {
roomSummaryItemPlaceHolder {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roomSummaryItemPlaceHolder adds model to collector, but here we need to return item instead, so we can't really use this inside buildItemModel method :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, true, my bad.

return roomSummaryItemFactory.create(item, roomChangeMembershipStates.orEmpty(), emptySet(), RoomListDisplayMode.ROOMS, listener)
return if (item == null) {
val host = this
RoomSummaryItemPlaceHolder_().apply {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: roomSummaryItemPlaceHolder{ } could be used

Suggested change
RoomSummaryItemPlaceHolder_().apply {
roomSummaryItemPlaceHolder {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roomSummaryItemPlaceHolder adds model to collector, but here we need to return item instead, so we can't really use this inside buildItemModel method :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough :)


init {
val fontScale = fontScalePreferences.getResolvedFontScaleValue()
shouldUseSingleLine = fontScale.scale > FontScalePreferences.SCALE_LARGE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tiny detail, but I would have used >=

Suggested change
shouldUseSingleLine = fontScale.scale > FontScalePreferences.SCALE_LARGE
shouldUseSingleLine = fontScale.scale >= FontScalePreferences.SCALE_LARGER

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel ok checking equality of two floating-point numbers. We don't do any calculations here, so they should be the same, but I still concerned. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, OK

* @param layoutManager - [LinearLayoutManager] of the recycler view, which displays items
* @param onItemUpdated - callback to be called, when observer detects event
*/
class FirstItemUpdatedObserver(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(you have to use @property instead of @param for class members documentation, in this case onItemUpdated )

@fedrunov fedrunov added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Sep 19, 2022
@ElementBot
Copy link

Warnings
⚠️

vector/src/main/res/layout/item_recent_room.xml#L10 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

⚠️

vector/src/main/res/layout/item_recent_room.xml#L10 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

⚠️

vector/src/main/res/layout/item_room.xml#L8 - Possible overdraw: Root element paints background ?android:colorBackground with a theme that also paints a background (inferred theme is @android:style/Theme.Holo)

⚠️

vector/src/main/res/layout/item_room.xml#L8 - Possible overdraw: Root element paints background ?android:colorBackground with a theme that also paints a background (inferred theme is @android:style/Theme.Holo)

⚠️

vector/src/main/res/layout/item_room.xml#L11 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

⚠️

vector/src/main/res/layout/item_room.xml#L11 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

⚠️

vector/src/main/res/layout/item_room_placeholder.xml#L8 - Possible overdraw: Root element paints background ?android:colorBackground with a theme that also paints a background (inferred theme is @android:style/Theme.Holo)

⚠️

vector/src/main/res/layout/item_room_placeholder.xml#L8 - Possible overdraw: Root element paints background ?android:colorBackground with a theme that also paints a background (inferred theme is @android:style/Theme.Holo)

⚠️

vector/src/main/res/layout/item_room_placeholder.xml#L11 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

⚠️

vector/src/main/res/layout/item_room_placeholder.xml#L11 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

Generated by 🚫 dangerJS against 469839a

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

11.0% 11.0% Coverage
0.0% 0.0% Duplication

@fedrunov fedrunov merged commit 830e5ff into develop Sep 19, 2022
@fedrunov fedrunov deleted the bugfix/nfe/room_placeholder_height branch September 19, 2022 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New App Layout | PagedList is buggy (long placeholders, jumpt to top)
4 participants