Display an archived icon if the post is archived. Display a locked icon if the post is locked.

This commit is contained in:
Alex Ning 2019-08-26 17:06:50 +08:00
parent 1da0e08552
commit b29bbf4321
8 changed files with 189 additions and 32 deletions

View File

@ -35,9 +35,8 @@
<map> <map>
<entry key="assetSourceType" value="FILE" /> <entry key="assetSourceType" value="FILE" />
<entry key="color" value="ffffff" /> <entry key="color" value="ffffff" />
<entry key="outputName" value="ic_baseline_bookmark_24px" /> <entry key="outputName" value="ic_archive_outline_24dp" />
<entry key="overrideSize" value="true" /> <entry key="sourceFile" value="$USER_HOME$/Downloads/24px.svg" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/baseline-bookmark-24px.svg" />
</map> </map>
</option> </option>
</PersistentState> </PersistentState>

View File

@ -331,6 +331,14 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
((PostDetailViewHolder) holder).mGildedNumberTextView.setText(gildedNumber); ((PostDetailViewHolder) holder).mGildedNumberTextView.setText(gildedNumber);
} }
if(mPost.isArchived()) {
((PostDetailViewHolder) holder).mArchivedImageView.setVisibility(View.VISIBLE);
}
if(mPost.isLocked()) {
((PostDetailViewHolder) holder).mLockedImageView.setVisibility(View.VISIBLE);
}
if(mPost.isSpoiler() || mPost.getFlair() != null) { if(mPost.isSpoiler() || mPost.getFlair() != null) {
((PostDetailViewHolder) holder).spoilerFlairlinearLayout.setVisibility(View.VISIBLE); ((PostDetailViewHolder) holder).spoilerFlairlinearLayout.setVisibility(View.VISIBLE);
} }
@ -555,6 +563,12 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
android.graphics.PorterDuff.Mode.SRC_IN); android.graphics.PorterDuff.Mode.SRC_IN);
} }
if(mPost.isLocked()) {
((CommentViewHolder) holder).replyButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.voteAndReplyUnavailableVoteButtonColor),
android.graphics.PorterDuff.Mode.SRC_IN);
}
((CommentViewHolder) holder).replyButton.setOnClickListener(view -> { ((CommentViewHolder) holder).replyButton.setOnClickListener(view -> {
if(mAccessToken == null) { if(mAccessToken == null) {
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
@ -989,6 +1003,8 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
@BindView(R.id.gilded_image_view_item_post_detail) ImageView mGildedImageView; @BindView(R.id.gilded_image_view_item_post_detail) ImageView mGildedImageView;
@BindView(R.id.gilded_number_text_view_item_post_detail) TextView mGildedNumberTextView; @BindView(R.id.gilded_number_text_view_item_post_detail) TextView mGildedNumberTextView;
@BindView(R.id.crosspost_image_view_item_post_detail) ImageView mCrosspostImageView; @BindView(R.id.crosspost_image_view_item_post_detail) ImageView mCrosspostImageView;
@BindView(R.id.archived_image_view_item_post_detail) ImageView mArchivedImageView;
@BindView(R.id.locked_image_view_item_post_detail) ImageView mLockedImageView;
@BindView(R.id.nsfw_text_view_item_post_detail) Chip mNSFWChip; @BindView(R.id.nsfw_text_view_item_post_detail) Chip mNSFWChip;
@BindView(R.id.spoiler_flair_linear_layout_item_post_detail) LinearLayout spoilerFlairlinearLayout; @BindView(R.id.spoiler_flair_linear_layout_item_post_detail) LinearLayout spoilerFlairlinearLayout;
@BindView(R.id.spoiler_custom_text_view_item_post_detail) CustomTextView spoilerTextView; @BindView(R.id.spoiler_custom_text_view_item_post_detail) CustomTextView spoilerTextView;

View File

@ -305,6 +305,10 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
((DataViewHolder) holder).gildedNumberTextView.setText(gildedNumber); ((DataViewHolder) holder).gildedNumberTextView.setText(gildedNumber);
} }
if(post.isLocked()) {
((DataViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
}
if(nsfw) { if(nsfw) {
((DataViewHolder) holder).nsfwChip.setVisibility(View.VISIBLE); ((DataViewHolder) holder).nsfwChip.setVisibility(View.VISIBLE);
} }
@ -350,6 +354,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
} }
if(isArchived) { if(isArchived) {
((DataViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE);
((DataViewHolder) holder).upvoteButton ((DataViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mContext, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).downvoteButton ((DataViewHolder) holder).downvoteButton
@ -691,6 +697,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
@BindView(R.id.type_text_view_item_post) Chip typeChip; @BindView(R.id.type_text_view_item_post) Chip typeChip;
@BindView(R.id.gilded_image_view_item_post) ImageView gildedImageView; @BindView(R.id.gilded_image_view_item_post) ImageView gildedImageView;
@BindView(R.id.gilded_number_text_view_item_post) TextView gildedNumberTextView; @BindView(R.id.gilded_number_text_view_item_post) TextView gildedNumberTextView;
@BindView(R.id.archived_image_view_item_post) ImageView archivedImageView;
@BindView(R.id.locked_image_view_item_post) ImageView lockedImageView;
@BindView(R.id.crosspost_image_view_item_post) ImageView crosspostImageView; @BindView(R.id.crosspost_image_view_item_post) ImageView crosspostImageView;
@BindView(R.id.nsfw_text_view_item_post) Chip nsfwChip; @BindView(R.id.nsfw_text_view_item_post) Chip nsfwChip;
@BindView(R.id.spoiler_flair_linear_layout_item_post) LinearLayout spoilerFlairLinearLayout; @BindView(R.id.spoiler_flair_linear_layout_item_post) LinearLayout spoilerFlairLinearLayout;
@ -745,6 +753,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
((DataViewHolder) holder).gildedImageView.setVisibility(View.GONE); ((DataViewHolder) holder).gildedImageView.setVisibility(View.GONE);
((DataViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE); ((DataViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE);
((DataViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((DataViewHolder) holder).crosspostImageView.setVisibility(View.GONE);
((DataViewHolder) holder).archivedImageView.setVisibility(View.GONE);
((DataViewHolder) holder).lockedImageView.setVisibility(View.GONE);
((DataViewHolder) holder).nsfwChip.setVisibility(View.GONE); ((DataViewHolder) holder).nsfwChip.setVisibility(View.GONE);
((DataViewHolder) holder).spoilerFlairLinearLayout.setVisibility(View.GONE); ((DataViewHolder) holder).spoilerFlairLinearLayout.setVisibility(View.GONE);
((DataViewHolder) holder).spoilerTextView.setVisibility(View.GONE); ((DataViewHolder) holder).spoilerTextView.setVisibility(View.GONE);

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M20.54,5.23l-1.39,-1.68C18.88,3.21 18.47,3 18,3L6,3c-0.47,0 -0.88,0.21 -1.16,0.55L3.46,5.23C3.17,5.57 3,6.02 3,6.5L3,19c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6.5c0,-0.48 -0.17,-0.93 -0.46,-1.27zM6.24,5h11.52l0.81,0.97L5.44,5.97l0.8,-0.97zM5,19L5,8h14v11L5,19zM13.45,10h-2.9v3L8,13l4,4 4,-4h-2.55z"/>
</vector>

View File

@ -92,8 +92,10 @@
android:src="@drawable/ic_arrow_downward_black_20dp" android:src="@drawable/ic_arrow_downward_black_20dp"
android:tint="@android:color/tab_indicator_text" android:tint="@android:color/tab_indicator_text"
app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment" app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment"
app:layout_constraintEnd_toStartOf="@id/more_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" /> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0" />
<ImageView <ImageView
android:id="@+id/more_button_item_post_comment" android:id="@+id/more_button_item_post_comment"

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
@ -80,67 +81,94 @@
android:textSize="18sp" android:textSize="18sp"
android:textColor="@color/primaryTextColor"/> android:textColor="@color/primaryTextColor"/>
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:padding="16dp">
android:paddingEnd="16dp"
android:paddingTop="16dp">
<com.google.android.material.chip.Chip <com.google.android.material.chip.Chip
android:id="@+id/type_text_view_item_post" android:id="@+id/type_text_view_item_post"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:layout_centerVertical="true" app:chipBackgroundColor="@color/backgroundColorPrimaryDark"
app:chipBackgroundColor="@color/backgroundColorPrimaryDark" /> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/gilded_image_view_item_post" android:id="@+id/gilded_image_view_item_post"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_toEndOf="@id/type_text_view_item_post" android:layout_marginStart="16dp"
android:layout_centerVertical="true" android:visibility="gone"
android:visibility="gone" /> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/type_text_view_item_post"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/gilded_number_text_view_item_post" android:id="@+id/gilded_number_text_view_item_post"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_image_view_item_post"
android:visibility="gone"
android:textSize="20sp"
android:textColor="@color/gold" android:textColor="@color/gold"
android:layout_centerVertical="true"/> android:textSize="20sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/gilded_image_view_item_post"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/archived_image_view_item_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_archive_outline_24dp"
android:tint="@color/archivedTint"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/crosspost_image_view_item_post"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/locked_image_view_item_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_outline_lock_24px"
android:tint="@color/lockedIconTint"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/nsfw_text_view_item_post"
app:layout_constraintStart_toEndOf="@+id/archived_image_view_item_post"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0" />
<ImageView <ImageView
android:id="@+id/crosspost_image_view_item_post" android:id="@+id/crosspost_image_view_item_post"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginStart="8dp" android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_number_text_view_item_post"
android:src="@drawable/crosspost" android:src="@drawable/crosspost"
android:tint="@color/colorAccent" android:tint="@color/colorAccent"
android:layout_centerVertical="true" android:visibility="gone"
android:visibility="gone"/> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/gilded_number_text_view_item_post"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.chip.Chip <com.google.android.material.chip.Chip
android:id="@+id/nsfw_text_view_item_post" android:id="@+id/nsfw_text_view_item_post"
android:text="@string/nsfw"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:text="@string/nsfw"
android:layout_marginStart="8dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:visibility="gone" android:visibility="gone"
android:layout_centerVertical="true" app:chipBackgroundColor="@color/colorAccent"
app:chipBackgroundColor="@color/colorAccent"/> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <LinearLayout
android:id="@+id/spoiler_flair_linear_layout_item_post" android:id="@+id/spoiler_flair_linear_layout_item_post"

View File

@ -80,7 +80,96 @@
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:visibility="gone" /> android:visibility="gone" />
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<com.google.android.material.chip.Chip
android:id="@+id/type_text_view_item_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
app:chipBackgroundColor="@color/backgroundColorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/gilded_image_view_item_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/type_text_view_item_post_detail"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/gilded_number_text_view_item_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:textColor="@color/gold"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/gilded_image_view_item_post_detail"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/archived_image_view_item_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_archive_outline_24dp"
android:tint="@color/archivedTint"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/crosspost_image_view_item_post_detail"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/locked_image_view_item_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_outline_lock_24px"
android:tint="@color/lockedIconTint"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/nsfw_text_view_item_post_detail"
app:layout_constraintStart_toEndOf="@+id/archived_image_view_item_post_detail"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0" />
<ImageView
android:id="@+id/crosspost_image_view_item_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/crosspost"
android:tint="@color/colorAccent"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/gilded_number_text_view_item_post_detail"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.chip.Chip
android:id="@+id/nsfw_text_view_item_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nsfw"
android:textColor="@android:color/white"
android:visibility="gone"
app:chipBackgroundColor="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--<RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:paddingStart="16dp"
@ -140,7 +229,7 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
app:chipBackgroundColor="@color/colorAccent"/> app:chipBackgroundColor="@color/colorAccent"/>
</RelativeLayout> </RelativeLayout>-->
<LinearLayout <LinearLayout
android:id="@+id/spoiler_flair_linear_layout_item_post_detail" android:id="@+id/spoiler_flair_linear_layout_item_post_detail"

View File

@ -51,4 +51,8 @@
<color name="singleCommentThreadBackgroundColor">#B3E5F9</color> <color name="singleCommentThreadBackgroundColor">#B3E5F9</color>
<color name="unreadMessageBackgroundColor">#B3E5F9</color> <color name="unreadMessageBackgroundColor">#B3E5F9</color>
<color name="archivedTint">#B4009F</color>
<color name="lockedIconTint">#EE7302</color>
</resources> </resources>