diff options
Diffstat (limited to 'app/src/main/java/ml')
6 files changed, 37 insertions, 11 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index 8a2dfb89..a6e130b8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -36,9 +36,9 @@ public class LinkResolverActivity extends AppCompatActivity { private static final String POST_PATTERN = "/r/\\w+/comments/\\w+/{0,1}\\w+/{0,1}"; private static final String COMMENT_PATTERN = "/r/\\w+/comments/\\w+/{0,1}\\w+/\\w+/{0,1}"; - private static final String SUBREDDIT_PATTERN = "/r/\\w+/{0,1}"; + private static final String SUBREDDIT_PATTERN = "/[rR]/\\w+/{0,1}"; private static final String USER_PATTERN_1 = "/user/\\w+/{0,1}"; - private static final String USER_PATTERN_2 = "/u/\\w+/{0,1}"; + private static final String USER_PATTERN_2 = "/[uU]/\\w+/{0,1}"; @Inject SharedPreferences mSharedPreferences; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 97c7fb98..12f06260 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -582,6 +582,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy String authorPrefixed = "u/" + comment.getAuthor(); ((CommentViewHolder) holder).authorTextView.setText(authorPrefixed); + if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) { + ((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE); + ((CommentViewHolder) holder).authorFlairTextView.setText(comment.getAuthorFlair()); + } + if (comment.isSubmitter()) { ((CommentViewHolder) holder).authorTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.submitter)); ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE); @@ -1374,6 +1379,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy ((CommentViewHolder) holder).authorTextView.setTextColor( ContextCompat.getColor(mActivity, R.color.colorPrimaryDarkDayNightTheme)); mGlide.clear(((CommentViewHolder) holder).authorTypeImageView); + ((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE); ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.GONE); ((CommentViewHolder) holder).moreButton.setVisibility(View.GONE); ((CommentViewHolder) holder).expandButton.setVisibility(View.GONE); @@ -1691,6 +1697,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy class CommentViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.author_text_view_item_post_comment) TextView authorTextView; + @BindView(R.id.author_flair_text_view_item_post_comment) + TextView authorFlairTextView; @BindView(R.id.author_type_image_view_item_comment) ImageView authorTypeImageView; @BindView(R.id.comment_time_text_view_item_post_comment) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index e221d03e..52da24a3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -11,7 +11,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; @@ -247,7 +246,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((DataViewHolder) holder).nameTextView.setTextColor(mContext.getResources().getColor(R.color.colorAccent)); ((DataViewHolder) holder).nameTextView.setText(subredditNamePrefixed); - ((DataViewHolder) holder).iconNameLinearLayout.setOnClickListener(view -> { + ((DataViewHolder) holder).nameTextView.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; if (post.getSubredditNamePrefixed().startsWith("u/")) { @@ -263,6 +262,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } } }); + + ((DataViewHolder) holder).iconGifImageView.setOnClickListener(view -> + ((DataViewHolder) holder).nameTextView.performClick()); } else { if (post.getAuthorIconUrl() == null) { String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor(); @@ -300,7 +302,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((DataViewHolder) holder).nameTextView.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme)); ((DataViewHolder) holder).nameTextView.setText(authorPrefixed); - ((DataViewHolder) holder).iconNameLinearLayout.setOnClickListener(view -> { + ((DataViewHolder) holder).nameTextView.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; Intent intent = new Intent(mContext, ViewUserDetailActivity.class); @@ -308,6 +310,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mContext.startActivity(intent); } }); + + ((DataViewHolder) holder).iconGifImageView.setOnClickListener(view -> + ((DataViewHolder) holder).nameTextView.performClick()); } ((DataViewHolder) holder).postTimeTextView.setText(postTime); @@ -807,8 +812,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView class DataViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.card_view_item_post) MaterialCardView cardView; - @BindView(R.id.icon_name_linear_layout_view_item_post) - LinearLayout iconNameLinearLayout; @BindView(R.id.icon_gif_image_view_item_post) AspectRatioGifImageView iconGifImageView; @BindView(R.id.name_text_view_item_post) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java index 285c7a8e..af24ae8e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java @@ -23,6 +23,7 @@ public class CommentData implements Parcelable { private String id; private String fullName; private String author; + private String authorFlair; private String linkAuthor; private String commentTime; private String commentContent; @@ -47,13 +48,14 @@ public class CommentData implements Parcelable { private boolean isLoadingMoreChildren; private boolean loadMoreChildrenFailed; - public CommentData(String id, String fullName, String author, String linkAuthor, String commentTime, + public CommentData(String id, String fullName, String author, String authorFlair, String linkAuthor, String commentTime, String commentContent, String linkId, String subredditName, String parentId, int score, int voteType, boolean isSubmitter, String distinguished, String permalink, int depth, boolean collapsed, boolean hasReply, boolean scoreHidden, boolean saved) { this.id = id; this.fullName = fullName; this.author = author; + this.authorFlair = authorFlair; this.linkAuthor = linkAuthor; this.commentTime = commentTime; this.commentContent = commentContent; @@ -87,6 +89,7 @@ public class CommentData implements Parcelable { id = in.readString(); fullName = in.readString(); author = in.readString(); + authorFlair = in.readString(); linkAuthor = in.readString(); commentTime = in.readString(); commentContent = in.readString(); @@ -127,6 +130,10 @@ public class CommentData implements Parcelable { this.author = author; } + public String getAuthorFlair() { + return authorFlair; + } + public String getLinkAuthor() { return linkAuthor; } @@ -308,6 +315,7 @@ public class CommentData implements Parcelable { parcel.writeString(id); parcel.writeString(fullName); parcel.writeString(author); + parcel.writeString(authorFlair); parcel.writeString(linkAuthor); parcel.writeString(commentTime); parcel.writeString(commentContent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java index 2c0ab119..bc966f49 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java @@ -16,6 +16,7 @@ public class JSONUtils { public static final String SELFTEXT_KEY = "selftext"; public static final String SELFTEXT_HTML_KEY = "selftext_html"; public static final String AUTHOR_KEY = "author"; + public static final String AUTHOR_FLAIR_TEXT_KEY = "author_flair_text"; public static final String LINK_AUTHOR_KEY = "link_author"; public static final String LINK_FLAIR_TEXT_KEY = "link_flair_text"; public static final String SCORE_KEY = "score"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index 54eb364b..84343132 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -112,6 +112,12 @@ public class ParseComment { String id = singleCommentData.getString(JSONUtils.ID_KEY); String fullName = singleCommentData.getString(JSONUtils.NAME_KEY); String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY); + String authorFlair; + if (!singleCommentData.has(JSONUtils.AUTHOR_FLAIR_TEXT_KEY) || singleCommentData.isNull(JSONUtils.AUTHOR_FLAIR_TEXT_KEY)) { + authorFlair = ""; + } else { + authorFlair = singleCommentData.getString(JSONUtils.AUTHOR_FLAIR_TEXT_KEY); + } String linkAuthor = singleCommentData.has(JSONUtils.LINK_AUTHOR_KEY) ? singleCommentData.getString(JSONUtils.LINK_AUTHOR_KEY) : null; String linkId = singleCommentData.getString(JSONUtils.LINK_ID_KEY).substring(3); String subredditName = singleCommentData.getString(JSONUtils.SUBREDDIT_KEY); @@ -147,9 +153,9 @@ public class ParseComment { boolean collapsed = singleCommentData.getBoolean(JSONUtils.COLLAPSED_KEY); boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String); - return new CommentData(id, fullName, author, linkAuthor, formattedSubmitTime, commentContent, - linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished, - permalink, depth, collapsed, hasReply, scoreHidden, saved); + return new CommentData(id, fullName, author, authorFlair, linkAuthor, formattedSubmitTime, + commentContent, linkId, subredditName, parentId, score, voteType, isSubmitter, + distinguished, permalink, depth, collapsed, hasReply, scoreHidden, saved); } @Nullable |