fix content warning in notifications when alwaysShowSpoiler is on (#1757)

main
Konrad Pozniak 5 years ago committed by Alibek Omarov
parent bf7e9e019d
commit 8a23f3b84c
  1. 11
      app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java
  2. 16
      app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java
  3. 2
      app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java
  4. 14
      app/src/main/java/com/keylesspalace/tusky/viewdata/NotificationViewData.java

@ -545,7 +545,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
statusContent.setVisibility(statusViewData.isExpanded() ? View.GONE : View.VISIBLE); 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) { private void setupContentAndSpoiler(final LinkListener listener) {
boolean shouldShowContentIfSpoiler = statusViewData.isExpanded();
boolean shouldShowContentIfSpoiler = notificationViewData.isExpanded();
boolean hasSpoiler = !TextUtils.isEmpty(statusViewData.getSpoilerText()); boolean hasSpoiler = !TextUtils.isEmpty(statusViewData.getSpoilerText());
if (!shouldShowContentIfSpoiler && hasSpoiler) { if (!shouldShowContentIfSpoiler && hasSpoiler) {
statusContent.setVisibility(View.GONE); statusContent.setVisibility(View.GONE);
@ -599,8 +598,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
Spanned content = statusViewData.getContent(); Spanned content = statusViewData.getContent();
List<Emoji> emojis = statusViewData.getStatusEmojis(); List<Emoji> emojis = statusViewData.getStatusEmojis();
if (statusViewData.isCollapsible() && (notificationViewData.isExpanded() || !hasSpoiler)) { if (statusViewData.isCollapsible() && (statusViewData.isExpanded() || !hasSpoiler)) {
contentCollapseButton.setOnClickListener(view -> { contentCollapseButton.setOnClickListener(view -> {
int position = getAdapterPosition(); int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION && notificationActionListener != null) { if (position != RecyclerView.NO_POSITION && notificationActionListener != null) {

@ -469,8 +469,7 @@ public class NotificationsFragment extends SFragment implements
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete( NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
viewdata.getType(), viewdata.getId(), viewdata.getAccount(), viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji()); viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
notifications.setPairedItem(position, newViewData); notifications.setPairedItem(position, newViewData);
updateAdapter(); updateAdapter();
} }
@ -504,7 +503,7 @@ public class NotificationsFragment extends SFragment implements
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete( NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
viewdata.getType(), viewdata.getId(), viewdata.getAccount(), viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji()); viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
notifications.setPairedItem(position, newViewData); notifications.setPairedItem(position, newViewData);
updateAdapter(); updateAdapter();
@ -539,7 +538,7 @@ public class NotificationsFragment extends SFragment implements
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete( NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
viewdata.getType(), viewdata.getId(), viewdata.getAccount(), viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji()); viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
notifications.setPairedItem(position, newViewData); notifications.setPairedItem(position, newViewData);
updateAdapter(); updateAdapter();
@ -568,7 +567,7 @@ public class NotificationsFragment extends SFragment implements
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete( NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
viewdata.getType(), viewdata.getId(), viewdata.getAccount(), viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
viewDataBuilder.createStatusViewData(), viewdata.isExpanded(), viewdata.getEmoji()); viewDataBuilder.createStatusViewData(), viewdata.getEmoji());
notifications.setPairedItem(position, newViewData); notifications.setPairedItem(position, newViewData);
updateAdapter(); updateAdapter();
@ -608,7 +607,7 @@ public class NotificationsFragment extends SFragment implements
.setIsExpanded(expanded) .setIsExpanded(expanded)
.createStatusViewData(); .createStatusViewData();
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(), 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); notifications.setPairedItem(position, notificationViewData);
updateAdapter(); updateAdapter();
} }
@ -622,7 +621,7 @@ public class NotificationsFragment extends SFragment implements
.setIsShowingSensitiveContent(isShowing) .setIsShowingSensitiveContent(isShowing)
.createStatusViewData(); .createStatusViewData();
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(), 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); notifications.setPairedItem(position, notificationViewData);
updateAdapter(); updateAdapter();
} }
@ -636,7 +635,7 @@ public class NotificationsFragment extends SFragment implements
.setMuted(isMuted) .setMuted(isMuted)
.createStatusViewData(); .createStatusViewData();
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(), 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); notifications.setPairedItem(position, notificationViewData);
updateAdapter(); updateAdapter();
} }
@ -708,7 +707,6 @@ public class NotificationsFragment extends SFragment implements
concreteNotification.getId(), concreteNotification.getId(),
concreteNotification.getAccount(), concreteNotification.getAccount(),
updatedStatus, updatedStatus,
concreteNotification.isExpanded(),
concreteNotification.getEmoji() concreteNotification.getEmoji()
); );
notifications.setPairedItem(position, updatedNotification); notifications.setPairedItem(position, updatedNotification);

@ -85,8 +85,8 @@ public final class ViewDataUtils {
alwaysShowSensitiveData, alwaysShowSensitiveData,
alwaysOpenSpoiler alwaysOpenSpoiler
), ),
false,
notification.getEmoji() notification.getEmoji()
)
); );
} }
} }

@ -47,18 +47,15 @@ public abstract class NotificationViewData {
private final Account account; private final Account account;
@Nullable @Nullable
private final StatusViewData.Concrete statusViewData; private final StatusViewData.Concrete statusViewData;
private final boolean isExpanded;
@Nullable
private final String emoji; private final String emoji;
public Concrete(Notification.Type type, String id, Account account, public Concrete(Notification.Type type, String id, Account account,
@Nullable StatusViewData.Concrete statusViewData, boolean isExpanded, @Nullable StatusViewData.Concrete statusViewData,
@Nullable String emoji) { @Nullable String emoji) {
this.type = type; this.type = type;
this.id = id; this.id = id;
this.account = account; this.account = account;
this.statusViewData = statusViewData; this.statusViewData = statusViewData;
this.isExpanded = isExpanded;
this.emoji = emoji; this.emoji = emoji;
} }
@ -79,10 +76,6 @@ public abstract class NotificationViewData {
return statusViewData; return statusViewData;
} }
public boolean isExpanded() {
return isExpanded;
}
@Nullable @Nullable
public String getEmoji() { public String getEmoji() {
return emoji; return emoji;
@ -98,8 +91,7 @@ public abstract class NotificationViewData {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Concrete concrete = (Concrete) o; Concrete concrete = (Concrete) o;
return isExpanded == concrete.isExpanded && return type == concrete.type &&
type == concrete.type &&
Objects.equals(id, concrete.id) && Objects.equals(id, concrete.id) &&
account.getId().equals(concrete.account.getId()) && account.getId().equals(concrete.account.getId()) &&
(emoji != null && concrete.emoji != null && emoji.equals(concrete.emoji)) && (emoji != null && concrete.emoji != null && emoji.equals(concrete.emoji)) &&
@ -111,7 +103,7 @@ public abstract class NotificationViewData {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(type, id, account, statusViewData, isExpanded); return Objects.hash(type, id, account, statusViewData);
} }
} }

Loading…
Cancel
Save