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

fix(android/application): org.nativescript.widgets.Utils::getDrawable #9563

Merged
merged 6 commits into from Sep 25, 2021
Merged

fix(android/application): org.nativescript.widgets.Utils::getDrawable #9563

merged 6 commits into from Sep 25, 2021

Conversation

@sebj54
Copy link
Contributor

@sebj54 sebj54 commented Sep 22, 2021

Avoid StringIndexOutOfBoundsException in org.nativescript.widgets.Utils

As it is my first PR to this repo, I am not experimented that much with native development. Feel free to guide me so I'll now next time :)

For example, I don't know how to test this file in a NativeScript project :/

PR Checklist

What is the current behavior?

Calling org.nativescript.widgets.Utils::getDrawable with a uri shorter than 6 characters throws a StringIndexOutOfBoundsException.

What is the new behavior?

An early check in this method ensures uri is longer than 6 characters so a warning is shown in the console.

Fixes #9562.

@cla-bot cla-bot bot added the cla: yes label Sep 22, 2021
@rigor789
Copy link
Member

@rigor789 rigor789 commented Sep 22, 2021

@sebj54 thanks for taking the time to do a PR - the change look good to me, I left a minor suggestion in the review.

The way you can test this requires building the widgets, which can be done by running npm start (after setting up the repo) and selecting the @nativescript/ui-mobile-base: Build for npm option - this should build the widgets lib. Then you can run any of the test apps in the repo: ui, automated or toolbox.

For this case specifically, I think a new test-case in the ui app would suffice - adding a few views and setting their background-image to a few variants like res:// res://non-existent res://icon

sebj54 and others added 2 commits Sep 22, 2021
@sebj54
Copy link
Contributor Author

@sebj54 sebj54 commented Sep 22, 2021

@rigor789 Thank you for your help! I added some views in the ui app. It runs correctly on my device but feel free to let me know if it's not exactly what was expected.

PS: The Android CI test has failed, is it expected?

These make the app crash without the fix in place
@rigor789
Copy link
Member

@rigor789 rigor789 commented Sep 25, 2021

@sebj54 yeah, the CI has been flaky for some time now, still not sure why - it works locally...

I added a few more test-cases - the last few make the app crash without the fix, so they verify that this fixes the IndexOutOfBoundsException.

Awesome job 🎉

@rigor789 rigor789 merged commit 8e76bbe into NativeScript:master Sep 25, 2021
2 of 3 checks passed
@sebj54
Copy link
Contributor Author

@sebj54 sebj54 commented Sep 25, 2021

Thanks for the time you took to get me ready :)
So happy to have one commit in such an awesome project! 🙌

@rigor789
Copy link
Member

@rigor789 rigor789 commented Sep 25, 2021

Thanks for taking the time @sebj54, hopefully sparked some interest in contributing again in the future 🎉

@sebj54
Copy link
Contributor Author

@sebj54 sebj54 commented Sep 25, 2021

I hope to be able to do it soon :)

@sebj54 sebj54 deleted the patch-1 branch Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants