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:
parent
3ca8a0b549
commit
8551785389
5 changed files with 18 additions and 11 deletions
|
@ -1046,6 +1046,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
actionable.getPoll() == null &&
|
actionable.getPoll() == null &&
|
||||||
card != null &&
|
card != null &&
|
||||||
!TextUtils.isEmpty(card.getUrl()) &&
|
!TextUtils.isEmpty(card.getUrl()) &&
|
||||||
|
(!actionable.getSensitive() || status.isExpanded()) &&
|
||||||
(!status.isCollapsible() || !status.isCollapsed())) {
|
(!status.isCollapsible() || !status.isCollapsed())) {
|
||||||
cardView.setVisibility(View.VISIBLE);
|
cardView.setVisibility(View.VISIBLE);
|
||||||
cardTitle.setText(card.getTitle());
|
cardTitle.setText(card.getTitle());
|
||||||
|
|
|
@ -103,20 +103,26 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
|
||||||
@NonNull final StatusActionListener listener,
|
@NonNull final StatusActionListener listener,
|
||||||
@NonNull StatusDisplayOptions statusDisplayOptions,
|
@NonNull StatusDisplayOptions statusDisplayOptions,
|
||||||
@Nullable Object payloads) {
|
@Nullable Object payloads) {
|
||||||
super.setupWithStatus(status, listener, statusDisplayOptions, payloads);
|
// We never collapse statuses in the detail view
|
||||||
setupCard(status, CardViewMode.FULL_WIDTH, statusDisplayOptions, listener); // Always show card for detailed status
|
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) {
|
if (payloads == null) {
|
||||||
|
Status actionable = uncollapsedStatus.getActionable();
|
||||||
|
|
||||||
if (!statusDisplayOptions.hideStats()) {
|
if (!statusDisplayOptions.hideStats()) {
|
||||||
setReblogAndFavCount(status.getActionable().getReblogsCount(),
|
setReblogAndFavCount(actionable.getReblogsCount(),
|
||||||
status.getActionable().getFavouritesCount(), listener);
|
actionable.getFavouritesCount(), listener);
|
||||||
} else {
|
} else {
|
||||||
hideQuantitativeStats();
|
hideQuantitativeStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
setApplication(status.getActionable().getApplication());
|
setApplication(actionable.getApplication());
|
||||||
|
|
||||||
setStatusVisibility(status.getActionable().getVisibility());
|
setStatusVisibility(actionable.getVisibility());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -538,7 +538,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContentCollapsedChange(boolean isCollapsed, int position) {
|
public void onContentCollapsedChange(boolean isCollapsed, int position) {
|
||||||
updateViewDataAt(position, (vd) -> vd.copyWIthCollapsed(isCollapsed));
|
updateViewDataAt(position, (vd) -> vd.copyWithCollapsed(isCollapsed));
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ public final class ViewThreadFragment extends SFragment implements
|
||||||
public void onContentCollapsedChange(boolean isCollapsed, int position) {
|
public void onContentCollapsedChange(boolean isCollapsed, int position) {
|
||||||
adapter.setItem(
|
adapter.setItem(
|
||||||
position,
|
position,
|
||||||
statuses.getPairedItem(position).copyWIthCollapsed(isCollapsed),
|
statuses.getPairedItem(position).copyWithCollapsed(isCollapsed),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ sealed class StatusViewData {
|
||||||
get() = status.id
|
get() = status.id
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether the content of this post is allowed to be collapsed or if it should show
|
* Specifies whether the content of this post is long enough to be automatically
|
||||||
* all content regardless.
|
* collapsed or if it should show all content regardless.
|
||||||
*
|
*
|
||||||
* @return Whether the post is collapsible or never collapsed.
|
* @return Whether the post is collapsible or never collapsed.
|
||||||
*/
|
*/
|
||||||
|
@ -106,7 +106,7 @@ sealed class StatusViewData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper for Java */
|
/** Helper for Java */
|
||||||
fun copyWIthCollapsed(isCollapsed: Boolean): Concrete {
|
fun copyWithCollapsed(isCollapsed: Boolean): Concrete {
|
||||||
return copy(isCollapsed = isCollapsed)
|
return copy(isCollapsed = isCollapsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue