Merge remote-tracking branch 'refs/remotes/Jacocococo/quote-display-fixes'

# Conflicts:
#	mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java
This commit is contained in:
LucasGGamerM 2024-07-04 20:22:10 -03:00
commit 38df70cd9e
4 changed files with 22 additions and 8 deletions

View File

@ -777,6 +777,8 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
displayItems.addAll(index+1, spoilerItem.contentItems); displayItems.addAll(index+1, spoilerItem.contentItems);
adapter.notifyItemRangeInserted(index+1, spoilerItem.contentItems.size()); adapter.notifyItemRangeInserted(index+1, spoilerItem.contentItems.size());
}else{ }else{
if(spoilers.size()>1 && !isForQuote && status.quote.spoilerRevealed)
toggleSpoiler(status.quote, true, itemID);
displayItems.subList(index+1, index+1+spoilerItem.contentItems.size()).clear(); displayItems.subList(index+1, index+1+spoilerItem.contentItems.size()).clear();
adapter.notifyItemRangeRemoved(index+1, spoilerItem.contentItems.size()); adapter.notifyItemRangeRemoved(index+1, spoilerItem.contentItems.size());
} }
@ -789,19 +791,23 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
list.invalidateItemDecorations(); list.invalidateItemDecorations();
} }
public void onEnableExpandable(TextStatusDisplayItem.Holder holder, boolean expandable) { public void onEnableExpandable(TextStatusDisplayItem.Holder holder, boolean expandable, boolean isForQuote) {
Status s=holder.getItem().status; Status s=holder.getItem().status;
if(s.textExpandable!=expandable && list!=null) { if(s.textExpandable!=expandable && list!=null) {
s.textExpandable=expandable; s.textExpandable=expandable;
HeaderStatusDisplayItem.Holder header=findHolderOfType(holder.getItemID(), HeaderStatusDisplayItem.Holder.class); List<HeaderStatusDisplayItem.Holder> headers=findAllHoldersOfType(holder.getItemID(), HeaderStatusDisplayItem.Holder.class);
HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0);
if(header!=null) header.bindCollapseButton(); if(header!=null) header.bindCollapseButton();
} }
} }
public void onToggleExpanded(Status status, String itemID) { public void onToggleExpanded(Status status, boolean isForQuote, String itemID) {
status.textExpanded = !status.textExpanded; status.textExpanded = !status.textExpanded;
notifyItemChanged(itemID, TextStatusDisplayItem.class); List<TextStatusDisplayItem.Holder> textItems = findAllHoldersOfType(itemID, TextStatusDisplayItem.Holder.class);
HeaderStatusDisplayItem.Holder header=findHolderOfType(itemID, HeaderStatusDisplayItem.Holder.class); TextStatusDisplayItem.Holder text = textItems.size() > 1 && isForQuote ? textItems.get(1) : textItems.get(0);
adapter.notifyItemChanged(text.getAbsoluteAdapterPosition());
List<HeaderStatusDisplayItem.Holder> headers=findAllHoldersOfType(itemID, HeaderStatusDisplayItem.Holder.class);
HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0);
if(header!=null) header.animateExpandToggle(); if(header!=null) header.animateExpandToggle();
else notifyItemChanged(itemID, HeaderStatusDisplayItem.class); else notifyItemChanged(itemID, HeaderStatusDisplayItem.class);
} }

View File

@ -228,6 +228,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
s.spoilerRevealed = oldStatus.spoilerRevealed; s.spoilerRevealed = oldStatus.spoilerRevealed;
s.sensitiveRevealed = oldStatus.sensitiveRevealed; s.sensitiveRevealed = oldStatus.sensitiveRevealed;
s.filterRevealed = oldStatus.filterRevealed; s.filterRevealed = oldStatus.filterRevealed;
s.textExpanded = oldStatus.textExpanded;
} }
if (GlobalUserPreferences.autoRevealEqualSpoilers != AutoRevealMode.NEVER && if (GlobalUserPreferences.autoRevealEqualSpoilers != AutoRevealMode.NEVER &&
s.spoilerText != null){ s.spoilerText != null){
@ -307,6 +308,13 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
updatedStatus.filterRevealed = mainStatus.filterRevealed; updatedStatus.filterRevealed = mainStatus.filterRevealed;
updatedStatus.spoilerRevealed = mainStatus.spoilerRevealed; updatedStatus.spoilerRevealed = mainStatus.spoilerRevealed;
updatedStatus.sensitiveRevealed = mainStatus.sensitiveRevealed; updatedStatus.sensitiveRevealed = mainStatus.sensitiveRevealed;
updatedStatus.textExpanded = mainStatus.textExpanded;
if(updatedStatus.quote!=null && mainStatus.quote!=null){
updatedStatus.quote.filterRevealed = mainStatus.quote.filterRevealed;
updatedStatus.quote.spoilerRevealed = mainStatus.quote.spoilerRevealed;
updatedStatus.quote.sensitiveRevealed = mainStatus.quote.sensitiveRevealed;
updatedStatus.quote.textExpanded = mainStatus.quote.textExpanded;
}
// returning fired event object to facilitate testing // returning fired event object to facilitate testing
Object event; Object event;

View File

@ -175,7 +175,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
fragment.removeNotification(item.notification); fragment.removeNotification(item.notification);
} }
})); }));
collapseBtn.setOnClickListener(l -> item.parentFragment.onToggleExpanded(item.status, getItemID())); collapseBtn.setOnClickListener(l -> item.parentFragment.onToggleExpanded(item.status, item.isForQuote, getItemID()));
optionsMenu=new PopupMenu(activity, more); optionsMenu=new PopupMenu(activity, more);
optionsMenu.inflate(R.menu.post); optionsMenu.inflate(R.menu.post);

View File

@ -101,7 +101,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
float textCollapsedHeight=activity.getResources().getDimension(R.dimen.text_collapsed_height); float textCollapsedHeight=activity.getResources().getDimension(R.dimen.text_collapsed_height);
collapseParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) textCollapsedHeight); collapseParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) textCollapsedHeight);
wrapParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); wrapParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
readMore.setOnClickListener(v -> item.parentFragment.onToggleExpanded(item.status, getItemID())); readMore.setOnClickListener(v -> item.parentFragment.onToggleExpanded(item.status, item.isForQuote, getItemID()));
} }
@Override @Override
@ -155,7 +155,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
if (GlobalUserPreferences.collapseLongPosts && !item.status.textExpandable) { if (GlobalUserPreferences.collapseLongPosts && !item.status.textExpandable) {
boolean tooBig = text.getMeasuredHeight() > textMaxHeight; boolean tooBig = text.getMeasuredHeight() > textMaxHeight;
boolean expandable = tooBig && !item.status.hasSpoiler(); boolean expandable = tooBig && !item.status.hasSpoiler();
item.parentFragment.onEnableExpandable(Holder.this, expandable); item.parentFragment.onEnableExpandable(Holder.this, expandable, item.isForQuote);
} }
boolean expandButtonShown=item.status.textExpandable && !item.status.textExpanded; boolean expandButtonShown=item.status.textExpandable && !item.status.textExpanded;