mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2026-02-23 17:25:28 +00:00
Continue adding comment filter.
This commit is contained in:
@ -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)");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user