From 3db9d449fd8abf4ec5366a08b0be9848544f9545 Mon Sep 17 00:00:00 2001
From: Jacocococo
Date: Fri, 10 Nov 2023 18:13:37 +0100
Subject: [PATCH 1/7] Displaying Akkoma quote status
---
.../fragments/BaseStatusListFragment.java | 12 ++--
.../fragments/NotificationsListFragment.java | 1 -
.../fragments/StatusEditHistoryFragment.java | 6 --
.../android/fragments/ThreadFragment.java | 1 +
.../displayitems/AudioStatusDisplayItem.java | 1 -
.../EmojiReactionsStatusDisplayItem.java | 1 -
.../ExtendedFooterStatusDisplayItem.java | 1 -
.../displayitems/FooterStatusDisplayItem.java | 1 -
.../ui/displayitems/GapStatusDisplayItem.java | 1 -
.../displayitems/HeaderStatusDisplayItem.java | 1 -
.../LinkCardStatusDisplayItem.java | 1 -
.../MediaGridStatusDisplayItem.java | 1 -
.../ReblogOrReplyLineStatusDisplayItem.java | 1 -
.../SpoilerStatusDisplayItem.java | 1 -
.../ui/displayitems/StatusDisplayItem.java | 56 ++++++++++++++-----
.../displayitems/TextStatusDisplayItem.java | 3 +-
.../WarningFilteredStatusDisplayItem.java | 1 -
17 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java
index a73d7d7228..5f307f4340 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java
@@ -47,6 +47,7 @@
import org.joinmastodon.android.ui.displayitems.WarningFilteredStatusDisplayItem;
import org.joinmastodon.android.ui.photoviewer.PhotoViewer;
import org.joinmastodon.android.ui.photoviewer.PhotoViewerHost;
+import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
import org.joinmastodon.android.ui.utils.MediaAttachmentViewController;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.joinmastodon.android.utils.ProvidesAssistContent;
@@ -358,6 +359,7 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat
}
});
list.addItemDecoration(new StatusListItemDecoration());
+ list.addItemDecoration(new InsetStatusItemDecoration(this));
((UsableRecyclerView)list).setSelectorBoundsProvider(new UsableRecyclerView.SelectorBoundsProvider(){
private Rect tmpRect=new Rect();
@Override
@@ -564,7 +566,8 @@ public void onError(ErrorResponse error){
public void onRevealSpoilerClick(SpoilerStatusDisplayItem.Holder holder){
Status status=holder.getItem().status;
- toggleSpoiler(status, holder.getItemID());
+ boolean isForQuote=holder.getItem().isForQuote;
+ toggleSpoiler(status, isForQuote, holder.getItemID());
}
public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder) {
@@ -586,15 +589,16 @@ public void onSensitiveRevealed(MediaGridStatusDisplayItem.Holder holder) {
else notifyItemChangedBefore(holder.getItem(), HeaderStatusDisplayItem.class);
}
- protected void toggleSpoiler(Status status, String itemID){
+ protected void toggleSpoiler(Status status, boolean isForQuote, String itemID){
status.spoilerRevealed=!status.spoilerRevealed;
if (!status.spoilerRevealed && !AccountSessionManager.get(accountID).getLocalPreferences().revealCWs)
status.sensitiveRevealed = false;
- SpoilerStatusDisplayItem.Holder spoiler=findHolderOfType(itemID, SpoilerStatusDisplayItem.Holder.class);
+ List spoilers=findAllHoldersOfType(itemID, SpoilerStatusDisplayItem.Holder.class);
+ SpoilerStatusDisplayItem.Holder spoiler=spoilers.size() > 1 && isForQuote ? spoilers.get(1) : spoilers.get(0);
if(spoiler!=null) spoiler.rebind();
else notifyItemChanged(itemID, SpoilerStatusDisplayItem.class);
- SpoilerStatusDisplayItem spoilerItem=Objects.requireNonNull(findItemOfType(itemID, SpoilerStatusDisplayItem.class));
+ SpoilerStatusDisplayItem spoilerItem=Objects.requireNonNull(spoiler.getItem());
int index=displayItems.indexOf(spoilerItem);
if(status.spoilerRevealed){
diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java
index bf07bbbbd2..fbb5edcd8f 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java
@@ -174,7 +174,6 @@ public void onItemClick(String id){
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
- list.addItemDecoration(new InsetStatusItemDecoration(this));
list.addItemDecoration(new RecyclerView.ItemDecoration(){
private Paint paint=new Paint();
private Rect tmpRect=new Rect();
diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java
index 0a723a3220..48e4cb16fb 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java
@@ -150,12 +150,6 @@ enum StatusEditChangeType{
return items;
}
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState){
- super.onViewCreated(view, savedInstanceState);
- list.addItemDecoration(new InsetStatusItemDecoration(this));
- }
-
@Override
public boolean isItemEnabled(String id){
return false;
diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java
index 580153f1c5..6546364446 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java
@@ -60,6 +60,7 @@ public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
mainStatus=Parcels.unwrap(getArguments().getParcelable("status"));
Account inReplyToAccount=Parcels.unwrap(getArguments().getParcelable("inReplyToAccount"));
+ refreshing=contextInitiallyRendered=getArguments().getBoolean("refresh", false);
if(inReplyToAccount!=null)
knownAccounts.put(inReplyToAccount.id, inReplyToAccount);
data.add(mainStatus);
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java
index 764a27e015..1333d76d05 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java
@@ -32,7 +32,6 @@
import me.grishka.appkit.utils.V;
public class AudioStatusDisplayItem extends StatusDisplayItem{
- public final Status status;
public final Attachment attachment;
private final ImageLoaderRequest imageRequest;
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java
index d874df595d..f75d17987f 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java
@@ -58,7 +58,6 @@
import me.grishka.appkit.views.UsableRecyclerView;
public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
- public final Status status;
private final Drawable placeholder;
private final boolean hideEmpty, forAnnouncement, playGifs;
private final String accountID;
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java
index 5a2c6810a4..7e7612e1cc 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ExtendedFooterStatusDisplayItem.java
@@ -36,7 +36,6 @@
import me.grishka.appkit.Nav;
public class ExtendedFooterStatusDisplayItem extends StatusDisplayItem{
- public final Status status;
public final String accountID;
private static final DateTimeFormatter TIME_FORMATTER=DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT);
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java
index bf0cce7a49..9d16950845 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java
@@ -38,7 +38,6 @@
import me.grishka.appkit.utils.V;
public class FooterStatusDisplayItem extends StatusDisplayItem{
- public final Status status;
private final String accountID;
public boolean hideCounts;
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/GapStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/GapStatusDisplayItem.java
index 4d0a087e89..9ff796fb91 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/GapStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/GapStatusDisplayItem.java
@@ -19,7 +19,6 @@
public class GapStatusDisplayItem extends StatusDisplayItem{
public boolean loading;
- private final Status status;
public GapStatusDisplayItem(String parentID, BaseStatusListFragment> parentFragment, Status status){
super(parentID, parentFragment);
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 6f1b95c2af..5bda18b063 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
@@ -76,7 +76,6 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
private String accountID;
private CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
private SpannableStringBuilder parsedName;
- public final Status status;
public boolean hasVisibilityToggle;
boolean needBottomPadding;
private CharSequence extraText;
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java
index 59b08451a5..b1ec54bb48 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java
@@ -24,7 +24,6 @@
import me.grishka.appkit.utils.V;
public class LinkCardStatusDisplayItem extends StatusDisplayItem{
- private final Status status;
private final UrlImageLoaderRequest imgRequest;
public LinkCardStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Status status){
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java
index 0d066fdf38..a9330593f1 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java
@@ -53,7 +53,6 @@ public class MediaGridStatusDisplayItem extends StatusDisplayItem{
private final TypedObjectPool viewPool;
private final List attachments;
private final ArrayList requests=new ArrayList<>();
- public final Status status;
public String sensitiveTitle;
public MediaGridStatusDisplayItem(String parentID, BaseStatusListFragment> parentFragment, PhotoLayoutHelper.TiledLayoutResult tiledLayout, List attachments, Status status){
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java
index 096b1f18d6..84df641a1d 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java
@@ -43,7 +43,6 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
public boolean needBottomPadding;
ReblogOrReplyLineStatusDisplayItem extra;
CharSequence fullText;
- Status status;
public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List emojis, @DrawableRes int icon, StatusPrivacy visibility, @Nullable View.OnClickListener handleClick, Status status) {
this(parentID, parentFragment, text, emojis, icon, visibility, handleClick, text, status);
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/SpoilerStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/SpoilerStatusDisplayItem.java
index 722bd5c49d..faeff6a1f6 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/SpoilerStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/SpoilerStatusDisplayItem.java
@@ -24,7 +24,6 @@
import me.grishka.appkit.imageloader.requests.ImageLoaderRequest;
public class SpoilerStatusDisplayItem extends StatusDisplayItem{
- public final Status status;
public final ArrayList contentItems=new ArrayList<>();
private final CharSequence parsedTitle;
private final CustomEmojiHelper emojiHelper;
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
index 9b5995f2d4..0605b0aa8d 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
@@ -58,13 +58,15 @@
public abstract class StatusDisplayItem{
public final String parentID;
public final BaseStatusListFragment> parentFragment;
+ public Status status;
public boolean inset;
public int index;
public boolean
hasDescendantNeighbor=false,
hasAncestoringNeighbor=false,
isMainStatus=true,
- isDirectDescendant=false;
+ isDirectDescendant=false,
+ isForQuote=false;
public static final int FLAG_INSET=1;
public static final int FLAG_NO_FOOTER=1 << 1;
@@ -238,14 +240,10 @@ public static ArrayList buildItems(BaseStatusListFragment>
contentItems=items;
}
- if (statusForContent.quote != null) {
- boolean hasQuoteInlineTag = statusForContent.content.contains("");
- if (!hasQuoteInlineTag) {
- String quoteUrl = statusForContent.quote.url;
- String quoteInline = String.format("%sRE: %s",
- statusForContent.content.endsWith("
") ? "" : "
", quoteUrl, quoteUrl);
- statusForContent.content += quoteInline;
- }
+ if(statusForContent.quote!=null) {
+ int quoteInlineIndex=statusForContent.content.indexOf("");
+ if (quoteInlineIndex!=-1)
+ statusForContent.content=statusForContent.content.substring(0, quoteInlineIndex);
}
boolean hasSpoiler=!TextUtils.isEmpty(statusForContent.spoilerText);
@@ -287,15 +285,30 @@ else if(statusForContent.sensitive && AccountSessionManager.get(accountID).getLo
if(statusForContent.poll!=null){
buildPollItems(parentID, fragment, statusForContent.poll, contentItems);
}
- if(statusForContent.card!=null && statusForContent.mediaAttachments.isEmpty()){
+ if(statusForContent.card!=null && statusForContent.mediaAttachments.isEmpty() && statusForContent.quote==null){
contentItems.add(new LinkCardStatusDisplayItem(parentID, fragment, statusForContent));
}
+ if(statusForContent.quote!=null && !(parentObject instanceof Notification)){
+ contentItems.addAll(
+ buildItems(fragment, statusForContent.quote, accountID, parentObject, knownAccounts, filterContext, FLAG_NO_FOOTER | FLAG_INSET | FLAG_NO_EMOJI_REACTIONS)
+ .stream().peek(item->{
+ item.status=statusForContent.quote;
+ item.isForQuote=true;
+ if(item instanceof SpoilerStatusDisplayItem spoiler){
+ for(StatusDisplayItem spoilerItem:spoiler.contentItems){
+ spoilerItem.isForQuote=true;
+ }
+ }
+ }).collect(Collectors.toList())
+ );
+ }
if(contentItems!=items && statusForContent.spoilerRevealed){
items.addAll(contentItems);
}
AccountLocalPreferences lp=fragment.getLocalPrefs();
if((flags & FLAG_NO_EMOJI_REACTIONS)==0 && lp.emojiReactionsEnabled &&
- (lp.showEmojiReactions!=ONLY_OPENED || fragment instanceof ThreadFragment)){
+ (lp.showEmojiReactions!=ONLY_OPENED || fragment instanceof ThreadFragment) &&
+ statusForContent.reactions!=null){
boolean isMainStatus=fragment instanceof ThreadFragment t && t.getMainStatus().id.equals(statusForContent.id);
boolean showAddButton=lp.showEmojiReactions==ALWAYS || isMainStatus;
items.add(new EmojiReactionsStatusDisplayItem(parentID, fragment, statusForContent, accountID, !showAddButton, false));
@@ -320,12 +333,14 @@ else if(statusForContent.sensitive && AccountSessionManager.get(accountID).getLo
items.add(gap=new GapStatusDisplayItem(parentID, fragment, status));
int i=1;
for(StatusDisplayItem item:items){
- item.inset=inset;
+ if(inset)
+ item.inset=true;
item.index=i++;
}
if(items!=contentItems && !statusForContent.spoilerRevealed){
for(StatusDisplayItem item:contentItems){
- item.inset=inset;
+ if(inset)
+ item.inset=true;
item.index=i++;
}
}
@@ -375,12 +390,15 @@ public enum Type{
}
public static abstract class Holder extends BindableViewHolder implements UsableRecyclerView.DisableableClickable{
+ private Context context;
+
public Holder(View itemView){
super(itemView);
}
public Holder(Context context, int layout, ViewGroup parent){
super(context, layout, parent);
+ this.context=context;
}
public String getItemID(){
@@ -389,6 +407,16 @@ public String getItemID(){
@Override
public void onClick(){
+ if(item.isForQuote){
+ item.status.filterRevealed=true;
+ Bundle args=new Bundle();
+ args.putString("account", item.parentFragment.getAccountID());
+ args.putParcelable("status", Parcels.wrap(item.status.clone()));
+ args.putBoolean("refresh", true);
+ Nav.go((Activity) context, ThreadFragment.class, args);
+ return;
+ }
+
item.parentFragment.onItemClick(item.parentID);
}
@@ -426,7 +454,7 @@ public boolean isLastDisplayItemForStatus(){
@Override
public boolean isEnabled(){
- return item.parentFragment.isItemEnabled(item.parentID);
+ return item.parentFragment.isItemEnabled(item.parentID) || item.isForQuote;
}
}
}
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 5881c66674..20a181b13b 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
@@ -39,7 +39,6 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
public boolean textSelectable;
public boolean reduceTopPadding;
public boolean disableTranslate;
- public final Status status;
public TextStatusDisplayItem(String parentID, CharSequence text, BaseStatusListFragment parentFragment, Status status, boolean disableTranslate){
super(parentID, parentFragment);
@@ -113,7 +112,7 @@ public void onBind(TextStatusDisplayItem item){
text.setText(item.text);
}
text.setTextIsSelectable(false);
- if(item.textSelectable) itemView.post(() -> text.setTextIsSelectable(true));
+ if(item.textSelectable && !item.isForQuote) itemView.post(() -> text.setTextIsSelectable(true));
text.setInvalidateOnEveryFrame(false);
itemView.setClickable(false);
itemView.setPadding(itemView.getPaddingLeft(), item.reduceTopPadding ? V.dp(6) : V.dp(12), itemView.getPaddingRight(), itemView.getPaddingBottom());
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 5f0867d021..2d67feb67a 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
@@ -14,7 +14,6 @@
public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
public boolean loading;
- public final Status status;
public List filteredItems;
public LegacyFilter applyingFilter;
From 7d2de34d6ecf5489b6b141c05886f2df390d43e7 Mon Sep 17 00:00:00 2001
From: Jacocococo
Date: Sun, 12 Nov 2023 20:47:22 +0100
Subject: [PATCH 2/7] Dummy display items for quote posts
---
.../ui/displayitems/StatusDisplayItem.java | 32 +++++++++++--------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
index 0605b0aa8d..cda5fc9742 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
@@ -75,6 +75,7 @@ public abstract class StatusDisplayItem{
public static final int FLAG_NO_HEADER=1 << 4;
public static final int FLAG_NO_TRANSLATE=1 << 5;
public static final int FLAG_NO_EMOJI_REACTIONS=1 << 6;
+ public static final int FLAG_IS_FOR_QUOTE=1 << 7;
public void setAncestryInfo(
boolean hasDescendantNeighbor,
@@ -234,6 +235,11 @@ public static ArrayList buildItems(BaseStatusListFragment>
if(statusForContent.hasSpoiler()){
if (AccountSessionManager.get(accountID).getLocalPreferences().revealCWs) statusForContent.spoilerRevealed = true;
SpoilerStatusDisplayItem spoilerItem=new SpoilerStatusDisplayItem(parentID, fragment, null, statusForContent, Type.SPOILER);
+ if((flags & FLAG_IS_FOR_QUOTE)!=0){
+ for(StatusDisplayItem item:spoilerItem.contentItems){
+ item.isForQuote=true;
+ }
+ }
items.add(spoilerItem);
contentItems=spoilerItem.contentItems;
}else{
@@ -289,18 +295,9 @@ else if(statusForContent.sensitive && AccountSessionManager.get(accountID).getLo
contentItems.add(new LinkCardStatusDisplayItem(parentID, fragment, statusForContent));
}
if(statusForContent.quote!=null && !(parentObject instanceof Notification)){
- contentItems.addAll(
- buildItems(fragment, statusForContent.quote, accountID, parentObject, knownAccounts, filterContext, FLAG_NO_FOOTER | FLAG_INSET | FLAG_NO_EMOJI_REACTIONS)
- .stream().peek(item->{
- item.status=statusForContent.quote;
- item.isForQuote=true;
- if(item instanceof SpoilerStatusDisplayItem spoiler){
- for(StatusDisplayItem spoilerItem:spoiler.contentItems){
- spoilerItem.isForQuote=true;
- }
- }
- }).collect(Collectors.toList())
- );
+ if(!statusForContent.mediaAttachments.isEmpty() && statusForContent.poll==null) // add spacing if immediately preceded by attachment
+ contentItems.add(new DummyStatusDisplayItem(parentID, fragment));
+ contentItems.addAll(buildItems(fragment, statusForContent.quote, accountID, parentObject, knownAccounts, filterContext, FLAG_NO_FOOTER | FLAG_INSET | FLAG_NO_EMOJI_REACTIONS | FLAG_IS_FOR_QUOTE));
}
if(contentItems!=items && statusForContent.spoilerRevealed){
items.addAll(contentItems);
@@ -320,8 +317,9 @@ else if(statusForContent.sensitive && AccountSessionManager.get(accountID).getLo
items.add(footer);
}
boolean inset=(flags & FLAG_INSET)!=0;
+ boolean isForQuote=(flags & FLAG_IS_FOR_QUOTE)!=0;
// add inset dummy so last content item doesn't clip out of inset bounds
- if((inset || footer==null) && (flags & FLAG_CHECKABLE)==0){
+ if((inset || footer==null) && (flags & FLAG_CHECKABLE)==0 && !isForQuote){
items.add(new DummyStatusDisplayItem(parentID, fragment));
// in case we ever need the dummy to display a margin for the media grid again:
// (i forgot why we apparently don't need this anymore)
@@ -335,12 +333,20 @@ else if(statusForContent.sensitive && AccountSessionManager.get(accountID).getLo
for(StatusDisplayItem item:items){
if(inset)
item.inset=true;
+ if(isForQuote){
+ item.status=statusForContent;
+ item.isForQuote=true;
+ }
item.index=i++;
}
if(items!=contentItems && !statusForContent.spoilerRevealed){
for(StatusDisplayItem item:contentItems){
if(inset)
item.inset=true;
+ if(isForQuote){
+ item.status=statusForContent;
+ item.isForQuote=true;
+ }
item.index=i++;
}
}
From cbacfc8a1c2438645cbd25411c462f46e3fefbc6 Mon Sep 17 00:00:00 2001
From: Jacocococo
Date: Sun, 12 Nov 2023 21:00:32 +0100
Subject: [PATCH 3/7] Only remove quote-inline with RE:
---
.../joinmastodon/android/ui/displayitems/StatusDisplayItem.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
index cda5fc9742..7556e67d5a 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
@@ -247,7 +247,7 @@ public static ArrayList buildItems(BaseStatusListFragment>
}
if(statusForContent.quote!=null) {
- int quoteInlineIndex=statusForContent.content.indexOf("");
+ int quoteInlineIndex=statusForContent.content.lastIndexOf("
RE:");
if (quoteInlineIndex!=-1)
statusForContent.content=statusForContent.content.substring(0, quoteInlineIndex);
}
From 7c8c6d6958946342373d0ebf79ba27f574e8291e Mon Sep 17 00:00:00 2001
From: sk
Date: Sun, 12 Nov 2023 23:06:35 +0100
Subject: [PATCH 4/7] fix null reference (reply-to instead of quote status)
---
.../org/joinmastodon/android/fragments/ComposeFragment.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java
index 264fb37ff3..7ac7cbc128 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java
@@ -736,7 +736,7 @@ public void getOutline(View view, Outline outline){
String prefix = (GlobalUserPreferences.prefixReplies == ALWAYS
|| (GlobalUserPreferences.prefixReplies == TO_OTHERS && !ownID.equals(status.account.id)))
&& !status.spoilerText.startsWith("re: ") ? "re: " : "";
- spoilerEdit.setText(prefix + replyTo.spoilerText);
+ spoilerEdit.setText(prefix + status.spoilerText);
spoilerBtn.setSelected(true);
}
if (status.language != null && !status.language.isEmpty()) setPostLanguage(status.language);
From 2c57773c8f8a01d06ecde4a3ea0a0e4ec0f7d984 Mon Sep 17 00:00:00 2001
From: sk
Date: Sun, 12 Nov 2023 23:43:00 +0100
Subject: [PATCH 5/7] fix text bottom padding in quote
---
.../android/ui/displayitems/TextStatusDisplayItem.java | 4 ++--
1 file changed, 2 insertions(+), 2 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 7e5135e125..9235e6d99b 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
@@ -123,8 +123,8 @@ public void onBind(TextStatusDisplayItem item){
StatusDisplayItem next=getNextVisibleDisplayItem().orElse(null);
if(next!=null && !next.parentID.equals(item.parentID)) next=null;
- int bottomPadding=next instanceof FooterStatusDisplayItem ? V.dp(6)
- : item.inset ? V.dp(12)
+ int bottomPadding=item.inset ? V.dp(12)
+ : next instanceof FooterStatusDisplayItem ? V.dp(6)
: (next instanceof EmojiReactionsStatusDisplayItem || next==null) ? 0
: V.dp(12);
itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), bottomPadding);
From c741f8e76faf87a6aadb5b98eca1fd3eb6ddb9e4 Mon Sep 17 00:00:00 2001
From: Jacoco <63549689+Jacocococo@users.noreply.github.com>
Date: Mon, 13 Nov 2023 11:30:00 +0100
Subject: [PATCH 6/7] Postprocess status quote
---
.../src/main/java/org/joinmastodon/android/model/Status.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java
index 605c10f221..6498cb0f74 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java
@@ -124,6 +124,8 @@ public void postprocess() throws ObjectValidationException{
if(filtered!=null)
for(FilterResult fr:filtered)
fr.postprocess();
+ if(quote!=null)
+ quote.postprocess();
spoilerRevealed=!hasSpoiler();
if(!spoilerRevealed) sensitive=true;
From f7967d2cf5b8a5296b47531ba34c4868df308455 Mon Sep 17 00:00:00 2001
From: sk
Date: Mon, 13 Nov 2023 18:43:18 +0100
Subject: [PATCH 7/7] fix rounded bottom for quoted media
closes sk22#929
---
.../joinmastodon/android/ui/displayitems/StatusDisplayItem.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
index 1eb28df74b..b71c585d8d 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
@@ -454,7 +454,7 @@ public Optional getDisplayItemOffset(int offset){
public boolean isLastDisplayItemForStatus(){
return getNextVisibleDisplayItem()
- .map(n->!n.parentID.equals(item.parentID))
+ .map(next->!next.parentID.equals(item.parentID) || item.inset && !next.inset)
.orElse(true);
}