diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-09-27 04:43:06 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-09-27 04:43:06 +0000 |
commit | edf85c2bc3d0a7d983b93d888e540380529601ca (patch) | |
tree | bd9a4dd7ecb8a6d698abd4c59a51d79797547fef /app/src/main | |
parent | 837e461451a877c581ea38e401863a266a1781ca (diff) | |
download | infinity-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 '')
10 files changed, 86 insertions, 13 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() { diff --git a/app/src/main/res/drawable/ic_mic_14dp.xml b/app/src/main/res/drawable/ic_mic_14dp.xml new file mode 100644 index 00000000..d4058a15 --- /dev/null +++ b/app/src/main/res/drawable/ic_mic_14dp.xml @@ -0,0 +1,4 @@ +<vector android:height="14dp" android:viewportHeight="24" + android:viewportWidth="24" android:width="14dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_verified_user_14dp.xml b/app/src/main/res/drawable/ic_verified_user_14dp.xml new file mode 100644 index 00000000..5a12bac0 --- /dev/null +++ b/app/src/main/res/drawable/ic_verified_user_14dp.xml @@ -0,0 +1,4 @@ +<vector android:height="14dp" android:viewportHeight="24" + android:viewportWidth="24" android:width="14dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,5l-9,-4zM10,17l-4,-4 1.41,-1.41L10,14.17l6.59,-6.59L18,9l-8,8z"/> +</vector> diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index 1cac0a70..dfdc3374 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -30,23 +30,33 @@ android:id="@+id/author_text_view_item_post_comment" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="16dp" android:textColor="@color/colorPrimaryDarkDayNightTheme" android:textSize="?attr/font_default" - app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toStartOf="@id/comment_time_text_view_item_post_comment" - app:layout_constraintHorizontal_bias="0" /> + app:layout_constraintTop_toTopOf="parent" /> + + <ImageView + android:id="@+id/author_type_image_view_item_comment" + android:layout_width="?attr/font_default" + android:layout_height="?attr/font_default" + android:layout_marginStart="4dp" + android:visibility="gone" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/author_text_view_item_post_comment" /> <TextView android:id="@+id/comment_time_text_view_item_post_comment" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginStart="4dp" android:textSize="?attr/font_default" - app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/author_type_image_view_item_comment" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintHorizontal_bias="1" /> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index ff7a6510..2049c23c 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -54,5 +54,13 @@ <color name="defaultTextColor">#B3FFFFFF</color> + <color name="commentVerticalBar1">#1565C0</color> + <color name="commentVerticalBar2">#C300B3</color> + <color name="commentVerticalBar3">#00B8DA</color> + <color name="commentVerticalBar4">#EDCA00</color> + <color name="commentVerticalBar5">#EE0219</color> + <color name="commentVerticalBar6">#00B925</color> + <color name="commentVerticalBar7">#EE4602</color> + <color name="greyTabBackgroundColor">#282828</color> </resources> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a3357db3..a08640f7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -71,4 +71,8 @@ <color name="commentVerticalBar7">#EE4602</color> <color name="greyTabBackgroundColor">@color/colorPrimary</color> + + <color name="submitter">#EE8A02</color> + + <color name="moderator">#00BA81</color> </resources> |