Skip to content

Commit

Permalink
Support for new post spoiler tag
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Jan 19, 2017
1 parent 5425702 commit 15becd9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
77/1.9.7
Support for new post spoiler tag
Added low-contrast night theme
Added Ultra Black theme
Added higher font scale options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public String getRawSelfText() {
return mSrc.selftext;
}

public boolean isSpoiler() {
return Boolean.TRUE.equals(mSrc.spoiler);
}

public String getUnescapedSelfText() {
return StringEscapeUtils.unescapeHtml4(mSrc.selftext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ private void rebuildSubtitle(Context context) {
pointsCol = boldCol;
}

if(src.isSpoiler()) {
postListDescSb.append(" SPOILER ", BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR,
Color.WHITE, Color.rgb(50, 50, 50), 1f);
postListDescSb.append(" ", 0);
}

if(src.isStickied()) {
postListDescSb.append(" STICKY ", BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR,
Color.WHITE, Color.rgb(0, 170, 0), 1f); // TODO color?
Expand Down Expand Up @@ -899,10 +905,6 @@ public boolean isRead() {
return mChangeDataManager.isRead(src);
}

public boolean isSticky() {
return src.isStickied();
}

public void bind(RedditPostView boundView) {
this.boundView = boundView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class RedditPost implements Parcelable, RedditThingWithIdAndType {
public boolean archived, over_18, hidden, saved, is_self, clicked, stickied;
public Object edited;
public Boolean likes;
public Boolean spoiler;

public long created, created_utc;

Expand Down Expand Up @@ -79,6 +80,18 @@ private RedditPost(final Parcel in) {
link_flair_text = in.readString();
author_flair_text = in.readString();
thumbnail = in.readString();

switch(in.readInt()) {
case -1:
spoiler = false;
break;
case 0:
spoiler = null;
break;
case 1:
spoiler = true;
break;
}
}

public int describeContents() {
Expand Down Expand Up @@ -126,6 +139,12 @@ public void writeToParcel(final Parcel parcel, final int flags) {
parcel.writeString(link_flair_text);
parcel.writeString(author_flair_text);
parcel.writeString(thumbnail);

if(spoiler == null) {
parcel.writeInt(0);
} else {
parcel.writeInt(spoiler ? 1 : -1);
}
}

public static final Parcelable.Creator<RedditPost> CREATOR = new Parcelable.Creator<RedditPost>() {
Expand Down

0 comments on commit 15becd9

Please sign in to comment.