-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
The redesign of comment details content #20798
The redesign of comment details content #20798
Conversation
…tails-content # Conflicts: # WordPress/src/main/res/layout/comment_detail_fragment.xml
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/notifications_refresh_p2 #20798 +/- ##
====================================================================
+ Coverage 40.72% 40.73% +0.01%
====================================================================
Files 1490 1492 +2
Lines 68612 68604 -8
Branches 11364 11348 -16
====================================================================
+ Hits 27942 27946 +4
+ Misses 38151 38141 -10
+ Partials 2519 2517 -2 ☔ View full report in Codecov by Sentry. |
} | ||
} | ||
|
||
private fun UserProfileBottomSheetBinding.setup(state: UserProfileUiState) { |
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 only moved the code snippets to this function, the logic is not changed.
@@ -23,29 +21,29 @@ import org.wordpress.android.util.image.ImageType | |||
// A user block with slightly different formatting for display in a comment detail | |||
@Suppress("LongParameterList") | |||
class CommentUserNoteBlock( |
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.
Most of the changes are related to renaming variables and removing some unused functions in this file.
@@ -214,7 +212,6 @@ public View onCreateView( | |||
) { | |||
mBinding = CommentDetailFragmentBinding.inflate(inflater, container, false); | |||
mReplyBinding = mBinding.layoutCommentBox; | |||
mActionBinding = CommentActionFooterBinding.inflate(inflater, null, false); |
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.
In this file, I removed a lot of logic related to mActionBinding
which is no longer 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.
Amazing work, Jarvis! 🚀
I tested this on the Google Pixel 7 Pro, and it works perfectly. The only issue I found is that some images are not stretched as they are in the Reader, and custom emojis are sometimes not displayed. This is out of scope since it behaves the same way in trunk, but it’s worth mentioning anyway.
Since the PR is pretty large, I would ask to wait for an extra thorough review from Antonis to make sure it works well and I haven’t missed anything.
WordPress/src/main/java/org/wordpress/android/ui/comments/NotificationCommentDetailFragment.kt
Outdated
Show resolved
Hide resolved
|
||
|
||
return BottomSheetUiState.UserProfileUiState( | ||
userAvatarUrl = mNote!!.iconURL, |
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'm not sure if it's safe to use the not-null assertion for mNote
. Shouldn't we use the same approach as for the mComment
?
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.
In NotificationCommentDetailFragment
, mNote
should be non-null after onCreate()
.
I replaced with note
here.
private val note: Note // note will be non-null after onCreate
get() = mNote!!
sealed class BottomSheetUiState { | ||
@Suppress("SerialVersionUIDInSerializableClass") | ||
data class UserProfileUiState( |
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'm wondering if we shouldn't mark some fields as nullable because not all are always available for all the cases. For example, if the user does not have an avatar URL, it should be null
but not an empty string that has less straight meaning. When using the state in different places with not enough context, it looks like the state has to contain all the data (except for onSiteClickListener
.)
Just leaving this note for your consideration :)
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 100% agree with you, straight meaning is important for us to handle those fields correctly. I find many implementations use default values, but it'd be better if they are defined as nullable.
I suspect that when handling this data with Java in the past, there was a tendency to use defensive programming to avoid crashes. However, now with Kotlin, handling nullables has become much easier. I think we can find time to refactor this.
@@ -16,6 +21,9 @@ import org.wordpress.android.util.ToastUtils | |||
* It'd be better to have multiple fragments for different sources for different purposes | |||
*/ | |||
class NotificationCommentDetailFragment : CommentDetailFragment() { | |||
private val note: Note // note will be non-null after onCreate | |||
get() = mNote!! |
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.
Wdyt of using this getter for all the mNote!!
occurrences in this file?
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.
Yeah, that makes sense, I missed some occurrences in this file when I made the change.
override fun getUserProfileUiState(): BottomSheetUiState.UserProfileUiState { | ||
return BottomSheetUiState.UserProfileUiState( | ||
userAvatarUrl = CommentExtension.getAvatarUrl( | ||
mComment!!, |
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 pick: I wonder if we should avoid the non-null assertion operator for mComment
in this file since it is assigned a nullable value. Wdyt of using ?.
when possible with a default value?
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.
Hmmm, I just reviewed the mComment
, I have a strong sense that mComment
should be non-null in SiteCommentDetailFragment
, but the parent class CommentDetailFragment
handles mComment
with defensive programming and make it like nullable.
I plan to replace it with
private val comment: CommentModel
get() = mComment!!
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 work @jarvislin 👍
I've tested the implementation on a Pixel 8 Pro (Android 14) and everything worked as described for me. The code also looks good and improves the codebase 🏅
I've left a few nit picks related to non-null assertions but nothing blocking on my side. We can revisit this separately as discussed
Quality Gate passedIssues Measures |
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.
Thank you for the changes @jarvislin 🙇
Thank you both for reviewing this PR! |
See https://github.com/orgs/Automattic/projects/944?pane=issue&itemId=60382108
Design: yWt5gg3nWORhu079Qfv3mS-fi-1135_4600
Slack discussion: p1715785205781899/1715757510.947859-slack-C06BWNSR02K
This PR mainly implements the UI redesign of comment details content. I also removed lot of logic related to unused UI components at the moment, some of the logic will come back in modern Kotlin way when I handle the comment moderation tasks.
To Test:
Notifications
tabComment
type...
User Info
Edit comment
.Edit comment
.P.S. The
User Info
bottom sheet displays different UI when we are from a comment or a notification because a notification contains richer information in its data.Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR Submission Checklist:
Skipped
Testing Checklist (strike-out the not-applying and unnecessary ones):