mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Use user prop if author is empty or null
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parent
9e1df07516
commit
4634eeb7d9
6 changed files with 23 additions and 20 deletions
|
|
@ -125,6 +125,19 @@ class Media constructor(
|
|||
categoriesHiddenStatus = categoriesHiddenStatus
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns Author if it's not null or empty, otherwise
|
||||
* returns user
|
||||
* @return Author or User
|
||||
*/
|
||||
fun getAuthorOrUser(): String? {
|
||||
return if (!author.isNullOrEmpty()) {
|
||||
author
|
||||
} else{
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets media display title
|
||||
* @return Media title
|
||||
|
|
|
|||
|
|
@ -98,14 +98,9 @@ class GridViewAdapter(
|
|||
*/
|
||||
@SuppressLint("StringFormatInvalid")
|
||||
private fun setUploaderView(item: Media, uploader: TextView) {
|
||||
if (!item.author.isNullOrEmpty()) {
|
||||
uploader.visibility = View.VISIBLE
|
||||
uploader.text = context.getString(
|
||||
R.string.image_uploaded_by,
|
||||
item.user
|
||||
item.getAuthorOrUser()
|
||||
)
|
||||
} else {
|
||||
uploader.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ an upload might take a dozen seconds. */
|
|||
this.contribution = contribution
|
||||
this.position = position
|
||||
binding.contributionTitle.text = contribution.media.mostRelevantCaption
|
||||
binding.authorView.text = contribution.media.author
|
||||
binding.authorView.text = contribution.media.getAuthorOrUser()
|
||||
|
||||
//Removes flicker of loading image.
|
||||
binding.contributionImage.hierarchy.fadeDuration = 0
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class DeleteHelper @Inject constructor(
|
|||
|
||||
val userPageString = "\n{{subst:idw|${media.filename}}} ~~~~"
|
||||
|
||||
val creator = media.author
|
||||
val creator = media.getAuthorOrUser()
|
||||
?: throw RuntimeException("Failed to nominate for deletion")
|
||||
|
||||
return pageEditClient.prependEdit(
|
||||
|
|
|
|||
|
|
@ -52,12 +52,7 @@ class SearchImagesViewHolder(
|
|||
binding.categoryImageView.setOnClickListener { onImageClicked(item.second) }
|
||||
binding.categoryImageTitle.text = media.mostRelevantCaption
|
||||
binding.categoryImageView.setImageURI(media.thumbUrl)
|
||||
if (media.author?.isNotEmpty() == true) {
|
||||
binding.categoryImageAuthor.visibility = View.VISIBLE
|
||||
binding.categoryImageAuthor.text =
|
||||
containerView.context.getString(R.string.image_uploaded_by, media.author)
|
||||
} else {
|
||||
binding.categoryImageAuthor.visibility = View.GONE
|
||||
}
|
||||
containerView.context.getString(R.string.image_uploaded_by, media.getAuthorOrUser())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
.append("\n\n");
|
||||
|
||||
builder.append("User that you want to report: ")
|
||||
.append(media.getAuthor())
|
||||
.append(media.getUser())
|
||||
.append("\n\n");
|
||||
|
||||
if (sessionManager.getUserName() != null) {
|
||||
|
|
@ -423,7 +423,7 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
// Initialize bookmark object
|
||||
bookmark = new Bookmark(
|
||||
m.getFilename(),
|
||||
m.getAuthor(),
|
||||
m.getAuthorOrUser(),
|
||||
BookmarkPicturesContentProvider.uriForName(m.getFilename())
|
||||
);
|
||||
updateBookmarkState(menu.findItem(R.id.menu_bookmark_current_image));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue