aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-10-21 14:15:56 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-10-21 14:15:56 +0000
commit3d4bb32cbf55440e249c5c335131aeacb4067d19 (patch)
treead2ee051574248c494ada9845bf34a82c631b12a /app/src/main/java/ml/docilealligator/infinityforreddit
parentbfec1912bd30a4ec2d684dc2a54bae351dd601e2 (diff)
downloadinfinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.tar
infinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.tar.gz
infinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.tar.bz2
infinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.tar.lz
infinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.tar.xz
infinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.tar.zst
infinity-for-reddit-3d4bb32cbf55440e249c5c335131aeacb4067d19.zip
Remove USER_TYPE in CommentFilterUsage. Add exclude users in comment filter.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsage.java1
7 files changed, 19 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index e89a47dd..ffbbb703 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -405,7 +405,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE comment_filter " +
- "(name TEXT NOT NULL PRIMARY KEY, max_vote INTEGER NOT NULL, min_vote INTEGER NOT NULL, exclude_strings TEXT)");
+ "(name TEXT NOT NULL PRIMARY KEY, max_vote INTEGER NOT NULL, min_vote INTEGER NOT NULL, exclude_strings TEXT, exclude_users TEXT)");
database.execSQL("CREATE TABLE comment_filter_usage (name TEXT NOT NULL, usage INTEGER NOT NULL, " +
"name_of_usage TEXT NOT NULL, PRIMARY KEY(name, usage, name_of_usage), FOREIGN KEY(name) REFERENCES comment_filter(name) ON DELETE CASCADE)");
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
index b174e9e8..7a1d6662 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
@@ -94,7 +94,6 @@ public class CommentFilterUsageListingActivity extends BaseActivity {
public void newCommentFilterUsage(int type) {
switch (type) {
case CommentFilterUsage.SUBREDDIT_TYPE:
- case CommentFilterUsage.USER_TYPE:
editAndCommentFilterUsageNameOfUsage(type, null);
break;
}
@@ -119,10 +118,6 @@ public class CommentFilterUsageListingActivity extends BaseActivity {
case CommentFilterUsage.SUBREDDIT_TYPE:
textInputEditText.setHint(R.string.settings_tab_subreddit_name);
break;
- case CommentFilterUsage.USER_TYPE:
- textInputEditText.setHint(R.string.settings_tab_username);
- titleStringId = R.string.user;
- break;
}
Utils.showKeyboard(this, new Handler(), textInputEditText);
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 090cd27c..0f958e3e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageEmbeddedRecyclerViewAdapter.java
@@ -41,9 +41,6 @@ public class CommentFilterUsageEmbeddedRecyclerViewAdapter extends RecyclerView.
case CommentFilterUsage.SUBREDDIT_TYPE:
holder.textView.setText("r/" + commentFilterUsage.nameOfUsage);
break;
- case CommentFilterUsage.USER_TYPE:
- holder.textView.setText("u/" + commentFilterUsage.nameOfUsage);
- break;
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java
index a6f510fd..134e9c18 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java
@@ -45,9 +45,6 @@ public class CommentFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<
case CommentFilterUsage.SUBREDDIT_TYPE:
((CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_subreddit, commentFilterUsage.nameOfUsage));
break;
- case CommentFilterUsage.USER_TYPE:
- ((CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_user, commentFilterUsage.nameOfUsage));
- break;
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java
index 2ff59d2b..b74fc39a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java
@@ -32,11 +32,6 @@ public class NewCommentFilterUsageBottomSheetFragment extends LandscapeExpandedR
dismiss();
});
- binding.userTextViewNewCommentFilterUsageBottomSheetFragment.setOnClickListener(view -> {
- activity.newCommentFilterUsage(CommentFilterUsage.USER_TYPE);
- dismiss();
- });
-
if (activity.typeface != null) {
Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
}
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 49c60d23..93b65365 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilter.java
@@ -23,6 +23,8 @@ public class CommentFilter implements Parcelable {
public int minVote = -1;
@ColumnInfo(name = "exclude_strings")
public String excludeStrings;
+ @ColumnInfo(name = "exclude_users")
+ public String excludeUsers;
public CommentFilter() {
@@ -33,6 +35,7 @@ public class CommentFilter implements Parcelable {
maxVote = in.readInt();
minVote = in.readInt();
excludeStrings = in.readString();
+ excludeUsers = in.readString();
}
public static final Creator<CommentFilter> CREATOR = new Creator<CommentFilter>() {
@@ -62,6 +65,14 @@ public class CommentFilter implements Parcelable {
}
}
}
+ if (commentFilter.excludeUsers != null && !commentFilter.excludeUsers.equals("")) {
+ String[] users = commentFilter.excludeUsers.split(",", 0);
+ for (String u : users) {
+ if (!u.trim().equals("") && comment.getAuthor().equalsIgnoreCase(u.trim())) {
+ return false;
+ }
+ }
+ }
return true;
}
@@ -83,6 +94,12 @@ public class CommentFilter implements Parcelable {
stringBuilder.append(",").append(c.excludeStrings);
commentFilter.excludeStrings = stringBuilder.toString();
}
+
+ if (c.excludeUsers != null && !c.excludeUsers.equals("")) {
+ stringBuilder = new StringBuilder(commentFilter.excludeUsers == null ? "" : commentFilter.excludeUsers);
+ stringBuilder.append(",").append(c.excludeUsers);
+ commentFilter.excludeUsers = stringBuilder.toString();
+ }
}
return commentFilter;
@@ -99,5 +116,6 @@ public class CommentFilter implements Parcelable {
dest.writeInt(maxVote);
dest.writeInt(minVote);
dest.writeString(excludeStrings);
+ dest.writeString(excludeUsers);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsage.java
index 368452ce..87d5ef17 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsage.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsage.java
@@ -13,7 +13,6 @@ import androidx.room.ForeignKey;
childColumns = "name", onDelete = ForeignKey.CASCADE))
public class CommentFilterUsage implements Parcelable {
public static final int SUBREDDIT_TYPE = 1;
- public static final int USER_TYPE = 2;
@NonNull
@ColumnInfo(name = "name")