Write original message timestamp into saved attachment file metadata.#14739
Open
Trigus42 wants to merge 1 commit into
Open
Write original message timestamp into saved attachment file metadata.#14739Trigus42 wants to merge 1 commit into
Trigus42 wants to merge 1 commit into
Conversation
Set EXIF DateTime and DateTimeOriginal for images (JPEG/PNG/WebP) and update MP4 mvhd/tkhd/mdhd creation_time for videos (mp4/3gpp/quicktime etc.) when saving attachments to the device gallery. This ensures gallery apps sort saved media by the original sent date rather than the save date. Fixes signalapp#14584
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First time contributor checklist
Contributor checklist
Fixes #1234syntaxDescription
Fixes #14584 - saved attachments appearing with the save date instead of the original message date in the gallery.
Commit 237ac9f set
DATE_ADDEDandDATE_MODIFIEDin the Android MediaStore database when saving attachments. The MediaStore is Android's media index - a SQLite database that catalogs files on the device. However, many gallery apps read dates from embedded file metadata rather than MediaStore columns. In my testing on a OnePlus Nord 4 (Android 16), saved attachments still appeared sorted by save date after that commit.This PR writes the original message timestamp (
dateSent) directly into the saved file:DateTimeandDateTimeOriginalvia AndroidXExifInterface.DateTimeOriginalis used here because Signal strips EXIF before sending, so no original capture date exists in the file - the sent date is the best available approximation and is what gallery apps sort by.video/mp4,video/3gpp,video/3gpp2,video/mp2ts,video/quicktime) - binary-patchescreation_timeandmodification_timein themvhd,tkhd, andmdhdboxes in-place, without loading the full file into memory.Other formats (GIF, WebM, etc.) are skipped gracefully - the save still succeeds, just without embedded timestamp metadata.
Testing: Bulk-saved all 4,533 attachments from a real Signal account on the device above. 4,529 succeeded (4 failures were pre-existing missing attachment data, unrelated). Verified correct timestamps via
ffprobeon saved videos and an EXIF reader on saved images.