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

Migrated AddCategoryFragment to ViewBinding #20933

Conversation

neeldoshii
Copy link
Contributor

@neeldoshii neeldoshii commented Jun 4, 2024

Description

This pull request migrates the AddCategoryFragment to use ViewBinding, improving type safety and eliminating the need for findViewById calls.

Fixes

Screenshots/ Video

categoryadd.mp4

Steps to reproduce

  1. Create a Post
  2. Click on Any of your Posts
  3. Go to Post Settings
  4. Click on Categories
  5. On top right click on Add Button (+ Button) for adding new categories

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.

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)

@neeldoshii

This comment was marked as outdated.

Copy link
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @neeldoshii and thanks so much for submitting this PR!

You shared a screenshot/video with steps to reproduce and test this migration, many thanks for that, but:

  1. Unfortunately you actually tested a different workflow, the PrepublishingAddCategoryFragment.kt functionality, and not the AddCategoryFragment.
  2. This means that you actually didn't verify that your change didn't brake anything. Which, might result in us merging this and then getting into problems.

I actually found how to test this AddCategoryFragment myself, but, I would like you to invest some extra time into doing that yourself too. Thus, I am not going to give you the answer here. I don't do that just to make it more difficult for you. Instead, I do that to help/guide you into being able to find it yourself, not just for this specific case, but for all the contributions you will be adding to this repo going forward.

FYI: What I did to figure that out is using the debugger. I added breakpoints to classes where I thought they might trigger this workflow. And then, after some time, I found where AddCategoryFragment is actually being used. I would like you to do the same.


As I have already explained, only with property testing, testing all edge-cases actually, will we make sure that we are not adding any regression to this screen. Thus me insisting on properly testing this before and after the change.

I hope all that makes sense and I am not overwhelming you with too much info. 🙏

@ParaskP7
Copy link
Contributor

Also, since we need to run this PR on CI, I need you to fix all the checks first, otherwise I am not able to push this branch and trigger our CI to run on it. In this case, CheckStyle fails with the below:

> Task :WordPress:checkstyle
[ant:checkstyle] [ERROR] /Users/.../WordPress-Android/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java:31:32: Name 'binding' must match pattern '^m[a-zA-Z0-9]*$'. [MemberName]
[ant:checkstyle] [ERROR] /Users/.../WordPress-Android/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java:55:55: ',' is not followed by whitespace. [WhitespaceAfter]
[ant:checkstyle] [ERROR] /Users/.../WordPress-Android/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java:55:60: ',' is not followed by whitespace. [WhitespaceAfter]

To run CheckStyle locally use this command: ./gradlew checkstyle

PS: I also suggest that you run all checks locally before pushing and opening any PR, just to make sure our CI will also succeed afterwards (see pipeline.yml). For you, the most important checks and tests command we use on CI are the following:

  1. ./gradlew checkstyle for Java classes
  2. ./gradlew detekt for Kotlin classes
  3. ./gradlew lintWordpressJalapenoDebug + ./gradlew lintJetpackJalapenoDebug for Android Lint
  4. ./gradlew testWordpressJalapenoDebugUnitTest + ./gradlew testJetpackJalapenoDebugUnitTest for Unit Tests

I hope the above will help you... 🙏


I am going to pause reviewing #20941 until we are done with this PR first, and maybe then, after you apply what you learned here on this other PR, I'll go for another round of review on it. I hope that's okay with you. 😊

@neeldoshii neeldoshii force-pushed the Migrate-`findViewById`-to-`ViewBinding` branch from 5f0bbc3 to b0a3bc5 Compare June 10, 2024 13:14
@neeldoshii
Copy link
Contributor Author

Thank you @ParaskP7 for reviewing 🙏.

Unfortunately you actually tested a different workflow, the PrepublishingAddCategoryFragment.kt functionality, and not the AddCategoryFragment.

Thank you for spotting this mistake. Updated the steps to reproduce the dialog in the description along with the video.

I actually found how to test this AddCategoryFragment myself, but, I would like you to invest some extra time into doing that yourself too. Thus, I am not going to give you the answer here. I don't do that just to make it more difficult for you. Instead, I do that to help/guide you into being able to find it yourself, not just for this specific case, but for all the contributions you will be adding to this repo going forward.

Thank you providing a good learning curve to me 🚀

FYI: What I did to figure that out is using the debugger. I added breakpoints to classes where I thought they might trigger this workflow. And then, after some time, I found where AddCategoryFragment is actually being used. I would like you to do the same.

Thanks for this, this is how I reproduced. Created two debugger breakpoint one at the class and second when the dialog is initialized/created to know when the dialog is called. Then kept playing in the app to wait when the breakpoint gets triggered 😅. This way It ensured this is the correct place.

--

Made the changes so the test passes and committed the new changes. ✅

Copy link
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @neeldoshii !

Thank you so much for your contribution to JP/WPAndroid with this PR! 🥇

I have reviewed and tested this PR as per the instructions, along with triggering CI on it via a draft PR, which I just pushed on the main repo, everything works as expected, good job! 🌟


Thank you for spotting this mistake. Updated the steps to reproduce the dialog in the description along with the video.

Thanks for updating the steps to reproduce, much appreciated! 🥇

Thank you providing a good learning curve to me 🚀

Thank YOU! 🥇

Thanks for this, this is how I reproduced. Created two debugger breakpoint one at the class and second when the dialog is initialized/created to know when the dialog is called. Then kept playing in the app to wait when the breakpoint gets triggered 😅. This way It ensured this is the correct place.

👍

Made the changes so the test passes and committed the new changes. ✅

🚀

@neeldoshii neeldoshii force-pushed the Migrate-`findViewById`-to-`ViewBinding` branch from dbbd2d8 to 0988898 Compare June 11, 2024 12:04
Copy link

sonarcloud bot commented Jun 11, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

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

See analysis details on SonarCloud

@ParaskP7 ParaskP7 merged commit d2199d4 into wordpress-mobile:trunk Jun 13, 2024
21 checks passed
@ParaskP7
Copy link
Contributor

🎉 @neeldoshii , your first contribution to JP/WPAndroid is now history and will be live with the next release, thanks so much for this work! 🥇

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.

2 participants