Fix hiding/showing preview cards for sensitive statuses (#2600)

* Update comment on StatusViewData.isCollapsible

* Fix hiding/showing preview cards for sensitive statuses.
Fixes #2565

* Fix typo
This commit is contained in:
Levi Bard 2022-06-24 21:47:49 +02:00 committed by GitHub
parent 3ca8a0b549
commit 8551785389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 11 deletions

View File

@ -1046,6 +1046,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
actionable.getPoll() == null &&
card != null &&
!TextUtils.isEmpty(card.getUrl()) &&
(!actionable.getSensitive() || status.isExpanded()) &&
(!status.isCollapsible() || !status.isCollapsed())) {
cardView.setVisibility(View.VISIBLE);
cardTitle.setText(card.getTitle());

View File

@ -103,20 +103,26 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
@NonNull final StatusActionListener listener,
@NonNull StatusDisplayOptions statusDisplayOptions,
@Nullable Object payloads) {
super.setupWithStatus(status, listener, statusDisplayOptions, payloads);
setupCard(status, CardViewMode.FULL_WIDTH, statusDisplayOptions, listener); // Always show card for detailed status
// We never collapse statuses in the detail view
StatusViewData.Concrete uncollapsedStatus = (status.isCollapsible() && status.isCollapsed()) ?
status.copyWithCollapsed(false) :
status;
super.setupWithStatus(uncollapsedStatus, listener, statusDisplayOptions, payloads);
setupCard(uncollapsedStatus, CardViewMode.FULL_WIDTH, statusDisplayOptions, listener); // Always show card for detailed status
if (payloads == null) {
Status actionable = uncollapsedStatus.getActionable();
if (!statusDisplayOptions.hideStats()) {
setReblogAndFavCount(status.getActionable().getReblogsCount(),
status.getActionable().getFavouritesCount(), listener);
setReblogAndFavCount(actionable.getReblogsCount(),
actionable.getFavouritesCount(), listener);
} else {
hideQuantitativeStats();
}
setApplication(status.getActionable().getApplication());
setApplication(actionable.getApplication());
setStatusVisibility(status.getActionable().getVisibility());
setStatusVisibility(actionable.getVisibility());
}
}

View File

@ -538,7 +538,7 @@ public class NotificationsFragment extends SFragment implements
@Override
public void onContentCollapsedChange(boolean isCollapsed, int position) {
updateViewDataAt(position, (vd) -> vd.copyWIthCollapsed(isCollapsed));
updateViewDataAt(position, (vd) -> vd.copyWithCollapsed(isCollapsed));
;
}

View File

@ -387,7 +387,7 @@ public final class ViewThreadFragment extends SFragment implements
public void onContentCollapsedChange(boolean isCollapsed, int position) {
adapter.setItem(
position,
statuses.getPairedItem(position).copyWIthCollapsed(isCollapsed),
statuses.getPairedItem(position).copyWithCollapsed(isCollapsed),
true
);
}

View File

@ -47,8 +47,8 @@ sealed class StatusViewData {
get() = status.id
/**
* Specifies whether the content of this post is allowed to be collapsed or if it should show
* all content regardless.
* Specifies whether the content of this post is long enough to be automatically
* collapsed or if it should show all content regardless.
*
* @return Whether the post is collapsible or never collapsed.
*/
@ -106,7 +106,7 @@ sealed class StatusViewData {
}
/** Helper for Java */
fun copyWIthCollapsed(isCollapsed: Boolean): Concrete {
fun copyWithCollapsed(isCollapsed: Boolean): Concrete {
return copy(isCollapsed = isCollapsed)
}
}