diff options
author | Hermes Junior <ohermesjunior@gmail.com> | 2020-06-12 20:06:35 +0000 |
---|---|---|
committer | OHermesJunior <ohermesjunior@gmail.com> | 2020-06-16 17:29:17 +0000 |
commit | 46a8b0d276e5e232b742e45577c94929a1f226e2 (patch) | |
tree | 3c7aeed23ced88bdf084c3fe1d18d23f2f21d709 /app/src/main | |
parent | e0020e3cf21abe06ca5e6f6456451ccf7b9fd3d1 (diff) | |
download | infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.tar infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.tar.gz infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.tar.bz2 infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.tar.lz infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.tar.xz infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.tar.zst infinity-for-reddit-46a8b0d276e5e232b742e45577c94929a1f226e2.zip |
Implement "see removed" for other types of posts. Improve removed thing detection.
Diffstat (limited to '')
5 files changed, 50 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 90bae86e..81e1ba8a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -566,7 +566,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mMenu.findItem(R.id.action_view_crosspost_parent_view_post_detail_activity).setVisible(mPost.getCrosspostParentId() != null); - if ("[deleted]".equals(mPost.getAuthor()) || "[deleted]".equals(mPost.getSelfText())) { + if ("[deleted]".equals(mPost.getAuthor()) || + "[deleted]".equals(mPost.getSelfText()) || + "[removed]".equals(mPost.getSelfText()) + ) { mMenu.findItem(R.id.action_see_removed_view_post_detail_activity).setVisible(true); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java index 2fa1f3d7..de4f5778 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java @@ -134,7 +134,10 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag dismiss(); }); - if ("[removed]".equals(commentData.getCommentRawText())) { + if ("[deleted]".equals(commentData.getAuthor()) || + "[deleted]".equals(commentData.getCommentRawText()) || + "[removed]".equals(commentData.getCommentRawText()) + ) { seeRemovedTextView.setVisibility(View.VISIBLE); seeRemovedTextView.setOnClickListener(view -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java index e2db7aed..6e18e927 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java @@ -80,6 +80,7 @@ public class FetchRemovedComment { comment = parseRemovedComment(commentJSON, comment); } catch (JSONException e) { e.printStackTrace(); + comment = null; } return null; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java index 00a0f6a0..2a8076a9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java @@ -1,6 +1,8 @@ package ml.docilealligator.infinityforreddit; +import android.net.Uri; import android.os.AsyncTask; +import android.text.Html; import androidx.annotation.NonNull; @@ -43,16 +45,46 @@ public class FetchRemovedPost { if (id.equals(post.getId())) { String author = postJson.getString(JSONUtils.AUTHOR_KEY); String title = postJson.getString(JSONUtils.TITLE_KEY); - String postContent = ""; - if (!postJson.isNull(JSONUtils.SELFTEXT_KEY)) { - postContent = Utils.modifyMarkdown(postJson.getString(JSONUtils.SELFTEXT_KEY).trim()); - } + String postContent = Utils.modifyMarkdown(postJson.getString(JSONUtils.SELFTEXT_KEY).trim()); post.setAuthor(author); post.setTitle(title); post.setSelfText(postContent); post.setSelfTextPlain(""); post.setSelfTextPlainTrimmed(""); + + String url = postJson.optString(JSONUtils.URL_KEY); + + if (url.endsWith("gif") || url.endsWith("mp4")) { + post.setVideoUrl(url); + post.setVideoDownloadUrl(url); + } else if (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE) { + JSONObject redditVideoObject = postJson.getJSONObject("secure_media").getJSONObject(JSONUtils.REDDIT_VIDEO_KEY); + String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString(); + String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY); + + post.setVideoUrl(videoUrl); + post.setVideoDownloadUrl(videoDownloadUrl); + } else if (post.getPostType() == Post.LINK_TYPE) { + post.setUrl(url); + } + + if (post.getPostType() == Post.VIDEO_TYPE) { + try { + Uri uri = Uri.parse(url); + String authority = uri.getAuthority(); + if (authority != null && (authority.contains("gfycat.com") || authority.contains("redgifs.com"))) { + post.setPostType(Post.LINK_TYPE); + post.setUrl(url); + } + } catch (IllegalArgumentException ignore) { + } + } + + if (!postJson.isNull("thumbnail")) { + post.setThumbnailPreviewUrl(postJson.getString("thumbnail")); + } + return post; } else { return null; @@ -84,6 +116,7 @@ public class FetchRemovedPost { post = parseRemovedPost(postJson, post); } catch (JSONException e) { e.printStackTrace(); + post = null; } return null; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java index 54e7ec7f..5a60bbdd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java @@ -325,6 +325,10 @@ public class Post implements Parcelable { return thumbnailPreviewUrl; } + public void setThumbnailPreviewUrl(String thumbnailPreviewUrl) { + this.thumbnailPreviewUrl = thumbnailPreviewUrl; + } + public String getUrl() { return url; } |