aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-10-16 03:37:16 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-10-16 03:37:16 +0000
commitb4afc015cddecad8a68f9b77c8a20bcc2538092e (patch)
tree13b037df07fbf75c9b8296f098f5096a8dd23e85
parent45b4ecf6ac2882bcdd597e0a40f3d04c197721c3 (diff)
downloadinfinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.tar
infinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.tar.gz
infinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.tar.bz2
infinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.tar.lz
infinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.tar.xz
infinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.tar.zst
infinity-for-reddit-b4afc015cddecad8a68f9b77c8a20bcc2538092e.zip
Continue adding comment filter.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterDao.java43
2 files changed, 54 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index ac76b6c9..c9eeba48 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -13,6 +13,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.account.AccountDao;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilter;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeDao;
import ml.docilealligator.infinityforreddit.multireddit.AnonymousMultiredditSubreddit;
@@ -38,7 +39,7 @@ import ml.docilealligator.infinityforreddit.user.UserData;
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
- ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class}, version = 24)
+ ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class, CommentFilter.class}, version = 25)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
public static RedditDataRoomDatabase create(final Context context) {
@@ -49,7 +50,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
- MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24)
+ MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25)
.build();
}
@@ -391,4 +392,12 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE custom_themes ADD COLUMN read_post_filled_card_view_background_color INTEGER DEFAULT " + Color.parseColor("#F5F5F5") + " NOT NULL");
}
};
+
+ private static final Migration MIGRATION_24_25 = new Migration(24, 25) {
+ @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)");
+ }
+ };
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterDao.java
index 944663f1..ea079722 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterDao.java
@@ -1,4 +1,47 @@
package ml.docilealligator.infinityforreddit.commentfilter;
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.OnConflictStrategy;
+import androidx.room.Query;
+import androidx.room.Transaction;
+
+import java.util.List;
+
+@Dao
public interface CommentFilterDao {
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
+ void insert(CommentFilter CommentFilter);
+
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
+ void insertAll(List<CommentFilter> CommentFilters);
+
+ @Query("DELETE FROM comment_filter")
+ void deleteAllCommentFilters();
+
+ @Delete
+ void deleteCommentFilter(CommentFilter CommentFilter);
+
+ @Query("DELETE FROM comment_filter WHERE name = :name")
+ void deleteCommentFilter(String name);
+
+ @Query("SELECT * FROM comment_filter WHERE name = :name LIMIT 1")
+ CommentFilter getCommentFilter(String name);
+
+ @Query("SELECT * FROM comment_filter ORDER BY name")
+ LiveData<List<CommentFilter>> getAllCommentFiltersLiveData();
+
+ @Query("SELECT * FROM comment_filter")
+ List<CommentFilter> getAllCommentFilters();
+
+ /*@Query("SELECT * FROM comment_filter WHERE comment_filter.name IN " +
+ "(SELECT comment_filter_usage.name FROM comment_filter_usage WHERE (usage = :usage AND name_of_usage = :nameOfUsage) " +
+ "OR (usage =:usage AND name_of_usage = '--'))")
+ List<CommentFilter> getValidCommentFilters(int usage, String nameOfUsage);*/
+
+ @Transaction
+ @Query("SELECT * FROM comment_filter ORDER BY name")
+ public LiveData<List<CommentFilterWithUsage>> getAllCommentFilterWithUsageLiveData();
}