From 7b31543d7a3a5f4fff65d9735e7912a84ab2bc35 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Thu, 25 Jul 2024 17:55:17 +0200 Subject: [PATCH] feat(StatusDisplayItem/WarningFiltered): apply equal inset vertically --- .../displayitems/WarningFilteredStatusDisplayItem.java | 10 +++++----- .../android/ui/utils/InsetStatusItemDecoration.java | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java index bd8fc60b44..97899833aa 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java @@ -52,13 +52,13 @@ public void onBind(WarningFilteredStatusDisplayItem item){ String title=item.applyingFilter.title; text.setText(item.parentFragment.getString(R.string.sk_filtered, title)); - itemView.setClipToOutline(item.inset); - itemView.setOutlineProvider(item.inset ? OutlineProviders.roundedRect(12) : null); + if(item.inset){ + itemView.setClipToOutline(true); + itemView.setOutlineProvider(OutlineProviders.roundedRect(12)); + } } @Override - public void onClick(){ - - } + public void onClick(){} } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java index cb4a2b08ee..b6e893d434 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java @@ -11,6 +11,7 @@ import org.joinmastodon.android.ui.displayitems.StatusDisplayItem; import org.joinmastodon.android.ui.displayitems.LinkCardStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.MediaGridStatusDisplayItem; +import org.joinmastodon.android.ui.displayitems.WarningFilteredStatusDisplayItem; import java.util.List; @@ -42,13 +43,16 @@ public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull Rec boolean inset=(holder instanceof StatusDisplayItem.Holder sdi) && sdi.getItem().inset; if(inset){ if(rect.isEmpty()){ - if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder){ - rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight() + V.dp(4)); + if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder || holder instanceof WarningFilteredStatusDisplayItem.Holder){ + float topInset=i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(); + if(holder instanceof WarningFilteredStatusDisplayItem.Holder) + topInset-=V.dp(4); + rect.set(child.getX(), topInset, child.getX() + child.getWidth(), child.getY() + child.getHeight() + V.dp(4)); }else { rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight()); } }else{ - if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder){ + if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder || holder instanceof WarningFilteredStatusDisplayItem.Holder){ rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight()) + V.dp(4); }else { rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight());