Skip to content

Conversation

whym
Copy link
Collaborator

@whym whym commented Apr 22, 2025

Description (required)

Fixes #6264 and #5030

  1. I replaced the credit line in the list of images (in contribution, explore, etc) with 3 kinds of text, in order to resolve [Bug]: Uploaded by shows what's in the source/author field, not the upload #6264 (comment)

  2. I added mechanism to retrieve creator value, when needed & available. This is to resolve Author field shows HTML tags when template used #5030 and used when HTML parsing of the author field fails. (More on this below.)

Because structured data requires additional HTTP requests, I took this approach:

  • First parse the HTML (which is already retrieved). If the HTML is in non-standard format (basically anything other than the HTML version of [[User:UserName|AnotherName]]), it fails.
  • If fails, show the uploader only immediately. Retrieve creator label(s) from structured data, and redraw the credit line, usually half a second later.

Tests performed (required)

I mostly used an API 35 emulator with betaDebug and prodDebug. I briefly tested with Pixel 3 and prodDebug, too.

For BetaDebug: I removed the author values from file pages, and added "author" values in structured data. (Its P253075 on Beta Cluter.) The latter was shown in the contributions activity.

For ProdDebug: # 3 Featured Picture is "Blackspotted puffer (''Arothron nigropunctatus''), Anilao, Philippines". Its credit line contained an HTML fragment. It now shows "Diego Delso". (I added the creator value into the structured data.)

Screenshots (for UI changes only)

Screenshot_20250422_2056102

Untitled

Remaining tasks to be resolved:

  • author name string is frequently used on Commons, and should be supported. (It supports entity labels only for now.)
  • There can be more than one uploader for one image (because an image can be overwritten), but only one is shown for now.

Less critical concerns:

  • The duplicated code added in ContributionViewHolder and PagedMediaAdapter is not ideal. Not happy with more parameters being passed around to ContributionViewHolder. To resolve this, I think a large refactoring in the surrounding code is necessary. (A new ViewModel might help?)
  • Class Media is getting large. Do we want to keep adding parameters to it?

- When author is not uploader, show both.
- When failing to parse author from HTML, use structured data.
Copy link

✅ Generated APK variants!

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.

Working great, thanks!

@nicolas-raoul nicolas-raoul merged commit 329a682 into commons-app:main Apr 23, 2025
1 check passed
@whym whym deleted the author-fix branch April 26, 2025 03:20
sonalyadav1 pushed a commit to sonalyadav1/apps-android-commons that referenced this pull request May 22, 2025
- When author is not uploader, show both.
- When failing to parse author from HTML, use structured data.
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.

[Bug]: Uploaded by shows what's in the source/author field, not the upload Author field shows HTML tags when template used
2 participants