Show author/uploader names in Media Details for Commons licensing compliance (#6375)
Some checks are pending
Android CI / Run tests and generate APK (push) Waiting to run

* Initial plan

* Implement author/uploader display in Media Details

Co-authored-by: nicolas-raoul <99590+nicolas-raoul@users.noreply.github.com>

* Enhanced implementation to use getAttributedAuthor() for better attribution coverage

Co-authored-by: nicolas-raoul <99590+nicolas-raoul@users.noreply.github.com>

* Move Author/Uploader fields to be positioned after License field

Co-authored-by: nicolas-raoul <99590+nicolas-raoul@users.noreply.github.com>

* Remove unnecessary comment lines as requested

Co-authored-by: nicolas-raoul <99590+nicolas-raoul@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nicolas-raoul <99590+nicolas-raoul@users.noreply.github.com>
This commit is contained in:
Copilot 2025-07-15 23:42:55 +09:00 committed by GitHub
parent 7500b6d374
commit 0cda8e4d70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 31 deletions

View file

@ -320,12 +320,6 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
binding.seeMore.setUnderlinedText(R.string.nominated_see_more) binding.seeMore.setUnderlinedText(R.string.nominated_see_more)
if (isCategoryImage) {
binding.authorLinearLayout.visibility = View.VISIBLE
} else {
binding.authorLinearLayout.visibility = View.GONE
}
if (!sessionManager.isUserLoggedIn) { if (!sessionManager.isUserLoggedIn) {
binding.categoryEditButton.visibility = View.GONE binding.categoryEditButton.visibility = View.GONE
binding.descriptionEdit.visibility = View.GONE binding.descriptionEdit.visibility = View.GONE
@ -814,10 +808,27 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
categoryNames.clear() categoryNames.clear()
categoryNames.addAll(media.categories!!) categoryNames.addAll(media.categories!!)
if (media.author == null || media.author == "") { // Show author or uploader information for licensing compliance
val authorName = media.getAttributedAuthor()
val uploaderName = media.user
when {
!authorName.isNullOrEmpty() -> {
// Show author if available
binding.mediaDetailAuthorLabel.text = getString(R.string.media_detail_author)
binding.mediaDetailAuthor.text = authorName
binding.authorLinearLayout.visibility = View.VISIBLE
}
!uploaderName.isNullOrEmpty() -> {
// Show uploader as fallback
binding.mediaDetailAuthorLabel.text = getString(R.string.media_detail_uploader)
binding.mediaDetailAuthor.text = uploaderName
binding.authorLinearLayout.visibility = View.VISIBLE
}
else -> {
// Hide if neither author nor uploader is available
binding.authorLinearLayout.visibility = View.GONE binding.authorLinearLayout.visibility = View.GONE
} else { }
binding.mediaDetailAuthor.text = media.author
} }
} }

View file

@ -125,27 +125,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout
style="@style/MediaDetailContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/authorLinearLayout"
android:orientation="horizontal">
<TextView
style="@style/MediaDetailTextLabelGeneric"
android:layout_width="@dimen/widget_margin"
android:layout_height="match_parent"
android:text="@string/media_detail_author" />
<TextView
style="@style/MediaDetailTextBody"
android:id="@+id/mediaDetailAuthor"
android:layout_width="@dimen/widget_margin"
android:layout_height="match_parent"
tools:text="Media author user name goes here." />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/caption_layout" android:id="@+id/caption_layout"
style="@style/MediaDetailContainer" style="@style/MediaDetailContainer"
@ -263,6 +242,28 @@
tools:text="License link" /> tools:text="License link" />
</LinearLayout> </LinearLayout>
<LinearLayout
style="@style/MediaDetailContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/authorLinearLayout"
android:orientation="horizontal">
<TextView
android:id="@+id/mediaDetailAuthorLabel"
style="@style/MediaDetailTextLabelGeneric"
android:layout_width="@dimen/widget_margin"
android:layout_height="match_parent"
android:text="@string/media_detail_author" />
<TextView
style="@style/MediaDetailTextBody"
android:id="@+id/mediaDetailAuthor"
android:layout_width="@dimen/widget_margin"
android:layout_height="match_parent"
tools:text="Media author user name goes here." />
</LinearLayout>
<LinearLayout <LinearLayout
style="@style/MediaDetailContainer" style="@style/MediaDetailContainer"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -211,6 +211,7 @@
<string name="media_detail_description">Description</string> <string name="media_detail_description">Description</string>
<string name="media_detail_discussion">Discussion</string> <string name="media_detail_discussion">Discussion</string>
<string name="media_detail_author">Author</string> <string name="media_detail_author">Author</string>
<string name="media_detail_uploader">Uploader</string>
<string name="media_detail_uploaded_date">Uploaded date</string> <string name="media_detail_uploaded_date">Uploaded date</string>
<string name="media_detail_license">License</string> <string name="media_detail_license">License</string>
<string name="media_detail_coordinates">Coordinates</string> <string name="media_detail_coordinates">Coordinates</string>