fix content warning in notifications when alwaysShowSpoiler is on (#1757)
This commit is contained in:
parent
b44ceea44c
commit
204167ea8f
|
@ -545,7 +545,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
statusContent.setVisibility(statusViewData.isExpanded() ? View.GONE : View.VISIBLE);
|
||||
});
|
||||
|
||||
setupContentAndSpoiler(notificationViewData, listener);
|
||||
setupContentAndSpoiler(listener);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -587,9 +587,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupContentAndSpoiler(NotificationViewData.Concrete notificationViewData, final LinkListener listener) {
|
||||
|
||||
boolean shouldShowContentIfSpoiler = notificationViewData.isExpanded();
|
||||
private void setupContentAndSpoiler(final LinkListener listener) {
|
||||
boolean shouldShowContentIfSpoiler = statusViewData.isExpanded();
|
||||
boolean hasSpoiler = !TextUtils.isEmpty(statusViewData.getSpoilerText());
|
||||
if (!shouldShowContentIfSpoiler && hasSpoiler) {
|
||||
statusContent.setVisibility(View.GONE);
|
||||
|
@ -599,8 +598,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
|
||||
Spanned content = statusViewData.getContent();
|
||||
List<Emoji> emojis = statusViewData.getStatusEmojis();
|
||||
|
||||
if (statusViewData.isCollapsible() && (notificationViewData.isExpanded() || !hasSpoiler)) {
|
||||
|
||||
if (statusViewData.isCollapsible() && (statusViewData.isExpanded() || !hasSpoiler)) {
|
||||
contentCollapseButton.setOnClickListener(view -> {
|
||||
int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION && notificationActionListener != null) {
|
||||
|
|
|
@ -469,8 +469,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
|
||||
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
||||
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
||||
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji());
|
||||
|
||||
viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
|
||||
notifications.setPairedItem(position, newViewData);
|
||||
updateAdapter();
|
||||
}
|
||||
|
@ -504,7 +503,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
|
||||
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
||||
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
||||
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji());
|
||||
viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
|
||||
|
||||
notifications.setPairedItem(position, newViewData);
|
||||
updateAdapter();
|
||||
|
@ -539,7 +538,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
|
||||
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
||||
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
||||
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji());
|
||||
viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
|
||||
|
||||
notifications.setPairedItem(position, newViewData);
|
||||
updateAdapter();
|
||||
|
@ -568,7 +567,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
|
||||
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
||||
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
||||
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji());
|
||||
viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
|
||||
|
||||
notifications.setPairedItem(position, newViewData);
|
||||
updateAdapter();
|
||||
|
@ -608,7 +607,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
.setIsExpanded(expanded)
|
||||
.createStatusViewData();
|
||||
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
||||
old.getId(), old.getAccount(), statusViewData, expanded, old.getEmoji());
|
||||
old.getId(), old.getAccount(), statusViewData, old.getEmoji());
|
||||
notifications.setPairedItem(position, notificationViewData);
|
||||
updateAdapter();
|
||||
}
|
||||
|
@ -622,7 +621,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
.setIsShowingSensitiveContent(isShowing)
|
||||
.createStatusViewData();
|
||||
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
||||
old.getId(), old.getAccount(), statusViewData, old.isExpanded(), old.getEmoji());
|
||||
old.getId(), old.getAccount(), statusViewData, old.getEmoji());
|
||||
notifications.setPairedItem(position, notificationViewData);
|
||||
updateAdapter();
|
||||
}
|
||||
|
@ -636,7 +635,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
.setMuted(isMuted)
|
||||
.createStatusViewData();
|
||||
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
||||
old.getId(), old.getAccount(), statusViewData, old.isExpanded(), old.getEmoji());
|
||||
old.getId(), old.getAccount(), statusViewData, old.getEmoji());
|
||||
notifications.setPairedItem(position, notificationViewData);
|
||||
updateAdapter();
|
||||
}
|
||||
|
@ -708,7 +707,6 @@ public class NotificationsFragment extends SFragment implements
|
|||
concreteNotification.getId(),
|
||||
concreteNotification.getAccount(),
|
||||
updatedStatus,
|
||||
concreteNotification.isExpanded(),
|
||||
concreteNotification.getEmoji()
|
||||
);
|
||||
notifications.setPairedItem(position, updatedNotification);
|
||||
|
|
|
@ -85,8 +85,8 @@ public final class ViewDataUtils {
|
|||
alwaysShowSensitiveData,
|
||||
alwaysOpenSpoiler
|
||||
),
|
||||
false,
|
||||
notification.getEmoji()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,18 +47,15 @@ public abstract class NotificationViewData {
|
|||
private final Account account;
|
||||
@Nullable
|
||||
private final StatusViewData.Concrete statusViewData;
|
||||
private final boolean isExpanded;
|
||||
@Nullable
|
||||
private final String emoji;
|
||||
|
||||
public Concrete(Notification.Type type, String id, Account account,
|
||||
@Nullable StatusViewData.Concrete statusViewData, boolean isExpanded,
|
||||
@Nullable StatusViewData.Concrete statusViewData,
|
||||
@Nullable String emoji) {
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.account = account;
|
||||
this.statusViewData = statusViewData;
|
||||
this.isExpanded = isExpanded;
|
||||
this.emoji = emoji;
|
||||
}
|
||||
|
||||
|
@ -79,10 +76,6 @@ public abstract class NotificationViewData {
|
|||
return statusViewData;
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return isExpanded;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getEmoji() {
|
||||
return emoji;
|
||||
|
@ -98,8 +91,7 @@ public abstract class NotificationViewData {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Concrete concrete = (Concrete) o;
|
||||
return isExpanded == concrete.isExpanded &&
|
||||
type == concrete.type &&
|
||||
return type == concrete.type &&
|
||||
Objects.equals(id, concrete.id) &&
|
||||
account.getId().equals(concrete.account.getId()) &&
|
||||
(emoji != null && concrete.emoji != null && emoji.equals(concrete.emoji)) &&
|
||||
|
@ -111,7 +103,7 @@ public abstract class NotificationViewData {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(type, id, account, statusViewData, isExpanded);
|
||||
return Objects.hash(type, id, account, statusViewData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue