From 2863bac0111daddf3e1d762be6266a525f59e95f Mon Sep 17 00:00:00 2001
From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>
Date: Wed, 17 Jul 2024 21:31:05 -0400
Subject: Add an entry for Display mode in CustomizeCommentFilterActivity.
---
.../activities/CustomizeCommentFilterActivity.java | 17 +++++++++++++++
.../commentfilter/CommentFilter.java | 2 ++
.../layout/activity_customize_comment_filter.xml | 25 ++++++++++++++++++++++
app/src/main/res/values/arrays.xml | 5 +++++
app/src/main/res/values/strings.xml | 4 ++++
5 files changed, 53 insertions(+)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java
index 95ebd9a2..668ea783 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java
@@ -11,6 +11,8 @@ import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@@ -138,6 +140,7 @@ public class CustomizeCommentFilterActivity extends BaseActivity {
private void bindView() {
binding.nameTextInputEditTextCustomizeCommentFilterActivity.setText(commentFilter.name);
+ binding.displayModeSpinnerCustomizeCommentFilterActivity.setSelection(commentFilter.displayMode == CommentFilter.DisplayMode.REMOVE_COMMENT ? 0 : 1);
binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.setText(commentFilter.excludeStrings);
binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.setText(commentFilter.excludeUsers);
binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.setText(Integer.toString(commentFilter.minVote));
@@ -179,6 +182,18 @@ public class CustomizeCommentFilterActivity extends BaseActivity {
binding.nameTextInputLayoutCustomizeCommentFilterActivity.setBoxStrokeColor(primaryTextColor);
binding.nameTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
binding.nameTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
+ binding.displayModeTitleTextViewCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
+ binding.displayModeSpinnerCustomizeCommentFilterActivity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ ((TextView) parent.getChildAt(0)).setTextColor(primaryTextColor);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+
+ }
+ });
binding.excludeStringsTextInputLayoutCustomizeCommentFilterActivity.setBoxStrokeColor(primaryTextColor);
binding.excludeStringsTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
@@ -299,6 +314,8 @@ public class CustomizeCommentFilterActivity extends BaseActivity {
private void constructCommentFilter() throws PatternSyntaxException {
commentFilter.name = binding.nameTextInputEditTextCustomizeCommentFilterActivity.getText().toString();
+ commentFilter.displayMode = binding.displayModeSpinnerCustomizeCommentFilterActivity.getSelectedItemPosition() == 0 ?
+ CommentFilter.DisplayMode.REMOVE_COMMENT : CommentFilter.DisplayMode.COLLAPSE_COMMENT;
commentFilter.excludeStrings = binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.getText().toString();
commentFilter.excludeUsers = binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.getText().toString();
commentFilter.maxVote = binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.getText() == null || binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.getText().toString().equals("") ? -1 : Integer.parseInt(binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.getText().toString());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java
index 796fd68d..4cce731d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java
@@ -38,6 +38,7 @@ public class CommentFilter implements Parcelable {
protected CommentFilter(Parcel in) {
name = in.readString();
+ displayMode = in.readInt();
maxVote = in.readInt();
minVote = in.readInt();
excludeStrings = in.readString();
@@ -120,6 +121,7 @@ public class CommentFilter implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeString(name);
+ dest.writeInt(displayMode);
dest.writeInt(maxVote);
dest.writeInt(minVote);
dest.writeString(excludeStrings);
diff --git a/app/src/main/res/layout/activity_customize_comment_filter.xml b/app/src/main/res/layout/activity_customize_comment_filter.xml
index 9153e01a..dbb24455 100644
--- a/app/src/main/res/layout/activity_customize_comment_filter.xml
+++ b/app/src/main/res/layout/activity_customize_comment_filter.xml
@@ -62,6 +62,31 @@
+
+
+
+
+
+
+
+
0
+
+ - @string/comment_filter_display_mode_remove_comments
+ - @string/comment_filter_display_mode_fully_collapse_comments
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 039627dd..5f772352 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1401,5 +1401,9 @@
Emote
None
+ Display mode
+ Remove comments
+ Fully collapse comments
+
--
cgit v1.2.3