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

Refactor usage of Html.fromHtml to use HtmlCompat.fromHtml (Issue #6002) #6071

Closed
wants to merge 1 commit into from

Conversation

sonalyadav1
Copy link
Contributor

Description:

This PR refactors the usage of Html.fromHtml across the project to address the deprecation warning and replace it with HtmlCompat.fromHtml for compatibility across all Android API levels.


Changes:

Replaced deprecated Html.fromHtml with HtmlCompat.fromHtml in multiple files:
StringUtil.kt
NearbyParentFragment.java
FeedbackDialog.kt
ReviewImageFragment.kt


Why:

The Html.fromHtml method has been deprecated, and we aim to ensure compatibility with newer Android versions by using HtmlCompat.fromHtml.

**Fixes: #6002 **


Testing:

Ensure the Html.fromHtml functionality is working correctly after the refactor.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Sorry would you mind fixing the conflict? Thanks a lot!

@sonalyadav1
Copy link
Contributor Author

Thanks for pointing that out!
I'll take care of the conflict and update it shortly.

@sonalyadav1
Copy link
Contributor Author

sonalyadav1 commented Dec 24, 2024

@nicolas-raoul I’ve gone ahead and rebased the branch, force-pushed the changes, and checked the MediaLicenseFragment.java file for any conflicts, but I’m not seeing anything that stands out. Could you kindly take a look again or trigger the CI checks to see if the issue is sorted now?

@parneet-guraya
Copy link
Contributor

@sonalyadav1 Got it, you changed the .java version of the said file but in the mean time upstream branch is updated with .kt version and .java version was deleted. So, you now have to make the same changes to the .kt file and don't include the .java version again.

Hope this helps you :)

@sonalyadav1
Copy link
Contributor Author

@parneet-guraya Just to confirm, based on your message, I should create the MediaLicenseFragment.kt file by converting the logic from the previously existing .java file. Is there anything else I should be aware of in the process?

@parneet-guraya
Copy link
Contributor

Okay, so here what you should do. Basic thing is your branch has .java version but the main branch has .kt so when you rebase, your changes are rewriting over the main branch (as a base) and git couldn't figure out because you have .java version but main branch doesn't so before rewriting it asks you to solve the conflict to avoid losing your work.

Also, when you finished with all the things below , do the diff locally to make sure only intended changes exist. Then only do the force push because if anything goes wrong this is your backup to start fresh.

Now here's what you can do ->

  • update main branch git pull upstream (or whatever name you kept) main
  • Checkout to your branch & bring the .kt version of the file in your branch

in terminal git checkout main app/src/main/java/fr/free/nrw/commons/upload/license/MediaLicenseFragment.kt

This will bring and stage the file into your current branch.

  • Now, whatever changes you made in the .java version do the same in the new file (in this case it is MediaLicenseFragment) you brought in.
  • After this delete the .java file (make sure IDE doesn't do any refactoring itself other than deleting the file)
  • make sure your changes only include deletion of the .java file and a new .kt file (with your changes)
  • Now, stage the changes git add . and the amend the commit by using git commit --amend (again before doing this make sure you're making the only changes I mentioned)
  • Now you're done just do the rebase as you do and you will se no conflict.

@nicolas-raoul
Copy link
Member

Since the change is not very big, another solution is to create a different branch from main, apply your changes (to the .kt files), then send a new pull request. 🙂

@parneet-guraya
Copy link
Contributor

Well that works too 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants