From 3b0ba561b2c8d66c6785618ffa876313166a2e31 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 15 Oct 2021 20:28:37 +0800 Subject: [PATCH] Fix some issues related to media indicator icon and themeing. --- .../activities/SubmitCrosspostActivity.java | 29 +++++++-------- .../PostDetailRecyclerViewAdapter.java | 2 +- .../adapters/PostRecyclerViewAdapter.java | 35 ++++++++++--------- .../ic_gallery_reverse_color_24dp.xml | 5 --- .../drawable-night/ic_play_circle_36dp.xml | 4 --- .../ic_gallery_reverse_color_24dp.xml | 5 --- .../drawable/play_button_round_background.xml | 5 +-- .../res/layout/activity_submit_crosspost.xml | 1 - app/src/main/res/layout/item_post_compact.xml | 1 - .../item_post_compact_right_thumbnail.xml | 1 - .../res/layout/item_post_detail_gallery.xml | 2 +- 11 files changed, 33 insertions(+), 57 deletions(-) delete mode 100644 app/src/main/res/drawable-night/ic_gallery_reverse_color_24dp.xml delete mode 100644 app/src/main/res/drawable-night/ic_play_circle_36dp.xml delete mode 100644 app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java index d6c5e68f..b5ac9689 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java @@ -2,8 +2,10 @@ package ml.docilealligator.infinityforreddit.activities; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Bitmap; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; @@ -265,7 +267,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom } else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) { contentTextView.setVisibility(View.VISIBLE); contentTextView.setText(post.getUrl()); - } else if (post.getPostType() == Post.GIF_TYPE || post.getPostType() == Post.GALLERY_TYPE || post.getPostType() == Post.IMAGE_TYPE) { + } else { Post.Preview preview = getPreview(post); if (preview != null) { frameLayout.setVisibility(View.VISIBLE); @@ -280,23 +282,14 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom } }); - } - } else if (post.getPostType() == Post.VIDEO_TYPE) { - Post.Preview preview = getPreview(post); - if (preview != null) { - frameLayout.setVisibility(View.VISIBLE); - mGlide.asBitmap().load(preview.getPreviewUrl()).into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - imageView.setImage(ImageSource.bitmap(resource)); - } - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); - playButton.setVisibility(View.VISIBLE); + if (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE) { + playButton.setVisibility(View.VISIBLE); + playButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_play_circle_36dp)); + } else if (post.getPostType() == Post.GALLERY_TYPE) { + playButton.setVisibility(View.VISIBLE); + playButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_gallery_24dp)); + } } } @@ -423,6 +416,8 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom titleEditText.setHintTextColor(secondaryTextColor); contentTextView.setTextColor(primaryTextColor); contentTextView.setHintTextColor(secondaryTextColor); + playButton.setColorFilter(mCustomThemeWrapper.getMediaIndicatorIconColor(), PorterDuff.Mode.SRC_IN); + playButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getMediaIndicatorBackgroundColor())); } private void displaySubredditIcon() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 064ede1d..d083a0bc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -780,7 +780,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter previews = post.getPreviews(); if (previews != null && !previews.isEmpty()) { @@ -1217,8 +1213,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter - - diff --git a/app/src/main/res/drawable-night/ic_play_circle_36dp.xml b/app/src/main/res/drawable-night/ic_play_circle_36dp.xml deleted file mode 100644 index 2471417e..00000000 --- a/app/src/main/res/drawable-night/ic_play_circle_36dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml b/app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml deleted file mode 100644 index d54dba10..00000000 --- a/app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/play_button_round_background.xml b/app/src/main/res/drawable/play_button_round_background.xml index f59e3ab5..816bfa2e 100644 --- a/app/src/main/res/drawable/play_button_round_background.xml +++ b/app/src/main/res/drawable/play_button_round_background.xml @@ -1,9 +1,6 @@ - - - + - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_submit_crosspost.xml b/app/src/main/res/layout/activity_submit_crosspost.xml index b4e555d1..345de3ae 100644 --- a/app/src/main/res/layout/activity_submit_crosspost.xml +++ b/app/src/main/res/layout/activity_submit_crosspost.xml @@ -216,7 +216,6 @@ android:layout_margin="16dp" android:layout_gravity="start" android:background="@drawable/play_button_round_background" - android:src="@drawable/ic_play_circle_36dp" android:visibility="gone" /> diff --git a/app/src/main/res/layout/item_post_compact.xml b/app/src/main/res/layout/item_post_compact.xml index 06c00131..0371a939 100644 --- a/app/src/main/res/layout/item_post_compact.xml +++ b/app/src/main/res/layout/item_post_compact.xml @@ -234,7 +234,6 @@ android:layout_gravity="center" android:layout_margin="0dp" android:background="@drawable/play_button_round_background" - android:src="@drawable/ic_play_circle_36dp" android:visibility="gone" /> diff --git a/app/src/main/res/layout/item_post_compact_right_thumbnail.xml b/app/src/main/res/layout/item_post_compact_right_thumbnail.xml index 6b1b7abf..f151c98d 100644 --- a/app/src/main/res/layout/item_post_compact_right_thumbnail.xml +++ b/app/src/main/res/layout/item_post_compact_right_thumbnail.xml @@ -103,7 +103,6 @@ android:layout_gravity="center" android:layout_margin="0dp" android:background="@drawable/play_button_round_background" - android:src="@drawable/ic_play_circle_36dp" android:visibility="gone" /> diff --git a/app/src/main/res/layout/item_post_detail_gallery.xml b/app/src/main/res/layout/item_post_detail_gallery.xml index 1a345dab..5a53410d 100644 --- a/app/src/main/res/layout/item_post_detail_gallery.xml +++ b/app/src/main/res/layout/item_post_detail_gallery.xml @@ -227,7 +227,7 @@ android:layout_gravity="start" android:scaleType="center" android:background="@drawable/play_button_round_background" - android:src="@drawable/ic_gallery_reverse_color_24dp" /> + android:src="@drawable/ic_gallery_24dp" />