From 1f63401e5b6c87a6cf4a4ed8e3f78c4588d6f285 Mon Sep 17 00:00:00 2001 From: sk Date: Wed, 7 Jun 2023 21:50:50 +0200 Subject: [PATCH] fix pixelfed post editing --- .../android/ui/displayitems/HeaderStatusDisplayItem.java | 8 +++++++- .../java/org/joinmastodon/android/ui/text/HtmlParser.java | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 5a30834f3..35c136221 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -196,7 +196,13 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ args.putBoolean("navigateToStatus", true); } } - if(!redraft && TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText)){ + boolean isPixelfed = item.parentFragment.isInstancePixelfed(); + boolean textEmpty = TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText); + if(!redraft && (isPixelfed || textEmpty)){ + if (isPixelfed) { + args.putString("sourceText", HtmlParser.text(item.status.content)); + args.putString("sourceSpoiler", item.status.spoilerText); + } Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); }else if(item.scheduledStatus!=null){ args.putString("sourceText", item.status.text); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java index 2e6001832..ab58a0480 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java @@ -251,6 +251,10 @@ public class HtmlParser{ return Jsoup.clean(html, Safelist.none()); } + public static String text(String html) { + return Jsoup.parse(html).body().wholeText(); + } + public static CharSequence parseLinks(String text){ Matcher matcher=URL_PATTERN.matcher(text); if(!matcher.find()) // Return the original string if there are no URLs