-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix both timezone problem and saved date problem #5019
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 both timezone problem and saved date problem #5019
Conversation
app/src/main/java/fr/free/nrw/commons/filepicker/UploadableFile.java
Outdated
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/filepicker/UploadableFile.java
Outdated
Show resolved
Hide resolved
Thanks for the reviews @nicolas-raoul :) Now ready to be tested |
// See issue https://github.com/commons-app/apps-android-commons/issues/1971 | ||
String dateTimeSubString = exif.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL); | ||
|
||
String year = dateTimeSubString.substring(0,4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAttribute may return null, so I think you will need to check that first.
(I would personally prefer checking the size than catching IndexOutOfBoundsException, but that's not a huge issue anyway.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a sample file without EXIF - trying to upload this gave a NullPointerException when I tested.
Thanks for the PR @neslihanturan ! I will test ASAP, but in the meantime I did notice that the format of the date that we are outputting in the template at https://commons.wikimedia.org/wiki/File%3ACommons_app_exif_issue.jpg "2022:07:03 (according to Exif data)" is somewhat unusual. @nicolas-raoul @whym do we know if this format is acceptable for the template? It definitely doesn't work with the category, as Photographs taken on 2022:07:03 leads to an invalid link (but I am aware that that is still work in progress). |
Yeah, the end result should look like "{{According to Exif data|2022-07-03}}". (=joined by "-", and zero padded) In the source code it will look like
(combining the preceding 3 parseInt lines into one) This would be in line with the "yyyy-MM-dd" format already used elsewhere in the app's codebase. (That said, the template could be made more flexible to accept different formats, if there is a legitimate need to do so, by submitting an edit request at https://commons.wikimedia.org/wiki/Template_talk:According_to_Exif_data .) |
Here is my test with a picture taken after 3pm JST: https://commons.wikimedia.org/wiki/File:Motomiya,_Tsurumi.jpg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, it works: https://commons.wikimedia.org/wiki/File:Pickles_for_automatic_sale_in_Zushi.jpg
Thanks a lot Nes! :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I tested it again with betaDebug and prodDebug and there was no NullPointerException anymore. Thanks @neslihanturan !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with prodDebug on Samsung Galaxy S20FE, works well for me. Nice work @neslihanturan ! :) I uploaded https://commons.wikimedia.org/wiki/File:Roma_Street_Parkland.jpg with edits (for Issue 1) and the correct date is used. I also uploaded a photo taken at 4.25pm (my timezone is +10 UTC) and the date is also correct there https://commons.wikimedia.org/wiki/File:Koala_22.jpg .
* Fix string for custom selector * Fix bug #4950 back arrow still present on top-level activity (#4952) * Fix bug #4949 by correctly setting previous db version number (#4956) * Fix bug #4949 by correctly setting previous db version number * Fix failing tests * Fix bug #4959 by correctly setting previous db version number and updating the current db version (#4960) * Fix bug #4957 (#4961) * Update library to new version that handles older Java VMs Fixes #4972 I believe. * Versioning for v4.0.0 * Changelog for v4.0.0 * Fix bug #4984 Added queries for package name for Android API 30+ (#4987) * Update mapbox sdk version (#4989) * Versioning for v4.0.1 * Changelog for v4.0.1 * Remove network type information from NetworkUtils (#4996) * Remove network type information from NetworkUtils * Ignore dependent tests * Fix #4992 invert the equals condition to be null safe (#4995) * Fix java.lang.NullPointerException for username in ContributionBoundaryCallback (#5003) * Fix failing tests for PR #5003 (#5004) * Fix java.lang.NullPointerException for username in ContributionBoundaryCallback * Fix failing tests * Update Room DB Version (#5011) * Fix #5001 (#5010) * Fix DB update issue (#5016) * [WIP] Fix both timezone problem and saved date problem (#5019) * Fix both timezone problem and saved date problem * Fixaccidental test code and add comments * Add issue link to the comments * Fix format issue and null checks * Versioning for v4.0.2 * Changelog for v4.0.2 * Add "Report Violation" menu option (#5025) * Add "Report Violation" menu option * Update email template * Update email address * Fixed typo Co-authored-by: Josephine Lim <josephinelim86@gmail.com> * Versioning for v4.0.3 * Changelog for v4.0.3 Co-authored-by: Josephine Lim <josephinelim86@gmail.com> Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com>
Description (required)
Fixes #1971
Tests performed (required)
Tested ProdDebug on Pixel 5 with API level 31
Here is the test upload: https://commons.wikimedia.org/wiki/File%3ACommons_app_exif_issue.jpg
The same upload without changes in this PR: https://commons.wikimedia.org/w/index.php?title=File:Vinkeveen,_Heilig_Hart_van_Jezus_(32).jpg
Auto added categories is not tested yet.