mirror of https://github.com/readrops/Readrops.git
Add NotificationPermission entity
This commit is contained in:
parent
2f7fd36511
commit
4762828980
|
@ -125,3 +125,5 @@ Temporary Items
|
|||
|
||||
|
||||
\.idea/
|
||||
|
||||
readropsdb/schemas/
|
||||
|
|
|
@ -13,7 +13,8 @@ android {
|
|||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [
|
||||
"room.incremental": "true"
|
||||
"room.incremental" : "true",
|
||||
"room.schemaLocation": "$projectDir/schemas".toString()
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,15 @@ import com.readrops.readropsdb.dao.AccountDao;
|
|||
import com.readrops.readropsdb.dao.FeedDao;
|
||||
import com.readrops.readropsdb.dao.FolderDao;
|
||||
import com.readrops.readropsdb.dao.ItemDao;
|
||||
import com.readrops.readropsdb.dao.NotificationPermissionDao;
|
||||
import com.readrops.readropsdb.entities.NotificationPermission;
|
||||
import com.readrops.readropsdb.entities.account.Account;
|
||||
import com.readrops.readropsdb.entities.Feed;
|
||||
import com.readrops.readropsdb.entities.Folder;
|
||||
import com.readrops.readropsdb.entities.Item;
|
||||
|
||||
|
||||
@androidx.room.Database(entities = {Feed.class, Item.class, Folder.class, Account.class}, version = 1, exportSchema = false)
|
||||
@androidx.room.Database(entities = {Feed.class, Item.class, Folder.class, Account.class, NotificationPermission.class}, version = 2)
|
||||
@TypeConverters({Converters.class})
|
||||
public abstract class Database extends RoomDatabase {
|
||||
|
||||
|
@ -28,6 +30,8 @@ public abstract class Database extends RoomDatabase {
|
|||
|
||||
public abstract AccountDao accountDao();
|
||||
|
||||
public abstract NotificationPermissionDao notificationPermissionDao();
|
||||
|
||||
private static Database database;
|
||||
|
||||
public static Database getInstance(Context context) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.readrops.readropsdb.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import com.readrops.readropsdb.entities.NotificationPermission
|
||||
|
||||
@Dao
|
||||
interface NotificationPermissionDao : BaseDao<NotificationPermission> {
|
||||
|
||||
@Query("Select NotificationPermission.* From NotificationPermission Inner Join Feed Where Feed.id = NotificationPermission.feedId And Feed.account_id = :accountId")
|
||||
fun selectAll(accountId: Int) : List<NotificationPermission>
|
||||
|
||||
@Query("Update NotificationPermission set enabled = :enabled Where id = :id")
|
||||
fun setEnableState(id: Int, enabled: Boolean)
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.readrops.readropsdb.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(foreignKeys = [ForeignKey(entity = Feed::class, parentColumns = ["id"],
|
||||
childColumns = ["feedId"], onDelete = ForeignKey.CASCADE)])
|
||||
data class NotificationPermission(@PrimaryKey(autoGenerate = true) val id: Int,
|
||||
@ColumnInfo(index = true) val feedId: Int,
|
||||
val enabled: Boolean)
|
Loading…
Reference in New Issue