From edf85c2bc3d0a7d983b93d888e540380529601ca Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 27 Sep 2019 12:43:06 +0800 Subject: 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. --- .../CommentAndPostRecyclerViewAdapter.java | 19 +++++++++++++++++++ .../infinityforreddit/CommentData.java | 13 +++++++++++-- .../infinityforreddit/MainActivity.java | 9 ++++++++- .../infinityforreddit/ParseComment.java | 5 +++-- .../ViewSubredditDetailActivity.java | 11 +++++++++-- app/src/main/res/drawable/ic_mic_14dp.xml | 4 ++++ .../main/res/drawable/ic_verified_user_14dp.xml | 4 ++++ app/src/main/res/layout/item_comment.xml | 22 ++++++++++++++++------ app/src/main/res/values-night/colors.xml | 8 ++++++++ app/src/main/res/values/colors.xml | 4 ++++ 10 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/drawable/ic_mic_14dp.xml create mode 100644 app/src/main/res/drawable/ic_verified_user_14dp.xml (limited to 'app/src/main') 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 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 @@ + + + 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 @@ + + + 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" /> + + + 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" /> 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 @@ #B3FFFFFF + #1565C0 + #C300B3 + #00B8DA + #EDCA00 + #EE0219 + #00B925 + #EE4602 + #282828 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 @@ #EE4602 @color/colorPrimary + + #EE8A02 + + #00BA81 -- cgit v1.2.3