Apply spoiler setting before creating PostImage.

Fixes the disable spoiler setting not doing anything.
Make it so that the info tab still shows that the image is spoilered,
and that the image viewer correctly handles it.

Closes #300
multisite^2
Floens 8 years ago
parent 17d83bdb9e
commit e9121bbc83
  1. 9
      Clover/app/src/main/java/org/floens/chan/core/model/Post.java

@ -165,7 +165,8 @@ public class Post {
imageUrl = ChanUrls.getImageUrl(board, Long.toString(tim), ext); imageUrl = ChanUrls.getImageUrl(board, Long.toString(tim), ext);
filename = Parser.unescapeEntities(filename, false); filename = Parser.unescapeEntities(filename, false);
if (spoiler) { boolean spoilerImage = spoiler && !ChanSettings.revealImageSpoilers.get();
if (spoilerImage) {
Board b = Chan.getBoardManager().getBoardByCode(board); Board b = Chan.getBoardManager().getBoardByCode(board);
if (b != null && b.customSpoilers >= 0) { if (b != null && b.customSpoilers >= 0) {
thumbnailUrl = ChanUrls.getCustomSpoilerUrl(board, random.nextInt(b.customSpoilers) + 1); thumbnailUrl = ChanUrls.getCustomSpoilerUrl(board, random.nextInt(b.customSpoilers) + 1);
@ -176,17 +177,13 @@ public class Post {
thumbnailUrl = ChanUrls.getThumbnailUrl(board, Long.toString(tim)); thumbnailUrl = ChanUrls.getThumbnailUrl(board, Long.toString(tim));
} }
image = new PostImage(String.valueOf(tim), thumbnailUrl, imageUrl, filename, ext, imageWidth, imageHeight, spoiler, fileSize); image = new PostImage(String.valueOf(tim), thumbnailUrl, imageUrl, filename, ext, imageWidth, imageHeight, spoilerImage, fileSize);
} }
if (!TextUtils.isEmpty(country)) { if (!TextUtils.isEmpty(country)) {
countryUrl = ChanUrls.getCountryFlagUrl(country); countryUrl = ChanUrls.getCountryFlagUrl(country);
} }
if (ChanSettings.revealImageSpoilers.get()) {
spoiler = false;
}
ChanParser.getInstance().parse(this); ChanParser.getInstance().parse(this);
repliesTo = Collections.unmodifiableSet(repliesTo); repliesTo = Collections.unmodifiableSet(repliesTo);

Loading…
Cancel
Save