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

5338 bug fix #5340

Merged
merged 8 commits into from
Oct 17, 2023
Merged

5338 bug fix #5340

merged 8 commits into from
Oct 17, 2023

Conversation

1162706031
Copy link
Contributor

Description (required)

Fixes #5338 (you should insert the actual issue number if one exists)

What changes did you make and why?

Fixed a potential ArrayIndexOutOfBoundsException in LanguagesAdapter. The bug was due to the method getIndexOfUserDefaultLocale possibly returning -1 when the user's default locale wasn't found in the language. codes list. The returned value is now properly checked and, if -1, defaults to DEFAULT_INDEX which is set to 0.

Tests performed (required)

Tested ProdDebug on Pixel 3 with API level 30. (replace with actual device and API details)
After multiple rounds of testing, in the case of Chinese and other languages, the program will not directly crash during the process of selecting and uploading images.
image
Before, the app would crash instantly before reaching this page.
Screenshots (for UI changes only)

N/A (since this is a bug fix and doesn't involve any UI changes)

Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.

Remember, it's important to actually test the changes on a real device or emulator before submitting a pull request to ensure that the bug is genuinely fixed and no new issues are introduced.

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.

I am able to reproduce the crash in main, and I confirm that this pull request fixes it.
Upload still works fine: https://commons.m.wikimedia.org/wiki/File%3AMarch_2007%2C_Old_house_in_Valleta.jpg

I just added two minor comments, would you mind editing?
Thanks a lot! :-)

* Represents the default index for the language list. By default, this index corresponds to the
* English language. This serves as a fallback when the user's system language is not present in
* the language_list.xml. Though this default can be changed by the user, it does not affect other
* functionalities of the application. Fix bug issue 5338
Copy link
Member

Choose a reason for hiding this comment

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

tiny change: Would you mind changing "Fix" to "Fixes" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I fix that, can you make approval for it? Thanks!

@nicolas-raoul nicolas-raoul merged commit f130851 into commons-app:main Oct 17, 2023
@nicolas-raoul
Copy link
Member

Thanks a lot @1162706031 for fixing the bug!

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

Successfully merging this pull request may close these issues.

App Crashes When Uploading Images with System Language Set to Chinese
2 participants