From 7252dce6e3f7df54440e1c2cdb88a02270e61f48 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Fri, 15 Sep 2023 17:50:36 -0400 Subject: Continue changing vote button icons. --- .../adapters/PostDetailRecyclerViewAdapter.java | 1676 +++++++++----------- .../adapters/PostRecyclerViewAdapter.java | 94 +- .../main/res/layout/item_post_detail_gallery.xml | 131 +- .../item_post_detail_image_and_gif_autoplay.xml | 121 +- app/src/main/res/layout/item_post_detail_link.xml | 121 +- .../res/layout/item_post_detail_no_preview.xml | 177 ++- app/src/main/res/layout/item_post_detail_text.xml | 117 +- .../item_post_detail_video_and_gif_preview.xml | 121 +- .../res/layout/item_post_detail_video_autoplay.xml | 123 +- ...ost_detail_video_autoplay_legacy_controller.xml | 123 +- 10 files changed, 1350 insertions(+), 1454 deletions(-) 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 1aad70b1..3867c3c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -8,7 +8,6 @@ import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; -import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -20,10 +19,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -48,6 +44,8 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.DefaultTimeBar; import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.ui.TimeBar; +import com.google.android.material.button.MaterialButton; +import com.google.android.material.button.MaterialButtonToggleGroup; import com.google.common.collect.ImmutableList; import com.libRG.CustomTextView; @@ -57,8 +55,6 @@ import java.util.concurrent.Executor; import javax.inject.Provider; -import butterknife.BindView; -import butterknife.ButterKnife; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; @@ -99,6 +95,14 @@ import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailGalleryBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailImageAndGifAutoplayBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailLinkBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailNoPreviewBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailTextBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailVideoAndGifPreviewBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailVideoAutoplayBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostDetailVideoAutoplayLegacyControllerBinding; import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; import ml.docilealligator.infinityforreddit.post.Post; @@ -430,47 +434,52 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter= 0) { @@ -498,11 +507,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).binding.progressBarItemPostDetailImageAndGifAutoplay.setVisibility(View.GONE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).binding.loadImageErrorTextViewItemPostDetailImageAndGifAutoplay.setVisibility(View.VISIBLE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).binding.loadImageErrorTextViewItemPostDetailImageAndGifAutoplay.setOnClickListener(view -> { + ((PostDetailImageAndGifAutoplayViewHolder) holder).binding.progressBarItemPostDetailImageAndGifAutoplay.setVisibility(View.VISIBLE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).binding.loadImageErrorTextViewItemPostDetailImageAndGifAutoplay.setVisibility(View.GONE); loadImage(holder, preview); }); return false; @@ -857,26 +867,26 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter target, DataSource dataSource, boolean isFirstResource) { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).binding.loadWrapperItemPostDetailImageAndGifAutoplay.setVisibility(View.GONE); return false; } }); if (blurImage) { - imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).binding.imageViewItemPostDetailImageAndGifAutoplay); } else { - imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailImageAndGifAutoplayViewHolder) holder).binding.imageViewItemPostDetailImageAndGifAutoplay); } } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { RequestBuilder imageRequestBuilder = mGlide.load(preview.getPreviewUrl()) .listener(new RequestListener<>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); - ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); - ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { - ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); - ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + ((PostDetailVideoAndGifPreviewHolder) holder).binding.progressBarItemPostDetailVideoAndGifPreview.setVisibility(View.GONE); + ((PostDetailVideoAndGifPreviewHolder) holder).binding.loadImageErrorTextViewItemPostDetailVideoAndGifPreview.setVisibility(View.VISIBLE); + ((PostDetailVideoAndGifPreviewHolder) holder).binding.loadImageErrorTextViewItemPostDetailVideoAndGifPreview.setOnClickListener(view -> { + ((PostDetailVideoAndGifPreviewHolder) holder).binding.progressBarItemPostDetailVideoAndGifPreview.setVisibility(View.VISIBLE); + ((PostDetailVideoAndGifPreviewHolder) holder).binding.loadImageErrorTextViewItemPostDetailVideoAndGifPreview.setVisibility(View.GONE); loadImage(holder, preview); }); return false; @@ -884,27 +894,27 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter target, DataSource dataSource, boolean isFirstResource) { - ((PostDetailVideoAndGifPreviewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + ((PostDetailVideoAndGifPreviewHolder) holder).binding.loadWrapperItemPostDetailVideoAndGifPreview.setVisibility(View.GONE); return false; } }); if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); + .into(((PostDetailVideoAndGifPreviewHolder) holder).binding.imageViewItemPostDetailVideoAndGifPreview); } else { - imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); + imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailVideoAndGifPreviewHolder) holder).binding.imageViewItemPostDetailVideoAndGifPreview); } } else if (holder instanceof PostDetailLinkViewHolder) { RequestBuilder imageRequestBuilder = mGlide.load(preview.getPreviewUrl()) .listener(new RequestListener<>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); - ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); - ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { - ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); - ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + ((PostDetailLinkViewHolder) holder).binding.progressBarItemPostDetailLink.setVisibility(View.GONE); + ((PostDetailLinkViewHolder) holder).binding.loadImageErrorTextViewItemPostDetailLink.setVisibility(View.VISIBLE); + ((PostDetailLinkViewHolder) holder).binding.loadImageErrorTextViewItemPostDetailLink.setOnClickListener(view -> { + ((PostDetailLinkViewHolder) holder).binding.progressBarItemPostDetailLink.setVisibility(View.VISIBLE); + ((PostDetailLinkViewHolder) holder).binding.loadImageErrorTextViewItemPostDetailLink.setVisibility(View.GONE); loadImage(holder, preview); }); return false; @@ -912,16 +922,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter target, DataSource dataSource, boolean isFirstResource) { - ((PostDetailLinkViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + ((PostDetailLinkViewHolder) holder).binding.loadWrapperItemPostDetailLink.setVisibility(View.GONE); return false; } }); if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostDetailLinkViewHolder) holder).mImageView); + .into(((PostDetailLinkViewHolder) holder).binding.imageViewItemPostDetailLink); } else { - imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailLinkViewHolder) holder).mImageView); + imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailLinkViewHolder) holder).binding.imageViewItemPostDetailLink); } } } @@ -952,15 +962,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter mSubredditTextView.performClick()); - - mSubredditTextView.setOnClickListener(view -> { + void setBaseView(AspectRatioGifImageView iconGifImageView, + TextView subredditTextView, + TextView userTextView, + TextView authorFlairTextView, + TextView postTimeTextView, + TextView titleTextView, + CustomTextView typeTextView, + ImageView crosspostImageView, + ImageView archivedImageView, + ImageView lockedImageView, + CustomTextView nSFWTextView, + CustomTextView spoilerTextView, + CustomTextView flairTextView, + TextView awardsTextView, + TextView upvoteRatioTextView, + RecyclerView contentMarkdownView, + ConstraintLayout bottomConstraintLayout, + MaterialButtonToggleGroup voteButtonToggleGroup, + MaterialButton upvoteButton, + MaterialButton downvoteButton, + MaterialButton commentsCountButton, + MaterialButton saveButton, + MaterialButton shareButton) { + this.iconGifImageView = iconGifImageView; + this.subredditTextView = subredditTextView; + this.userTextView = userTextView; + this.authorFlairTextView = authorFlairTextView; + this.postTimeTextView = postTimeTextView; + this.titleTextView = titleTextView; + this.typeTextView = typeTextView; + this.crosspostImageView = crosspostImageView; + this.archivedImageView = archivedImageView; + this.lockedImageView = lockedImageView; + this.nsfwTextView = nSFWTextView; + this.spoilerTextView = spoilerTextView; + this.flairTextView = flairTextView; + this.awardsTextView = awardsTextView; + this.upvoteRatioTextView = upvoteRatioTextView; + this.contentMarkdownView = contentMarkdownView; + this.bottomConstraintLayout = bottomConstraintLayout; + this.upvoteButton = upvoteButton; + this.downvoteButton = downvoteButton; + this.commentsCountButton = commentsCountButton; + this.saveButton = saveButton; + this.shareButton = shareButton; + + iconGifImageView.setOnClickListener(view -> subredditTextView.performClick()); + + subredditTextView.setOnClickListener(view -> { Intent intent; intent = new Intent(mActivity, ViewSubredditDetailActivity.class); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, @@ -1128,7 +1138,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + userTextView.setOnClickListener(view -> { if (mPost.isAuthorDeleted()) { return; } @@ -1137,16 +1147,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter mUserTextView.performClick()); + authorFlairTextView.setOnClickListener(view -> userTextView.performClick()); - mCrosspostImageView.setOnClickListener(view -> { + crosspostImageView.setOnClickListener(view -> { Intent crosspostIntent = new Intent(mActivity, ViewPostDetailActivity.class); crosspostIntent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, mPost.getCrosspostParentId()); mActivity.startActivity(crosspostIntent); }); if (!mHidePostType) { - mTypeTextView.setOnClickListener(view -> { + typeTextView.setOnClickListener(view -> { Intent intent = new Intent(mActivity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2)); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT); @@ -1154,11 +1164,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + flairTextView.setOnClickListener(view -> { Intent intent = new Intent(mActivity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2)); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT); @@ -1166,10 +1176,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + nSFWTextView.setOnClickListener(view -> { Intent intent = new Intent(mActivity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2)); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT); @@ -1177,7 +1187,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + upvoteButton.setOnClickListener(view -> { if (mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -1200,31 +1210,35 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + downvoteButton.setOnClickListener(view -> { if (mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -1280,31 +1299,34 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + this.commentsCountButton.setOnClickListener(view -> { if (mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_comment_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -1376,23 +1402,23 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + this.saveButton.setOnClickListener(view -> { if (mAccessToken == null) { Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); return; } if (mPost.isSaved()) { - mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + this.saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp); SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { mPost.setSaved(false); - mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + PostDetailBaseViewHolder.this.saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp); Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show(); mPostDetailRecyclerViewAdapterCallback.updatePost(mPost); } @@ -1400,19 +1426,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + this.shareButton.setOnClickListener(view -> { Bundle bundle = new Bundle(); bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, mPost.getPermalink()); if (mPost.getPostType() != Post.TEXT_TYPE) { @@ -1450,149 +1476,112 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + this.shareButton.setOnLongClickListener(view -> { mActivity.copyLink(mPost.getPermalink()); return true; }); if (mVoteButtonsOnTheRight) { ConstraintSet constraintSet = new ConstraintSet(); - constraintSet.clone(mBottomConstraintLayout); - constraintSet.clear(mUpvoteButton.getId(), ConstraintSet.START); - constraintSet.clear(mScoreTextView.getId(), ConstraintSet.START); - constraintSet.clear(mDownvoteButton.getId(), ConstraintSet.START); - constraintSet.clear(mSaveButton.getId(), ConstraintSet.END); - constraintSet.clear(mShareButton.getId(), ConstraintSet.END); - constraintSet.connect(mUpvoteButton.getId(), ConstraintSet.END, mScoreTextView.getId(), ConstraintSet.START); - constraintSet.connect(mScoreTextView.getId(), ConstraintSet.END, mDownvoteButton.getId(), ConstraintSet.START); - constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); - constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.START, mSaveButton.getId(), ConstraintSet.END); - constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.END, mUpvoteButton.getId(), ConstraintSet.START); - constraintSet.connect(mSaveButton.getId(), ConstraintSet.START, mShareButton.getId(), ConstraintSet.END); - constraintSet.connect(mShareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); - constraintSet.setHorizontalBias(commentsCountTextView.getId(), 0); - constraintSet.applyTo(mBottomConstraintLayout); + constraintSet.clone(bottomConstraintLayout); + constraintSet.clear(voteButtonToggleGroup.getId(), ConstraintSet.START); + constraintSet.clear(saveButton.getId(), ConstraintSet.END); + constraintSet.clear(shareButton.getId(), ConstraintSet.END); + constraintSet.connect(voteButtonToggleGroup.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); + constraintSet.connect(commentsCountButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END); + constraintSet.connect(commentsCountButton.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START); + constraintSet.connect(saveButton.getId(), ConstraintSet.START, shareButton.getId(), ConstraintSet.END); + constraintSet.connect(shareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); + constraintSet.setHorizontalBias(commentsCountButton.getId(), 0); + constraintSet.applyTo(bottomConstraintLayout); } if (mActivity.typeface != null) { - mSubredditTextView.setTypeface(mActivity.typeface); - mUserTextView.setTypeface(mActivity.typeface); - mAuthorFlairTextView.setTypeface(mActivity.typeface); - mPostTimeTextView.setTypeface(mActivity.typeface); - mTypeTextView.setTypeface(mActivity.typeface); - mSpoilerTextView.setTypeface(mActivity.typeface); - mNSFWTextView.setTypeface(mActivity.typeface); - mFlairTextView.setTypeface(mActivity.typeface); - mAwardsTextView.setTypeface(mActivity.typeface); - mUpvoteRatioTextView.setTypeface(mActivity.typeface); - mScoreTextView.setTypeface(mActivity.typeface); - commentsCountTextView.setTypeface(mActivity.typeface); + subredditTextView.setTypeface(mActivity.typeface); + userTextView.setTypeface(mActivity.typeface); + authorFlairTextView.setTypeface(mActivity.typeface); + postTimeTextView.setTypeface(mActivity.typeface); + typeTextView.setTypeface(mActivity.typeface); + spoilerTextView.setTypeface(mActivity.typeface); + nSFWTextView.setTypeface(mActivity.typeface); + flairTextView.setTypeface(mActivity.typeface); + awardsTextView.setTypeface(mActivity.typeface); + upvoteRatioTextView.setTypeface(mActivity.typeface); + upvoteButton.setTypeface(mActivity.typeface); + commentsCountButton.setTypeface(mActivity.typeface); } if (mActivity.titleTypeface != null) { - mTitleTextView.setTypeface(mActivity.typeface); + titleTextView.setTypeface(mActivity.typeface); } itemView.setBackgroundColor(mCardViewColor); - mSubredditTextView.setTextColor(mSubredditColor); - mUserTextView.setTextColor(mUsernameColor); - mAuthorFlairTextView.setTextColor(mAuthorFlairTextColor); - mPostTimeTextView.setTextColor(mSecondaryTextColor); - mTitleTextView.setTextColor(mPostTitleColor); - mTypeTextView.setBackgroundColor(mPostTypeBackgroundColor); - mTypeTextView.setBorderColor(mPostTypeBackgroundColor); - mTypeTextView.setTextColor(mPostTypeTextColor); - mSpoilerTextView.setBackgroundColor(mSpoilerBackgroundColor); - mSpoilerTextView.setBorderColor(mSpoilerBackgroundColor); - mSpoilerTextView.setTextColor(mSpoilerTextColor); - mNSFWTextView.setBackgroundColor(mNSFWBackgroundColor); - mNSFWTextView.setBorderColor(mNSFWBackgroundColor); - mNSFWTextView.setTextColor(mNSFWTextColor); - mFlairTextView.setBackgroundColor(mFlairBackgroundColor); - mFlairTextView.setBorderColor(mFlairBackgroundColor); - mFlairTextView.setTextColor(mFlairTextColor); - mArchivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN); - mLockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN); - mCrosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN); - mAwardsTextView.setTextColor(mSecondaryTextColor); + subredditTextView.setTextColor(mSubredditColor); + userTextView.setTextColor(mUsernameColor); + authorFlairTextView.setTextColor(mAuthorFlairTextColor); + postTimeTextView.setTextColor(mSecondaryTextColor); + titleTextView.setTextColor(mPostTitleColor); + typeTextView.setBackgroundColor(mPostTypeBackgroundColor); + typeTextView.setBorderColor(mPostTypeBackgroundColor); + typeTextView.setTextColor(mPostTypeTextColor); + spoilerTextView.setBackgroundColor(mSpoilerBackgroundColor); + spoilerTextView.setBorderColor(mSpoilerBackgroundColor); + spoilerTextView.setTextColor(mSpoilerTextColor); + nSFWTextView.setBackgroundColor(mNSFWBackgroundColor); + nSFWTextView.setBorderColor(mNSFWBackgroundColor); + nSFWTextView.setTextColor(mNSFWTextColor); + flairTextView.setBackgroundColor(mFlairBackgroundColor); + flairTextView.setBorderColor(mFlairBackgroundColor); + flairTextView.setTextColor(mFlairTextColor); + archivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN); + lockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN); + crosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN); + awardsTextView.setTextColor(mSecondaryTextColor); Drawable upvoteRatioDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_upvote_ratio, mUpvoteRatioTintColor); - mUpvoteRatioTextView.setCompoundDrawablesWithIntrinsicBounds( + upvoteRatioTextView.setCompoundDrawablesWithIntrinsicBounds( upvoteRatioDrawable, null, null, null); - mUpvoteRatioTextView.setTextColor(mSecondaryTextColor); - mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN); - mScoreTextView.setTextColor(mPostIconAndInfoColor); - mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN); - commentsCountTextView.setTextColor(mPostIconAndInfoColor); - commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null); - mSaveButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN); - mShareButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN); + upvoteRatioTextView.setTextColor(mSecondaryTextColor); + upvoteButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); + upvoteButton.setTextColor(mPostIconAndInfoColor); + downvoteButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); + commentsCountButton.setTextColor(mPostIconAndInfoColor); + commentsCountButton.setIcon(mCommentIcon); + saveButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); + shareButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); } } - class PostDetailVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer { + class PostDetailBaseVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer { public Call fetchGfycatOrStreamableVideoCall; - @BindView(R.id.icon_gif_image_view_item_post_detail_video_autoplay) AspectRatioGifImageView mIconGifImageView; - @BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay) TextView mSubredditTextView; - @BindView(R.id.user_text_view_item_post_detail_video_autoplay) TextView mUserTextView; - @BindView(R.id.author_flair_text_view_item_post_detail_video_autoplay) TextView mAuthorFlairTextView; - @BindView(R.id.post_time_text_view_item_post_detail_video_autoplay) TextView mPostTimeTextView; - @BindView(R.id.title_text_view_item_post_detail_video_autoplay) TextView mTitleTextView; - @BindView(R.id.type_text_view_item_post_detail_video_autoplay) CustomTextView mTypeTextView; - @BindView(R.id.crosspost_image_view_item_post_detail_video_autoplay) ImageView mCrosspostImageView; - @BindView(R.id.archived_image_view_item_post_detail_video_autoplay) ImageView mArchivedImageView; - @BindView(R.id.locked_image_view_item_post_detail_video_autoplay) ImageView mLockedImageView; - @BindView(R.id.nsfw_text_view_item_post_detail_video_autoplay) CustomTextView mNSFWTextView; - @BindView(R.id.spoiler_custom_text_view_item_post_detail_video_autoplay) CustomTextView mSpoilerTextView; - @BindView(R.id.flair_custom_text_view_item_post_detail_video_autoplay) CustomTextView mFlairTextView; - @BindView(R.id.awards_text_view_item_post_detail_video_autoplay) TextView mAwardsTextView; - @BindView(R.id.upvote_ratio_text_view_item_post_detail_video_autoplay) TextView mUpvoteRatioTextView; - @BindView(R.id.aspect_ratio_frame_layout_item_post_detail_video_autoplay) AspectRatioFrameLayout aspectRatioFrameLayout; - @BindView(R.id.player_view_item_post_detail_video_autoplay) PlayerView playerView; - @BindView(R.id.preview_image_view_item_post_detail_video_autoplay) GifImageView previewImageView; - @BindView(R.id.error_loading_gfycat_image_view_item_post_detail_video_autoplay) ImageView mErrorLoadingGfycatImageView; - @BindView(R.id.mute_exo_playback_control_view) ImageView muteButton; - @BindView(R.id.fullscreen_exo_playback_control_view) ImageView fullscreenButton; - @BindView(R.id.exo_pause) ImageView pauseButton; - @BindView(R.id.exo_play) ImageView playButton; - @BindView(R.id.exo_progress) DefaultTimeBar progressBar; - @BindView(R.id.content_markdown_view_item_post_detail_video_autoplay) RecyclerView mContentMarkdownView; - @BindView(R.id.bottom_constraint_layout_item_post_detail_video_autoplay) ConstraintLayout mBottomConstraintLayout; - @BindView(R.id.plus_button_item_post_detail_video_autoplay) - ImageView mUpvoteButton; - @BindView(R.id.score_text_view_item_post_detail_video_autoplay) - TextView mScoreTextView; - @BindView(R.id.minus_button_item_post_detail_video_autoplay) - ImageView mDownvoteButton; - @BindView(R.id.comments_count_item_post_detail_video_autoplay) - TextView commentsCountTextView; - @BindView(R.id.save_button_item_post_detail_video_autoplay) - ImageView mSaveButton; - @BindView(R.id.share_button_item_post_detail_video_autoplay) - ImageView mShareButton; + MaterialButton mUpvoteButton; + MaterialButton mDownvoteButton; + MaterialButton commentsCountButton; + MaterialButton mSaveButton; + MaterialButton mShareButton; @Nullable Container container; @Nullable @@ -1601,32 +1590,73 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + ItemPostDetailVideoAndGifPreviewBinding binding; + + PostDetailVideoAndGifPreviewHolder(@NonNull ItemPostDetailVideoAndGifPreviewBinding binding) { + super(binding.getRoot()); + this.binding = binding; + setBaseView(binding.iconGifImageViewItemPostDetailVideoAndGifPreview, + binding.subredditTextViewItemPostDetailVideoAndGifPreview, + binding.userTextViewItemPostDetailVideoAndGifPreview, + binding.authorFlairTextViewItemPostDetailVideoAndGifPreview, + binding.postTimeTextViewItemPostDetailVideoAndGifPreview, + binding.titleTextViewItemPostDetailVideoAndGifPreview, + binding.typeTextViewItemPostDetailVideoAndGifPreview, + binding.crosspostImageViewItemPostDetailVideoAndGifPreview, + binding.archivedImageViewItemPostDetailVideoAndGifPreview, + binding.lockedImageViewItemPostDetailVideoAndGifPreview, + binding.nsfwTextViewItemPostDetailVideoAndGifPreview, + binding.spoilerCustomTextViewItemPostDetailVideoAndGifPreview, + binding.flairCustomTextViewItemPostDetailVideoAndGifPreview, + binding.awardsTextViewItemPostDetailVideoAndGifPreview, + binding.upvoteRatioTextViewItemPostDetailVideoAndGifPreview, + binding.contentMarkdownViewItemPostDetailVideoAndGifPreview, + binding.bottomConstraintLayoutItemPostDetailVideoAndGifPreview, + binding.voteButtonToggleItemPostDetailVideoAndGifPreview, + binding.upvoteButtonItemPostDetailVideoAndGifPreview, + binding.downvoteButtonItemPostDetailVideoAndGifPreview, + binding.commentsCountButtonItemPostDetailVideoAndGifPreview, + binding.saveButtonItemPostDetailVideoAndGifPreview, + binding.shareButtonItemPostDetailVideoAndGifPreview); + + binding.videoOrGifIndicatorImageViewItemPostDetail.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN); + binding.videoOrGifIndicatorImageViewItemPostDetail.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor)); + binding.progressBarItemPostDetailVideoAndGifPreview.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + binding.loadImageErrorTextViewItemPostDetailVideoAndGifPreview.setTextColor(mPrimaryTextColor); + + binding.imageViewItemPostDetailVideoAndGifPreview.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; if (mPost.getPostType() == Post.VIDEO_TYPE) { @@ -1966,94 +2017,39 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + ItemPostDetailImageAndGifAutoplayBinding binding; + + PostDetailImageAndGifAutoplayViewHolder(@NonNull ItemPostDetailImageAndGifAutoplayBinding binding) { + super(binding.getRoot()); + this.binding = binding; + setBaseView(binding.iconGifImageViewItemPostDetailImageAndGifAutoplay, + binding.subredditTextViewItemPostDetailImageAndGifAutoplay, + binding.userTextViewItemPostDetailImageAndGifAutoplay, + binding.authorFlairTextViewItemPostDetailImageAndGifAutoplay, + binding.postTimeTextViewItemPostDetailImageAndGifAutoplay, + binding.titleTextViewItemPostDetailImageAndGifAutoplay, + binding.typeTextViewItemPostDetailImageAndGifAutoplay, + binding.crosspostImageViewItemPostDetailImageAndGifAutoplay, + binding.archivedImageViewItemPostDetailImageAndGifAutoplay, + binding.lockedImageViewItemPostDetailImageAndGifAutoplay, + binding.nsfwTextViewItemPostDetailImageAndGifAutoplay, + binding.spoilerCustomTextViewItemPostDetailImageAndGifAutoplay, + binding.flairCustomTextViewItemPostDetailImageAndGifAutoplay, + binding.awardsTextViewItemPostDetailImageAndGifAutoplay, + binding.upvoteRatioTextViewItemPostDetailImageAndGifAutoplay, + binding.contentMarkdownViewItemPostDetailImageAndGifAutoplay, + binding.bottomConstraintLayoutItemPostDetailImageAndGifAutoplay, + binding.voteButtonToggleItemPostDetailImageAndGifAutoplay, + binding.upvoteButtonItemPostDetailImageAndGifAutoplay, + binding.downvoteButtonItemPostDetailImageAndGifAutoplay, + binding.commentsCountButtonItemPostDetailImageAndGifAutoplay, + binding.saveButtonItemPostDetailImageAndGifAutoplay, + binding.shareButtonItemPostDetailImageAndGifAutoplay); + + binding.progressBarItemPostDetailImageAndGifAutoplay.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + binding.loadImageErrorTextViewItemPostDetailImageAndGifAutoplay.setTextColor(mPrimaryTextColor); + + binding.imageViewItemPostDetailImageAndGifAutoplay.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; if (mPost.getPostType() == Post.IMAGE_TYPE) { @@ -2079,100 +2075,43 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + binding.imageViewItemPostDetailLink.setOnClickListener(view -> { Intent intent = new Intent(mActivity, LinkResolverActivity.class); Uri uri = Uri.parse(mPost.getUrl()); intent.setData(uri); @@ -2183,92 +2122,43 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + binding.imageViewNoPreviewPostTypeItemPostDetailNoPreview.setOnClickListener(view -> { if (mPost != null) { if (mPost.getPostType() == Post.VIDEO_TYPE) { Intent intent = new Intent(mActivity, ViewVideoActivity.class); @@ -2324,105 +2214,52 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + binding.galleryRecyclerViewItemPostDetailGallery.setAdapter(adapter); + new PagerSnapHelper().attachToRecyclerView(binding.galleryRecyclerViewItemPostDetailGallery); + binding.galleryRecyclerViewItemPostDetailGallery.setOnTouchListener((v, motionEvent) -> { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) { if (mActivity.mSliderPanel != null) { mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); @@ -2444,8 +2281,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + binding.noPreviewPostTypeImageViewItemPostDetailGallery.setOnClickListener(view -> { Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class); intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, mPost.getGallery()); intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName()); @@ -2519,79 +2356,34 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter + android:layout_height="wrap_content" + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - - - + + + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_gallery" + style="?attr/materialIconButtonOutlinedStyle" /> - + style="?attr/materialIconButtonOutlinedStyle" /> - + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml b/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml index 900ce5d1..b71ae921 100644 --- a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml +++ b/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml @@ -252,89 +252,96 @@ android:nestedScrollingEnabled="false" /> + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - + app:layout_constraintBottom_toBottomOf="parent"> - + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_image_and_gif_autoplay" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_image_and_gif_autoplay" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_image_and_gif_autoplay" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_link.xml b/app/src/main/res/layout/item_post_detail_link.xml index a6299212..4074f4b4 100644 --- a/app/src/main/res/layout/item_post_detail_link.xml +++ b/app/src/main/res/layout/item_post_detail_link.xml @@ -262,89 +262,96 @@ android:nestedScrollingEnabled="false" /> + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - + app:layout_constraintBottom_toBottomOf="parent"> - + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_link" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_link" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_link" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_no_preview.xml b/app/src/main/res/layout/item_post_detail_no_preview.xml index e96a45a3..b460f0d7 100644 --- a/app/src/main/res/layout/item_post_detail_no_preview.xml +++ b/app/src/main/res/layout/item_post_detail_no_preview.xml @@ -8,13 +8,13 @@ android:background="?attr/cardViewBackgroundColor"> + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - - - + + + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_no_preview" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_no_preview" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_no_preview" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_text.xml b/app/src/main/res/layout/item_post_detail_text.xml index 936ef740..625a598d 100644 --- a/app/src/main/res/layout/item_post_detail_text.xml +++ b/app/src/main/res/layout/item_post_detail_text.xml @@ -213,89 +213,96 @@ + android:paddingStart="8dp" + android:paddingEnd="8dp"> - + app:layout_constraintBottom_toBottomOf="parent"> - + - + - + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_text" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_text" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_text" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml index f1d84e27..8a7c8044 100644 --- a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml +++ b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml @@ -265,89 +265,96 @@ android:nestedScrollingEnabled="false" /> + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - + app:layout_constraintBottom_toBottomOf="parent"> - + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_video_and_gif_preview" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_video_and_gif_preview" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_video_and_gif_preview" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_video_autoplay.xml b/app/src/main/res/layout/item_post_detail_video_autoplay.xml index d4818d41..69af5ffd 100644 --- a/app/src/main/res/layout/item_post_detail_video_autoplay.xml +++ b/app/src/main/res/layout/item_post_detail_video_autoplay.xml @@ -246,89 +246,96 @@ android:nestedScrollingEnabled="false" /> + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - - - + + + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_video_autoplay" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_video_autoplay" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_video_autoplay" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> diff --git a/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml b/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml index c21efc56..36400f28 100644 --- a/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml +++ b/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml @@ -247,89 +247,96 @@ android:nestedScrollingEnabled="false" /> + android:paddingStart="8dp" + android:paddingEnd="8dp"> - - - - - - - + + + + + + + + + app:layout_constraintStart_toEndOf="@id/vote_button_toggle_item_post_detail_video_autoplay" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintStart_toEndOf="@id/comments_count_button_item_post_detail_video_autoplay" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_video_autoplay" + style="?attr/materialIconButtonOutlinedStyle" /> - + app:layout_constraintEnd_toEndOf="parent" + style="?attr/materialIconButtonOutlinedStyle" /> -- cgit v1.2.3