diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-10-19 04:00:27 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-10-19 04:00:27 +0000 |
commit | 3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7 (patch) | |
tree | d594628099ae183483abd18cbc72c6a077d20265 /app/src/main/java/ml/docilealligator | |
parent | 2af02771d10546fc52711208871face9dc29d854 (diff) | |
download | infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.tar infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.tar.gz infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.tar.bz2 infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.tar.lz infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.tar.xz infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.tar.zst infinity-for-reddit-3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7.zip |
Continue adding comment filter.
Diffstat (limited to '')
5 files changed, 22 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java index 16f8b2d8..59639054 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java @@ -499,9 +499,7 @@ public class CustomizePostFilterActivity extends BaseActivity { if (typeface != null) { Utils.setFontToAllTextViews(coordinatorLayout, typeface); } - } - - public void setCursorDrawableColor(EditText editText, int color) { + } void setCursorDrawableColor(EditText editText, int color) { try { Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes"); fCursorDrawableRes.setAccessible(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java index 5d1ad217..090cd27c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java @@ -32,9 +32,9 @@ public class CommentFilterUsageEmbeddedRecyclerViewAdapter extends RecyclerView. @Override public void onBindViewHolder(@NonNull EntryViewHolder holder, int position) { if (commentFilterUsageList == null || commentFilterUsageList.isEmpty()) { - holder.textView.setText(R.string.click_to_apply_post_filter); + holder.textView.setText(R.string.comment_filter_applied_to_all_subreddits); } else if (holder.getBindingAdapterPosition() > 4) { - holder.textView.setText(baseActivity.getString(R.string.post_filter_usage_embedded_more_count, commentFilterUsageList.size() - 5)); + holder.textView.setText(baseActivity.getString(R.string.comment_filter_usage_embedded_more_count, commentFilterUsageList.size() - 5)); } else { CommentFilterUsage commentFilterUsage = commentFilterUsageList.get(holder.getBindingAdapterPosition()); switch (commentFilterUsage.usage) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterWithUsageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterWithUsageRecyclerViewAdapter.java index 48fd090f..914c64f2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterWithUsageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterWithUsageRecyclerViewAdapter.java @@ -39,14 +39,14 @@ public class CommentFilterWithUsageRecyclerViewAdapter extends RecyclerView.Adap @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof CommentFilterViewHolder) { - ((CommentFilterViewHolder) holder).binding.commentFilterNameTextViewItemCommentFilter.setText(commentFilterWithUsageList.get(position - 1).commentFilter.name); - ((CommentFilterViewHolder) holder).adapter.setCommentFilterUsageList(commentFilterWithUsageList.get(position - 1).commentFilterUsageList); + ((CommentFilterViewHolder) holder).binding.commentFilterNameTextViewItemCommentFilter.setText(commentFilterWithUsageList.get(position).commentFilter.name); + ((CommentFilterViewHolder) holder).adapter.setCommentFilterUsageList(commentFilterWithUsageList.get(position).commentFilterUsageList); } } @Override public int getItemCount() { - return commentFilterWithUsageList == null ? 1 : 1 + commentFilterWithUsageList.size(); + return commentFilterWithUsageList == null ? 0 : commentFilterWithUsageList.size(); } public void setCommentFilterWithUsageList(List<CommentFilterWithUsage> commentFilterWithUsageList) { @@ -68,7 +68,7 @@ public class CommentFilterWithUsageRecyclerViewAdapter extends RecyclerView.Adap } binding.getRoot().setOnClickListener(view -> { - onItemClickListener.onItemClick(commentFilterWithUsageList.get(getBindingAdapterPosition() - 1).commentFilter); + onItemClickListener.onItemClick(commentFilterWithUsageList.get(getBindingAdapterPosition()).commentFilter); }); binding.commentFilterUsageRecyclerViewItemCommentFilter.setRecycledViewPool(recycledViewPool); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java index 284ab852..37126ab6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java @@ -9,6 +9,7 @@ import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.biometric.BiometricManager; import androidx.preference.Preference; @@ -17,6 +18,7 @@ import javax.inject.Named; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.activities.CommentFilterPreferenceActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity; import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat; @@ -35,6 +37,7 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat { Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY); Preference postFilterPreference = findPreference(SharedPreferencesUtils.POST_FILTER); + Preference commentFilterPreference = findPreference(SharedPreferencesUtils.COMMENT_FILTER); Preference privacyPolicyPreference = findPreference(SharedPreferencesUtils.PRIVACY_POLICY_KEY); Preference redditUserAgreementPreference = findPreference(SharedPreferencesUtils.REDDIT_USER_AGREEMENT_KEY); @@ -53,6 +56,17 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat { }); } + if (commentFilterPreference != null) { + commentFilterPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(@NonNull Preference preference) { + Intent intent = new Intent(activity, CommentFilterPreferenceActivity.class); + activity.startActivity(intent); + return true; + } + }); + } + if (privacyPolicyPreference != null) { privacyPolicyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override 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 baef18de..0fe8c0ce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -218,6 +218,7 @@ public class SharedPreferencesUtils { 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 SUBSCRIBED_THINGS_SYNC_TIME = "subscribed_things_sync_time"; + public static final String COMMENT_FILTER = "comment_filter"; 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"; |