improve preview card when there is no author or description (#4872)

Remove the bottom space on vertical layout, center text vertically on
horizontal layout. Make sure the image on the horizontal layout is at
least square.


Before / After:

<img
src="https://github.com/user-attachments/assets/a2399c50-c878-413f-bb65-a45b2c0af90c"
width="280"/>

<img
src="https://github.com/user-attachments/assets/8b83a1d9-3991-4f9c-981f-2a50354b6727"
width="280"/>
This commit is contained in:
Konrad Pozniak 2025-01-17 12:35:48 +01:00 committed by GitHub
commit fd7d966148
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -1158,7 +1158,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
providerName = Uri.parse(card.getUrl()).getHost();
}
if (TextUtils.isEmpty(providerName) && card.getPublishedAt() != null) {
if (TextUtils.isEmpty(providerName)) {
cardMetadata.setVisibility(View.GONE);
} else {
cardMetadata.setVisibility(View.VISIBLE);
@ -1183,7 +1183,12 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
}
}
if (TextUtils.isEmpty(cardAuthorName)) {
final boolean hasNoAuthorName = TextUtils.isEmpty(cardAuthorName);
if (hasNoAuthorName && TextUtils.isEmpty(card.getDescription())) {
cardAuthor.setVisibility(View.GONE);
cardAuthorButton.setVisibility(View.GONE);
} else if (hasNoAuthorName) {
cardAuthor.setVisibility(View.VISIBLE);
cardAuthor.setText(card.getDescription());
cardAuthorButton.setVisibility(View.GONE);