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 22f6828ff..77658b1c5 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -777,6 +777,8 @@ public abstract class BaseStatusListFragment exten displayItems.addAll(index+1, spoilerItem.contentItems); adapter.notifyItemRangeInserted(index+1, spoilerItem.contentItems.size()); }else{ + if(spoilers.size()>1 && !isForQuote && status.quote.spoilerRevealed) + toggleSpoiler(status.quote, true, itemID); displayItems.subList(index+1, index+1+spoilerItem.contentItems.size()).clear(); adapter.notifyItemRangeRemoved(index+1, spoilerItem.contentItems.size()); } @@ -789,19 +791,23 @@ public abstract class BaseStatusListFragment exten 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; if(s.textExpandable!=expandable && list!=null) { s.textExpandable=expandable; - HeaderStatusDisplayItem.Holder header=findHolderOfType(holder.getItemID(), HeaderStatusDisplayItem.Holder.class); + List 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(); } } - public void onToggleExpanded(Status status, String itemID) { + public void onToggleExpanded(Status status, boolean isForQuote, String itemID) { status.textExpanded = !status.textExpanded; - notifyItemChanged(itemID, TextStatusDisplayItem.class); - HeaderStatusDisplayItem.Holder header=findHolderOfType(itemID, HeaderStatusDisplayItem.Holder.class); + List textItems = findAllHoldersOfType(itemID, TextStatusDisplayItem.Holder.class); + TextStatusDisplayItem.Holder text = textItems.size() > 1 && isForQuote ? textItems.get(1) : textItems.get(0); + adapter.notifyItemChanged(text.getAbsoluteAdapterPosition()); + List headers=findAllHoldersOfType(itemID, HeaderStatusDisplayItem.Holder.class); + HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0); if(header!=null) header.animateExpandToggle(); else notifyItemChanged(itemID, HeaderStatusDisplayItem.class); } 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 55bc9db89..4fa6ba02d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java @@ -228,6 +228,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist s.spoilerRevealed = oldStatus.spoilerRevealed; s.sensitiveRevealed = oldStatus.sensitiveRevealed; s.filterRevealed = oldStatus.filterRevealed; + s.textExpanded = oldStatus.textExpanded; } if (GlobalUserPreferences.autoRevealEqualSpoilers != AutoRevealMode.NEVER && s.spoilerText != null){ @@ -307,6 +308,13 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist updatedStatus.filterRevealed = mainStatus.filterRevealed; updatedStatus.spoilerRevealed = mainStatus.spoilerRevealed; 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 Object event; 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 7e05968ba..53a5b4be6 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 @@ -175,7 +175,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ 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.inflate(R.menu.post); 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 2550fdaa4..b846bd872 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 @@ -101,7 +101,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ float textCollapsedHeight=activity.getResources().getDimension(R.dimen.text_collapsed_height); collapseParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) textCollapsedHeight); 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 @@ -155,7 +155,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ if (GlobalUserPreferences.collapseLongPosts && !item.status.textExpandable) { boolean tooBig = text.getMeasuredHeight() > textMaxHeight; 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;