From c23df0c065efe4d0894555533b504635f50c7a3f Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 17 Nov 2022 20:46:39 +0100 Subject: [PATCH 1/2] tweak content warning styles --- .../android/ui/displayitems/TextStatusDisplayItem.java | 1 + mastodon/src/main/res/layout/display_item_text.xml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index 939383003..16054144b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -78,6 +78,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ public void onBind(TextStatusDisplayItem item){ text.setText(item.text); text.setTextIsSelectable(item.textSelectable); + spoilerTitleInline.setTextIsSelectable(item.textSelectable); text.setInvalidateOnEveryFrame(false); if(!TextUtils.isEmpty(item.status.spoilerText)){ spoilerTitle.setText(item.parsedSpoilerText); diff --git a/mastodon/src/main/res/layout/display_item_text.xml b/mastodon/src/main/res/layout/display_item_text.xml index 8cdcc8072..79f8a57af 100644 --- a/mastodon/src/main/res/layout/display_item_text.xml +++ b/mastodon/src/main/res/layout/display_item_text.xml @@ -14,6 +14,8 @@ @@ -35,7 +36,6 @@ From b1f7acb76bb6036665adb75cbb940fc1914b3663 Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 17 Nov 2022 21:24:43 +0100 Subject: [PATCH 2/2] fix content warnings overflowing notifications --- .../displayitems/TextStatusDisplayItem.java | 21 ++++++++++++++++++- .../src/main/res/layout/display_item_text.xml | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index 16054144b..a5a3a2515 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -5,8 +5,10 @@ import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.text.TextUtils; +import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import org.joinmastodon.android.R; @@ -20,6 +22,7 @@ import org.joinmastodon.android.ui.views.LinkedTextView; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.MovieDrawable; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; +import me.grishka.appkit.utils.V; public class TextStatusDisplayItem extends StatusDisplayItem{ private CharSequence text; @@ -61,8 +64,10 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ private final LinkedTextView text; + private final LinearLayout spoilerHeader; private final TextView spoilerTitle, spoilerTitleInline; - private final View spoilerOverlay, spoilerHeader; + private final View spoilerOverlay, borderTop, borderBottom; + private final Drawable backgroundColor, borderColor; public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_text, parent); @@ -71,7 +76,17 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ spoilerTitleInline=findViewById(R.id.spoiler_title_inline); spoilerHeader=findViewById(R.id.spoiler_header); spoilerOverlay=findViewById(R.id.spoiler_overlay); + borderTop=findViewById(R.id.border_top); + borderBottom=findViewById(R.id.border_bottom); itemView.setOnClickListener(v->item.parentFragment.onRevealSpoilerClick(this)); + + TypedValue outValue=new TypedValue(); + activity.getTheme().resolveAttribute(R.attr.colorBackgroundLight, outValue, true); + backgroundColor=activity.getDrawable(outValue.resourceId); +// activity.getTheme().resolveAttribute(R.attr.colorBackgroundLightest, outValue, true); +// backgroundColorInset=activity.getDrawable(outValue.resourceId); + activity.getTheme().resolveAttribute(R.attr.colorPollVoted, outValue, true); + borderColor=activity.getDrawable(outValue.resourceId); } @Override @@ -80,6 +95,10 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ text.setTextIsSelectable(item.textSelectable); spoilerTitleInline.setTextIsSelectable(item.textSelectable); text.setInvalidateOnEveryFrame(false); + spoilerTitleInline.setBackground(item.inset ? null : backgroundColor); + spoilerTitleInline.setPadding(spoilerTitleInline.getPaddingLeft(), item.inset ? 0 : V.dp(14), spoilerTitleInline.getPaddingRight(), item.inset ? 0 : V.dp(14)); + borderTop.setBackground(item.inset ? null : borderColor); + borderBottom.setBackground(item.inset ? null : borderColor); if(!TextUtils.isEmpty(item.status.spoilerText)){ spoilerTitle.setText(item.parsedSpoilerText); spoilerTitleInline.setText(item.parsedSpoilerText); diff --git a/mastodon/src/main/res/layout/display_item_text.xml b/mastodon/src/main/res/layout/display_item_text.xml index 79f8a57af..4b362531d 100644 --- a/mastodon/src/main/res/layout/display_item_text.xml +++ b/mastodon/src/main/res/layout/display_item_text.xml @@ -19,6 +19,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> @@ -34,6 +35,7 @@ tools:text="CW title"/>