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

The redesign of comment details content #20798

Merged

Conversation

jarvislin
Copy link
Contributor

@jarvislin jarvislin commented May 10, 2024

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.

Screenshot 1 Screenshot 2
Screenshot_20240516-151102 Screenshot_20240516-151120

To Test:

  1. Sign in JP app
  2. Go to Notifications tab
  3. Click on a notification with Comment type
  4. The UI should be the same as the design on Figma
  5. Click on the icon with three dot ...
  6. It should open the comment menu.
  7. Click on User Info
  8. It should display the user info bottom sheet.
  9. The functionalities on the bottom sheet should be working as before.
  10. Open the comment menu again.
  11. Click on Edit comment.
  12. It should navigate you to the screen of Edit comment.
  13. The functionalities in this screen should be working as before.
  14. Go to My Site -> More -> Comments, click on a comment
  15. Repeat step 5 - 13.
  16. Done, thank you!

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

  1. Potential unintended areas of impact

    • comment, notification
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • manual
  3. What automated tests I added (or what prevented me from doing so)

    • only updated some broken unit tests

PR Submission Checklist:

Skipped


Testing Checklist (strike-out the not-applying and unnecessary ones):

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@dangermattic
Copy link
Collaborator

dangermattic commented May 10, 2024

2 Warnings
⚠️ strings.xml files should only be updated on release branches, when the translations are downloaded by our automation.
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 10, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20798-1b18034
Commit1b18034
Direct Downloadwordpress-prototype-build-pr20798-1b18034.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 10, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20798-1b18034
Commit1b18034
Direct Downloadjetpack-prototype-build-pr20798-1b18034.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 12.98701% with 67 lines in your changes are missing coverage. Please review.

Project coverage is 40.73%. Comparing base (d8edd7a) to head (1b18034).
Report is 148 commits behind head on feature/notifications_refresh_p2.

Files Patch % Lines
...id/ui/notifications/blocks/CommentUserNoteBlock.kt 0.00% 36 Missing ⚠️
...d/ui/comments/unified/CommentActionPopupHandler.kt 0.00% 20 Missing ⚠️
...s/android/ui/comments/SiteCommentDetailFragment.kt 0.00% 9 Missing ⚠️
...ress/android/ui/engagement/UserProfileViewModel.kt 0.00% 0 Missing and 1 partial ⚠️
...android/ui/notifications/blocks/HeaderNoteBlock.kt 50.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

}
}

private fun UserProfileBottomSheetBinding.setup(state: UserProfileUiState) {
Copy link
Contributor Author

@jarvislin jarvislin May 15, 2024

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(
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

@jarvislin jarvislin marked this pull request as ready for review May 16, 2024 12:20
Copy link
Contributor

@justtwago justtwago left a 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.



return BottomSheetUiState.UserProfileUiState(
userAvatarUrl = mNote!!.iconURL,
Copy link
Contributor

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?

Copy link
Contributor Author

@jarvislin jarvislin May 20, 2024

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(
Copy link
Contributor

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 :)

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 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.

@jarvislin jarvislin requested a review from antonis May 22, 2024 07:19
@@ -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!!
Copy link
Contributor

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?

Copy link
Contributor Author

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!!,
Copy link
Contributor

@antonis antonis May 22, 2024

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?

Copy link
Contributor Author

@jarvislin jarvislin May 24, 2024

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!!

Copy link
Contributor

@antonis antonis left a 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

Copy link

sonarcloud bot commented May 24, 2024

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@antonis antonis left a 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 🙇

@jarvislin
Copy link
Contributor Author

Thank you both for reviewing this PR!

@jarvislin jarvislin merged commit afec253 into feature/notifications_refresh_p2 May 24, 2024
18 checks passed
@jarvislin jarvislin deleted the issue/comment-details-content branch May 24, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants