Skip to content

Commit

Permalink
Fixed issue where edited posts weren't marked (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Mar 5, 2021
1 parent ed38afe commit 939b5a6
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
3 changes: 3 additions & 0 deletions assets/changelog-alpha.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/Alpha 271 (2021-03-05)
Fixed issue where edited posts weren't marked

/Alpha 270 (2021-02-26)
Added more options for post and comment fling actions (thanks to Cameron Merkel)
Fixed issue where tapping a loading image would close it (thanks to Cameron Merkel)
Expand Down
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Workaround for third party share apps
Added accessibility preference for minimum comment height (thanks to Cameron Merkel)
Added more options for post and comment fling actions (thanks to Cameron Merkel)
Fixed issue where tapping a loading image would close it (thanks to Cameron Merkel)
Fixed issue where edited posts weren't marked

96/1.16
Fixed error message when marking all inbox messages as read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.quantumbadger.redreader.R;
import org.quantumbadger.redreader.activities.BaseActivity;
import org.quantumbadger.redreader.common.RRTime;
import org.quantumbadger.redreader.jsonwrap.JsonLong;
import org.quantumbadger.redreader.reddit.things.RedditComment;

public final class CommentPropertiesDialog extends PropertiesDialog {
Expand Down Expand Up @@ -70,11 +71,11 @@ protected void prepare(
RRTime.formatDateTime(comment.created_utc * 1000, context),
false));

if(comment.edited instanceof Long) {
if(comment.edited instanceof JsonLong) {
items.addView(propView(
context,
R.string.props_edited,
RRTime.formatDateTime((Long)comment.edited * 1000, context),
RRTime.formatDateTime(comment.edited.asLong() * 1000, context),
false));
} else {
items.addView(propView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.quantumbadger.redreader.R;
import org.quantumbadger.redreader.activities.BaseActivity;
import org.quantumbadger.redreader.common.RRTime;
import org.quantumbadger.redreader.jsonwrap.JsonLong;
import org.quantumbadger.redreader.reddit.things.RedditPost;

public final class PostPropertiesDialog extends PropertiesDialog {
Expand Down Expand Up @@ -69,11 +70,11 @@ protected void prepare(
RRTime.formatDateTime(post.created_utc * 1000, context),
false));

if(post.edited instanceof Long) {
if(post.edited instanceof JsonLong) {
items.addView(propView(
context,
R.string.props_edited,
RRTime.formatDateTime((Long)post.edited * 1000, context),
RRTime.formatDateTime(post.edited.asLong() * 1000, context),
false));
} else {
items.addView(propView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class JsonLong extends JsonValue {

private final long mValue;

protected JsonLong(final long value) {
public JsonLong(final long value) {
mValue = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public CharSequence getHeader(
0,
1f);

if(rawComment.edited instanceof Long) {
if(rawComment.wasEdited()) {
sb.append(
"*",
BetterSSB.FOREGROUND_COLOR | BetterSSB.BOLD,
Expand Down Expand Up @@ -366,7 +366,7 @@ public String getAccessibilityHeader(
formattedAge))
.append(separator);

if(rawComment.edited instanceof Long) {
if(rawComment.wasEdited()) {
accessibilityHeader
.append(context.getString(
R.string.accessibility_subtitle_edited_since_being_posted))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import androidx.annotation.Nullable;
import org.apache.commons.text.StringEscapeUtils;
import org.quantumbadger.redreader.common.LinkHandler;
import org.quantumbadger.redreader.jsonwrap.JsonBoolean;
import org.quantumbadger.redreader.jsonwrap.JsonLong;
import org.quantumbadger.redreader.jsonwrap.JsonValue;
import org.quantumbadger.redreader.reddit.url.PostCommentListingURL;

Expand All @@ -42,13 +44,13 @@ public final class RedditComment implements Parcelable, RedditThingWithIdAndType
public int ups, downs;
public int gilded;

public Object edited;
@Nullable public JsonValue edited;

public long created, created_utc;

public Boolean saved;
@Nullable public Boolean saved;

public String distinguished;
@Nullable public String distinguished;

public RedditComment() {
}
Expand Down Expand Up @@ -90,9 +92,9 @@ private RedditComment(final Parcel in) {

final long in_edited = in.readLong();
if(in_edited == -1) {
edited = false;
edited = JsonBoolean.FALSE;
} else {
edited = in_edited;
edited = new JsonLong(in_edited);
}

created = in.readLong();
Expand Down Expand Up @@ -130,8 +132,8 @@ public void writeToParcel(final Parcel parcel, final int flags) {
parcel.writeInt(ups);
parcel.writeInt(downs);

if(edited instanceof Long) {
parcel.writeLong((Long)edited);
if(edited instanceof JsonLong) {
parcel.writeLong(edited.asLong());
} else {
parcel.writeLong(-1);
}
Expand Down Expand Up @@ -208,4 +210,8 @@ public RedditComment[] newArray(final int size) {
public HashSet<String> computeAllLinks() {
return LinkHandler.computeAllLinks(StringEscapeUtils.unescapeHtml4(body_html));
}

public boolean wasEdited() {
return edited != null && !Boolean.FALSE.equals(edited.asBoolean());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import org.quantumbadger.redreader.jsonwrap.JsonBoolean;
import org.quantumbadger.redreader.jsonwrap.JsonLong;
import org.quantumbadger.redreader.jsonwrap.JsonObject;
import org.quantumbadger.redreader.jsonwrap.JsonValue;

public final class RedditPost implements Parcelable, RedditThingWithIdAndType {

Expand All @@ -30,7 +33,7 @@ public final class RedditPost implements Parcelable, RedditThingWithIdAndType {
public String title, author, domain, subreddit, subreddit_id;
public int num_comments, score, ups, downs, gilded;
public boolean archived, over_18, hidden, saved, is_self, clicked, stickied;
public Object edited;
public JsonValue edited;
public Boolean likes;
public Boolean spoiler;

Expand Down Expand Up @@ -112,9 +115,9 @@ private RedditPost(final Parcel in) {

final long in_edited = in.readLong();
if(in_edited == -1) {
edited = false;
edited = JsonBoolean.FALSE;
} else {
edited = in_edited;
edited = new JsonLong(in_edited);
}

switch(in.readInt()) {
Expand Down Expand Up @@ -182,8 +185,8 @@ public void writeToParcel(final Parcel parcel, final int flags) {
parcel.writeInt(clicked ? 1 : 0);
parcel.writeInt(stickied ? 1 : 0);

if(edited instanceof Long) {
parcel.writeLong((Long)edited);
if(edited instanceof JsonLong) {
parcel.writeLong(edited.asLong());
} else {
parcel.writeLong(-1);
}
Expand Down Expand Up @@ -235,4 +238,8 @@ public String getIdAlone() {
public String getIdAndType() {
return name;
}

public boolean wasEdited() {
return edited != null && !Boolean.FALSE.equals(edited.asBoolean());
}
}

0 comments on commit 939b5a6

Please sign in to comment.