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

[Nullability Annotations to Java Classes] Replace findViewById with ViewBinding for Comments (relatively safe) #19217

Merged

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Sep 19, 2023

Parent #18906

This PR's main focus is to replace findViewById with ViewBinding for the CommentsDetailActivity.java class.

Additionally, this PR is also dealing with adding any missing nullability annotations to this activity class, focusing mainly on its fields, and, any effected neighbour classes. But first, all existing warnings on this class are being resolved/suppressed so as to make it easier to deal with any missing nullability checks (with help from the IDE), especially when a @Nullable annotation is added.

FYI: This change is relatively safe, meaning that although there are compile-time changes associated with this change, and it needs testing, the changes included in this PR are very targeted and specific to one screen, and one screen only. Thus, if this screen is tested appropriately, it should be safe to merge this to trunk.


PS: @AjeshRPai I added you as the main reviewer, randomly so, since I just wanted someone from the Jetpack/WordPress mobile team to be aware of and sign-off on that change for JP/WPAndroid. Feel free to merge this PR directly yourself if you deem so.


findViewById -> ViewBinding

  1. Replace findviewbyid with viewbinding for comments detail
  2. Use non-null viewbinding method parameter for comments detail

Nullability Annotation List:

  1. Add missing nullability annotations to sdk override methods
  2. Add missing nl-a to status filter field
  3. Add missing nl-a to site field
  4. Add missing nl-a to adapter field
  5. Add missing nl-a to on page change listener field

Warnings Suppression List:

  1. Suppress deprecation warnings on comments detail

To test:

  1. Quickly smoke test any comments related functionality on both, the WordPress and Jetpack apps, and see if everything is working as expected.
  2. In addition to the above smoke test, you can expand the below and follow the inner and more explicit test steps within:
Comment Details Screen [CommentsDetailActivity.java]

ℹ️ This test applies to both, the Jetpack and WordPress app.

  • Go to Comments screen and tap on any comment.
  • Verify that the Comment Details screen is shown and functioning as expected.
  • For example, try replying, approving, marking as spam, liking, trashing, editing or copying a comment's link address. Most importantly, make sure to verify that you can swipe left-right to navigate between comments.

Regression Notes

  1. Potential unintended areas of impact

    • N/A
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • See To test section above.
  3. What automated tests I added (or what prevented me from doing so)

    • N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes testing checklist:

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

This is done in order to avoid using the 'if (mBinding != null) { ... }'
check everywhere and only use that where absolutely necessary, which
usually is only needed when a 'binding' is required via an SDK related
'@OverRide' method, that is, it being the 'binding' starting point.

FYI: This way, when this class gets converted to Kotlin (in the future),
instead of using the 'binding' as a parameter to a method, the same
method will get converted to a 'binding' extension function, and then,
everything will become much more straightforward. For what is worth,
this pattern is already used as such with Kotlin classes. For example,
see 'PreviewImageFragment.kt' class and its 'initializeViews()'
extension function.
Warnings:
- "Deprecated member 'CommentsDetailActivity' is still used"
- "'org.wordpress.android.ui.comments.CommentActions'
is deprecated"
- "'org.wordpress.android.ui.comments.unified.CommentsStoreAdapter'
is deprecated"
- "'org.wordpress.android.ui.comments.CommentDetailFragmentAdapter'
is deprecated"
- "'org.wordpress.android.ui.comments.CommentsDetailActivity'
is deprecated"
FYI: 'nl-a' stands for 'nullable annotation'.
FYI: 'nl-a' stands for 'nullable annotation'.
FYI: 'nl-a' stands for 'nullable annotation'.
FYI: 'nl-a' stands for 'nullable annotation'.
@wpmobilebot
Copy link
Contributor

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
Versionpr19217-5953977
Commit5953977
Direct Downloadwordpress-prototype-build-pr19217-5953977.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

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
Versionpr19217-5953977
Commit5953977
Direct Downloadjetpack-prototype-build-pr19217-5953977.apk
Note: Google Login is not supported on these builds.

@ParaskP7 ParaskP7 requested a review from AjeshRPai September 19, 2023 13:05
@ParaskP7 ParaskP7 marked this pull request as ready for review September 19, 2023 13:05
Copy link
Contributor

@AjeshRPai AjeshRPai left a comment

Choose a reason for hiding this comment

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

Hey @ParaskP7

The changes looks good to me and I have tested the Comment detail page in JP and WP. Everything is working as expected 👍🏼

@AjeshRPai AjeshRPai merged commit 556516b into trunk Sep 21, 2023
@AjeshRPai AjeshRPai deleted the refactor/replace-findviewbyid-with-viewbinding-for-comments branch September 21, 2023 10:49
@ParaskP7
Copy link
Contributor Author

Awesome, thanks for much for reviewing, testing and merging this @AjeshRPai , you rock! 🙇 ❤️ 🚀

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.

3 participants