From d0faebbab94fff13a657311b286419619200663e Mon Sep 17 00:00:00 2001 From: Hermes Junior Date: Sun, 29 Mar 2020 05:20:52 +0200 Subject: Add hidden comment toolbar feature. --- .../Activity/ViewPostDetailActivity.java | 15 +++++--- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 45 +++++++++++++++++++++- .../Utils/SharedPreferencesUtils.java | 2 + app/src/main/res/layout/item_comment.xml | 16 +++++++- app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/interface_preference.xml | 10 +++++ 6 files changed, 81 insertions(+), 9 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 152b71ad..160a5b42 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -177,6 +177,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS private boolean mLockFab; private boolean mSwipeUpToHideFab; private boolean mExpandChildren; + private boolean mCommentToolbarHidden; + private boolean mCommentToolbarHideOnClick; private boolean mShowCommentDivider; private boolean mShowAbsoluteNumberOfVotes; private LinearLayoutManager mLinearLayoutManager; @@ -243,6 +245,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false); mSwipeUpToHideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false); mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false); + mCommentToolbarHidden = mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDDEN, false); + mCommentToolbarHideOnClick= mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true); mShowCommentDivider = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false); mShowAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true); @@ -500,8 +504,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide, mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, isSingleCommentThreadMode, - mNeedBlurNsfw, mNeedBlurSpoiler, mVoteButtonsOnTheRight, mShowElapsedTime, - mExpandChildren, mShowCommentDivider, mShowAbsoluteNumberOfVotes, + mNeedBlurNsfw, mNeedBlurSpoiler, mVoteButtonsOnTheRight, mShowElapsedTime, mExpandChildren, + mCommentToolbarHidden, mCommentToolbarHideOnClick, mShowCommentDivider,mShowAbsoluteNumberOfVotes, new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() { @Override public void updatePost(Post post) { @@ -630,10 +634,9 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide, - mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, - isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler, - mVoteButtonsOnTheRight, mShowElapsedTime, mExpandChildren, mShowCommentDivider, - mShowAbsoluteNumberOfVotes, + mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, isSingleCommentThreadMode, + mNeedBlurNsfw, mNeedBlurSpoiler, mVoteButtonsOnTheRight, mShowElapsedTime, mExpandChildren, + mCommentToolbarHidden, mCommentToolbarHideOnClick, mShowCommentDivider, mShowAbsoluteNumberOfVotes, new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() { @Override public void updatePost(Post post) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 8a67a44f..44609d19 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -17,6 +17,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; @@ -125,6 +126,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter 0) { @@ -887,6 +903,21 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { + if (((CommentViewHolder) holder).bottomConstraintLayout.getVisibility() == View.GONE){ + ((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.VISIBLE); + ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE); + } else { + ((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.GONE); + ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE); + } + }; + ((CommentViewHolder) holder).linearLayout.setOnClickListener(hideToolbarOnClickListener); + ((CommentViewHolder) holder).commentMarkdownView.setOnClickListener(hideToolbarOnClickListener); + ((CommentViewHolder) holder).commentTimeTextView.setOnClickListener(hideToolbarOnClickListener); + } + ((CommentViewHolder) holder).moreButton.setOnClickListener(view -> { Bundle bundle = new Bundle(); if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) { @@ -1002,6 +1033,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter + android:orientation="vertical" + android:animateLayoutChanges="true"> + + + app:constraint_referenced_ids="top_score_text_view_item_post_comment" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a05fb242..67519d2f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -314,6 +314,8 @@ Confirm to Exit Show Top-level Comments First Show Comment Divider + Click to Show/Hide Comment Toolbar + Comment Toolbar Hidden by Default Show Absolute Number of Votes Show Elapsed Time in Posts and Comments Default Post Layout diff --git a/app/src/main/res/xml/interface_preference.xml b/app/src/main/res/xml/interface_preference.xml index 7b21020e..0ddedb98 100644 --- a/app/src/main/res/xml/interface_preference.xml +++ b/app/src/main/res/xml/interface_preference.xml @@ -51,6 +51,16 @@ app:key="show_comment_divider" app:title="@string/settings_show_comment_divider_title" /> + + + +