Skip to content

Commit

Permalink
improve preview card when there is no author or description (#4872)
Browse files Browse the repository at this point in the history
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"/>
  • Loading branch information
connyduck authored Jan 17, 2025
1 parent 9e59780 commit fd7d966
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ protected void setupCard(
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);
Expand All @@ -1183,7 +1183,12 @@ protected void setupCard(
}
}

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);
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_preview_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:id="@+id/status_card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="80dp"
android:minHeight="@dimen/card_image_horizontal_width"
android:gravity="center"
android:orientation="vertical">

Expand All @@ -29,6 +29,7 @@
android:paddingVertical="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
Expand Down

0 comments on commit fd7d966

Please sign in to comment.