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.

This commit is contained in:
Alex Ning 2019-09-27 12:43:06 +08:00
parent 837e461451
commit edf85c2bc3
11 changed files with 88 additions and 15 deletions

View File

@ -159,8 +159,8 @@
<map>
<entry key="assetSourceType" value="FILE" />
<entry key="color" value="ffffff" />
<entry key="outputName" value="ic_bookmark_border_18dp" />
<entry key="sourceFile" value="$USER_HOME$/Documents/24px.svg" />
<entry key="outputName" value="ic_verified_user_14dp" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/verified_user-24px.svg" />
</map>
</option>
</PersistentState>

View File

@ -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;

View File

@ -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));

View File

@ -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() {

View File

@ -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

View File

@ -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() {

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>