aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-09-27 04:43:06 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-09-27 04:43:06 +0000
commitedf85c2bc3d0a7d983b93d888e540380529601ca (patch)
treebd9a4dd7ecb8a6d698abd4c59a51d79797547fef /app/src/main/java
parent837e461451a877c581ea38e401863a266a1781ca (diff)
downloadinfinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.tar
infinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.tar.gz
infinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.tar.bz2
infinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.tar.lz
infinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.tar.xz
infinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.tar.zst
infinity-for-reddit-edf85c2bc3d0a7d983b93d888e540380529601ca.zip
Add a mic icon if the user is the submitter in comments. Add a mod icon if the user is a moderator. Tweak the vertical bar colors in comments in dark theme.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java11
5 files changed, 50 insertions, 7 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
index efb920e4..f2fb4545 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
@@ -568,6 +568,20 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
String authorPrefixed = "u/" + comment.getAuthor();
((CommentViewHolder) holder).authorTextView.setText(authorPrefixed);
+ if(comment.isSubmitter()) {
+ ((CommentViewHolder) holder).authorTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.submitter));
+ ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE);
+ ((CommentViewHolder) holder).authorTypeImageView.
+ setColorFilter(ContextCompat.getColor(mActivity, R.color.submitter), android.graphics.PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_mic_14dp);
+ } else if(comment.isModerator()) {
+ ((CommentViewHolder) holder).authorTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.moderator));
+ ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE);
+ ((CommentViewHolder) holder).authorTypeImageView.
+ setColorFilter(ContextCompat.getColor(mActivity, R.color.moderator), android.graphics.PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_verified_user_14dp);
+ }
+
((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
mMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentContent());
@@ -1151,6 +1165,10 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof CommentViewHolder) {
+ ((CommentViewHolder) holder).authorTextView.setTextColor(
+ ContextCompat.getColor(mActivity, R.color.colorPrimaryDarkDayNightTheme));
+ mGlide.clear(((CommentViewHolder) holder).authorTypeImageView);
+ ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.GONE);
((CommentViewHolder) holder).moreButton.setVisibility(View.GONE);
((CommentViewHolder) holder).expandButton.setVisibility(View.GONE);
((CommentViewHolder) holder).upVoteButton.clearColorFilter();
@@ -1415,6 +1433,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
class CommentViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.author_text_view_item_post_comment) TextView authorTextView;
+ @BindView(R.id.author_type_image_view_item_comment) ImageView authorTypeImageView;
@BindView(R.id.comment_time_text_view_item_post_comment) TextView commentTimeTextView;
@BindView(R.id.comment_markdown_view_item_post_comment) TextView commentMarkdownView;
@BindView(R.id.up_vote_button_item_post_comment) ImageView upVoteButton;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
index b06caa15..f936aac0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
@@ -22,6 +22,7 @@ class CommentData implements Parcelable {
private int score;
private int voteType;
private boolean isSubmitter;
+ private String distinguished;
private String permalink;
private int depth;
private boolean collapsed;
@@ -37,8 +38,9 @@ class CommentData implements Parcelable {
private boolean isLoadingMoreChildren;
private boolean loadMoreChildrenFailed;
- CommentData(String id, String fullName, String author, String linkAuthor, String commentTime, String commentContent,
- String linkId, String subredditName, String parentId, int score, int voteType, boolean isSubmitter, String permalink,
+ CommentData(String id, String fullName, String author, 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;
@@ -52,6 +54,7 @@ class CommentData implements Parcelable {
this.score = score;
this.voteType = voteType;
this.isSubmitter = isSubmitter;
+ this.distinguished = distinguished;
this.permalink = RedditUtils.API_BASE_URI + permalink;
this.depth = depth;
this.collapsed = collapsed;
@@ -84,6 +87,7 @@ class CommentData implements Parcelable {
score = in.readInt();
voteType = in.readInt();
isSubmitter = in.readByte() != 0;
+ distinguished = in.readString();
permalink = in.readString();
depth = in.readInt();
collapsed = in.readByte() != 0;
@@ -170,6 +174,10 @@ class CommentData implements Parcelable {
return isSubmitter;
}
+ public boolean isModerator() {
+ return distinguished != null && distinguished.equals("moderator");
+ }
+
public String getPermalink() {
return permalink;
}
@@ -312,6 +320,7 @@ class CommentData implements Parcelable {
parcel.writeInt(score);
parcel.writeInt(voteType);
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
+ parcel.writeString(distinguished);
parcel.writeString(permalink);
parcel.writeInt(depth);
parcel.writeByte((byte) (collapsed ? 1 : 0));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 641a9b41..5e3d4c54 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -299,7 +299,14 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
getCurrentAccountAndBindView();
}
- fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()));
+ fab.setOnClickListener(view -> {
+ if(mAccessToken == null) {
+ Toast.makeText(MainActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
+ });
}
private void getCurrentAccountAndBindView() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
index e84b8e24..41082a8c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
@@ -217,6 +217,7 @@ class ParseComment {
String subredditName = singleCommentData.getString(JSONUtils.SUBREDDIT_KEY);
String parentId = singleCommentData.getString(JSONUtils.PARENT_ID_KEY);
boolean isSubmitter = singleCommentData.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
+ String distinguished = singleCommentData.getString(JSONUtils.DISTINGUISHED_KEY);
String commentContent = "";
if(!singleCommentData.isNull(JSONUtils.BODY_KEY)) {
commentContent = Utils.addSubredditAndUserLink(singleCommentData.getString(JSONUtils.BODY_KEY).trim());
@@ -247,8 +248,8 @@ class ParseComment {
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
return new CommentData(id, fullName, author, linkAuthor, formattedSubmitTime, commentContent,
- linkId, subredditName, parentId, score, voteType, isSubmitter, permalink, depth, collapsed,
- hasReply, scoreHidden, saved);
+ linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished,
+ permalink, depth, collapsed, hasReply, scoreHidden, saved);
}
@Nullable
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
index 813801d5..ba24aae8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -197,7 +197,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
}
- subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME_KEY);
+ subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME_KEY);
if(savedInstanceState == null) {
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
@@ -313,7 +313,14 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
}
});
- fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()));
+ fab.setOnClickListener(view -> {
+ if(mAccessToken == null) {
+ Toast.makeText(ViewSubredditDetailActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
+ });
}
private void getCurrentAccountAndBindView() {