aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2022-11-14 11:01:31 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2022-11-14 11:01:31 +0000
commit67b6906ead02ceb7d7e46f28ae5c27a510956038 (patch)
treecbbcf9558131b8d276ef177d21513f4bb04004ce /app/src/main/java
parentaf870c157bd542b776bf16ff36527b80af5f92d3 (diff)
downloadinfinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar
infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.gz
infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.bz2
infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.lz
infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.xz
infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.zst
infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.zip
New option: Settings->Interface->Comment->Comment Divider Type.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java39
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
3 files changed, 46 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 5e66a671..55517b4e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -74,6 +74,9 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+ public static final int DIVIDER_NORMAL = 0;
+ public static final int DIVIDER_PARENT = 1;
+
private static final int VIEW_TYPE_FIRST_LOADING = 9;
private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 10;
private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 11;
@@ -107,6 +110,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private boolean mCommentToolbarHideOnClick;
private boolean mSwapTapAndLong;
private boolean mShowCommentDivider;
+ private int mDividerType;
private boolean mShowAbsoluteNumberOfVotes;
private boolean mFullyCollapseComment;
private boolean mShowOnlyOneCommentLevelIndicator;
@@ -221,6 +225,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mCommentToolbarHideOnClick = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true);
mSwapTapAndLong = sharedPreferences.getBoolean(SharedPreferencesUtils.SWAP_TAP_AND_LONG_COMMENTS, false);
mShowCommentDivider = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
+ mDividerType = Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.COMMENT_DIVIDER_TYPE, "0"));
mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false);
mShowOnlyOneCommentLevelIndicator = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR, false);
@@ -525,6 +530,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (position == mSearchCommentIndex) {
holder.itemView.setBackgroundColor(Color.parseColor("#03A9F4"));
}
+
+ if (mShowCommentDivider) {
+ if (mDividerType == DIVIDER_PARENT && comment.getDepth() == 0) {
+ RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
+ params.setMargins(0, (int) Utils.convertDpToPixel(16, mActivity), 0, 0);
+ }
+ }
}
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
Comment comment = getCurrentComment(position);
@@ -574,6 +586,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
+
+ if (mShowCommentDivider) {
+ if (mDividerType == DIVIDER_PARENT && comment.getDepth() == 0) {
+ RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
+ params.setMargins(0, (int) Utils.convertDpToPixel(16, mActivity), 0, 0);
+ }
+ }
}
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
Comment placeholder;
@@ -1128,6 +1147,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).expandButton.setText("");
((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
+ params.setMargins(0, 0, 0, 0);
}
}
@@ -1246,8 +1267,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
if (mShowCommentDivider) {
- commentDivider.setBackgroundColor(mDividerColor);
- commentDivider.setVisibility(View.VISIBLE);
+ if (mDividerType == DIVIDER_NORMAL) {
+ commentDivider.setBackgroundColor(mDividerColor);
+ commentDivider.setVisibility(View.VISIBLE);
+ }
}
if (mActivity.typeface != null) {
@@ -1749,8 +1772,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
commentTimeTextView.setTextColor(mSecondaryTextColor);
if (mShowCommentDivider) {
- commentDivider.setBackgroundColor(mDividerColor);
- commentDivider.setVisibility(View.VISIBLE);
+ if (mDividerType == DIVIDER_NORMAL) {
+ commentDivider.setBackgroundColor(mDividerColor);
+ commentDivider.setVisibility(View.VISIBLE);
+ }
}
if (mShowAuthorAvatar) {
@@ -1801,7 +1826,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
ButterKnife.bind(this, itemView);
if (mShowCommentDivider) {
- commentDivider.setVisibility(View.VISIBLE);
+ if (mDividerType == DIVIDER_NORMAL) {
+ commentDivider.setBackgroundColor(mDividerColor);
+ commentDivider.setVisibility(View.VISIBLE);
+ }
}
if (mActivity.typeface != null) {
@@ -1809,7 +1837,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
itemView.setBackgroundColor(mCommentBackgroundColor);
placeholderTextView.setTextColor(mPrimaryTextColor);
- commentDivider.setBackgroundColor(mDividerColor);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java
index 2c350305..386e2827 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java
@@ -3,7 +3,9 @@ package ml.docilealligator.infinityforreddit.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
+import androidx.preference.ListPreference;
import androidx.preference.SeekBarPreference;
+import androidx.preference.SwitchPreference;
import javax.inject.Inject;
import javax.inject.Named;
@@ -25,8 +27,18 @@ public class CommentPreferenceFragment extends CustomFontPreferenceFragmentCompa
((Infinity) activity.getApplication()).getAppComponent().inject(this);
+ SwitchPreference showCommentDividerSwitchPreference = findPreference(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER);
+ ListPreference commentDividerTypeListPreference = findPreference(SharedPreferencesUtils.COMMENT_DIVIDER_TYPE);
SeekBarPreference showFewerToolbarOptionsThresholdSeekBarPreference = findPreference(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD);
+ if (showCommentDividerSwitchPreference != null && commentDividerTypeListPreference != null) {
+ commentDividerTypeListPreference.setVisible(sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false));
+ showCommentDividerSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ commentDividerTypeListPreference.setVisible((Boolean) newValue);
+ return true;
+ });
+ }
+
if (showFewerToolbarOptionsThresholdSeekBarPreference != null) {
showFewerToolbarOptionsThresholdSeekBarPreference.setSummary(getString(R.string.settings_show_fewer_toolbar_options_threshold_summary, sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5)));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index 0cf4ba52..389bcf83 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -215,6 +215,7 @@ public class SharedPreferencesUtils {
public static final String REDDIT_VIDEO_DEFAULT_RESOLUTION = "reddit_video_default_resolution";
public static final String EASIER_TO_WATCH_IN_FULL_SCREEN = "easier_to_watch_in_full_screen";
public static final String HIDE_THE_NUMBER_OF_VOTES_IN_COMMENTS = "hide_the_number_of_votes_in_comments";
+ public static final String COMMENT_DIVIDER_TYPE = "comment_divider_type";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";