add room infra
Signed-off-by: androidacy-user <opensource@androidacy.com>pull/89/head
parent
a030dfe2b0
commit
1e8e7da065
@ -0,0 +1,3 @@
|
||||
# assets/*.db are binary
|
||||
|
||||
*.db binary
|
Binary file not shown.
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
|
||||
*/
|
||||
|
||||
package com.fox2code.mmm.utils.room
|
||||
|
||||
import androidx.room.Entity
|
||||
|
||||
@Suppress("unused")
|
||||
@Entity(tableName = "modulelistcache")
|
||||
class ModuleListCache (
|
||||
var codename: String,
|
||||
var version: String,
|
||||
var versionCode: Int,
|
||||
var author: String,
|
||||
var description: String,
|
||||
var minApi: Int,
|
||||
var maxApi: Int,
|
||||
var minMagisk: Int,
|
||||
var needRamdisk: Boolean,
|
||||
var support: String,
|
||||
var donate: String,
|
||||
var config: String,
|
||||
var changeBoot: Boolean,
|
||||
var mmtReborn: Boolean,
|
||||
var repoId: String,
|
||||
var lastUpdate: Long
|
||||
) {
|
||||
// functions:
|
||||
// getAll(): List<ModuleListCache>
|
||||
// getByCodename(codename: String): ModuleListCache
|
||||
// insert(moduleListCache: ModuleListCache)
|
||||
// update(moduleListCache: ModuleListCache)
|
||||
// delete(moduleListCache: ModuleListCache)
|
||||
// deleteAll()
|
||||
// count(): Int
|
||||
|
||||
// get fun
|
||||
// getVersion(codename: String): String
|
||||
// getVersionCode(codename: String): Int
|
||||
// getAuthor(codename: String): String
|
||||
// getDescription(codename: String): String
|
||||
// getMinApi(codename: String): Int
|
||||
// getMaxApi(codename: String): Int
|
||||
// getMinMagisk(codename: String): Int
|
||||
// getNeedRamdisk(codename: String): Boolean
|
||||
// getSupport(codename: String): String
|
||||
// getDonate(codename: String): String
|
||||
// getConfig(codename: String): String
|
||||
// getChangeBoot(codename: String): Boolean
|
||||
// getMmtReborn(codename: String): Boolean
|
||||
// getRepoId(codename: String): String
|
||||
// getLastUpdate(codename: String): Long
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
|
||||
*/
|
||||
|
||||
package com.fox2code.mmm.utils.room
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
|
||||
|
||||
// contains
|
||||
// codename (string, primary), version (string), versionCode (int), author (string), description (string), minApi (int), maxApi (int), minMagisk (int), needRamdisk (boolean), support (string), donate (string), config (string), changeBoot (bool), mmtReborn (bool), repoId (string), lastUpdate (bigint)
|
||||
@Suppress("unused")
|
||||
@Dao
|
||||
interface ModuleListCacheDao {
|
||||
// functions:
|
||||
// getAll(): List<ModuleListCache>
|
||||
// getByRepoId(repoId: String): List<ModuleListCache>
|
||||
// getByCodename(codename: String): ModuleListCache
|
||||
// insert(moduleListCache: ModuleListCache)
|
||||
// update(moduleListCache: ModuleListCache)
|
||||
// delete(moduleListCache: ModuleListCache)
|
||||
// deleteAll()
|
||||
// count(): Int
|
||||
|
||||
// get fun
|
||||
// getVersion(codename: String): String
|
||||
// getVersionCode(codename: String): Int
|
||||
// getAuthor(codename: String): String
|
||||
// getDescription(codename: String): String
|
||||
// getMinApi(codename: String): Int
|
||||
// getMaxApi(codename: String): Int
|
||||
// getMinMagisk(codename: String): Int
|
||||
// getNeedRamdisk(codename: String): Boolean
|
||||
// getSupport(codename: String): String
|
||||
// getDonate(codename: String): String
|
||||
// getConfig(codename: String): String
|
||||
// getChangeBoot(codename: String): Boolean
|
||||
// getMmtReborn(codename: String): Boolean
|
||||
// getRepoId(codename: String): String
|
||||
// getLastUpdate(codename: String): Long
|
||||
|
||||
// set fun
|
||||
// setVersion(codename: String, version: String)
|
||||
// setVersionCode(codename: String, versionCode: Int)
|
||||
// setAuthor(codename: String, author: String)
|
||||
// setDescription(codename: String, description: String)
|
||||
// setMinApi(codename: String, minApi: Int)
|
||||
// setMaxApi(codename: String, maxApi: Int)
|
||||
// setMinMagisk(codename: String, minMagisk: Int)
|
||||
// setNeedRamdisk(codename: String, needRamdisk: Boolean)
|
||||
// setSupport(codename: String, support: String)
|
||||
// setDonate(codename: String, donate: String)
|
||||
// setConfig(codename: String, config: String)
|
||||
// setChangeBoot(codename: String, changeBoot: Boolean)
|
||||
// setMmtReborn(codename: String, mmtReborn: Boolean)
|
||||
// setRepoId(codename: String, repoId: String)
|
||||
// setLastUpdate(codename: String, lastUpdate: Long)
|
||||
|
||||
@Query("SELECT * FROM modulelistcache")
|
||||
fun getAll(): List<ModuleListCache>
|
||||
|
||||
@Query("SELECT * FROM modulelistcache WHERE repoId = :repoId")
|
||||
fun getByRepoId(repoId: String): List<ModuleListCache>
|
||||
|
||||
@Query("SELECT * FROM modulelistcache WHERE codename = :codename")
|
||||
fun getByCodename(codename: String): ModuleListCache
|
||||
|
||||
@Query("INSERT INTO modulelistcache VALUES (:codename, :version, :versionCode, :author, :description, :minApi, :maxApi, :minMagisk, :needRamdisk, :support, :donate, :config, :changeBoot, :mmtReborn, :repoId, :lastUpdate)")
|
||||
fun insert(codename: String, version: String, versionCode: Int, author: String, description: String, minApi: Int, maxApi: Int, minMagisk: Int, needRamdisk: Boolean, support: String, donate: String, config: String, changeBoot: Boolean, mmtReborn: Boolean, repoId: String, lastUpdate: Long)
|
||||
|
||||
@Query("UPDATE modulelistcache SET version = :version WHERE codename = :codename")
|
||||
fun setVersion(codename: String, version: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET versionCode = :versionCode WHERE codename = :codename")
|
||||
fun setVersionCode(codename: String, versionCode: Int)
|
||||
|
||||
@Query("UPDATE modulelistcache SET author = :author WHERE codename = :codename")
|
||||
fun setAuthor(codename: String, author: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET description = :description WHERE codename = :codename")
|
||||
fun setDescription(codename: String, description: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET minApi = :minApi WHERE codename = :codename")
|
||||
fun setMinApi(codename: String, minApi: Int)
|
||||
|
||||
@Query("UPDATE modulelistcache SET maxApi = :maxApi WHERE codename = :codename")
|
||||
fun setMaxApi(codename: String, maxApi: Int)
|
||||
|
||||
@Query("UPDATE modulelistcache SET minMagisk = :minMagisk WHERE codename = :codename")
|
||||
fun setMinMagisk(codename: String, minMagisk: Int)
|
||||
|
||||
@Query("UPDATE modulelistcache SET needRamdisk = :needRamdisk WHERE codename = :codename")
|
||||
fun setNeedRamdisk(codename: String, needRamdisk: Boolean)
|
||||
|
||||
@Query("UPDATE modulelistcache SET support = :support WHERE codename = :codename")
|
||||
fun setSupport(codename: String, support: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET donate = :donate WHERE codename = :codename")
|
||||
fun setDonate(codename: String, donate: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET config = :config WHERE codename = :codename")
|
||||
fun setConfig(codename: String, config: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET changeBoot = :changeBoot WHERE codename = :codename")
|
||||
fun setChangeBoot(codename: String, changeBoot: Boolean)
|
||||
|
||||
@Query("UPDATE modulelistcache SET mmtReborn = :mmtReborn WHERE codename = :codename")
|
||||
fun setMmtReborn(codename: String, mmtReborn: Boolean)
|
||||
|
||||
@Query("UPDATE modulelistcache SET repoId = :repoId WHERE codename = :codename")
|
||||
fun setRepoId(codename: String, repoId: String)
|
||||
|
||||
@Query("UPDATE modulelistcache SET lastUpdate = :lastUpdate WHERE codename = :codename")
|
||||
fun setLastUpdate(codename: String, lastUpdate: Long)
|
||||
|
||||
@Query("DELETE FROM modulelistcache WHERE codename = :codename")
|
||||
fun delete(codename: String)
|
||||
|
||||
@Query("DELETE FROM modulelistcache")
|
||||
fun deleteAll()
|
||||
|
||||
@Query("SELECT COUNT(*) FROM modulelistcache")
|
||||
fun count(): Int
|
||||
|
||||
@Query("SELECT version FROM modulelistcache WHERE codename = :codename")
|
||||
fun getVersion(codename: String): String
|
||||
|
||||
@Query("SELECT versionCode FROM modulelistcache WHERE codename = :codename")
|
||||
fun getVersionCode(codename: String): Int
|
||||
|
||||
@Query("SELECT author FROM modulelistcache WHERE codename = :codename")
|
||||
fun getAuthor(codename: String): String
|
||||
|
||||
@Query("SELECT description FROM modulelistcache WHERE codename = :codename")
|
||||
fun getDescription(codename: String): String
|
||||
|
||||
@Query("SELECT minApi FROM modulelistcache WHERE codename = :codename")
|
||||
fun getMinApi(codename: String): Int
|
||||
|
||||
@Query("SELECT maxApi FROM modulelistcache WHERE codename = :codename")
|
||||
fun getMaxApi(codename: String): Int
|
||||
|
||||
@Query("SELECT minMagisk FROM modulelistcache WHERE codename = :codename")
|
||||
fun getMinMagisk(codename: String): Int
|
||||
|
||||
@Query("SELECT needRamdisk FROM modulelistcache WHERE codename = :codename")
|
||||
fun getNeedRamdisk(codename: String): Boolean
|
||||
|
||||
@Query("SELECT support FROM modulelistcache WHERE codename = :codename")
|
||||
fun getSupport(codename: String): String
|
||||
|
||||
@Query("SELECT donate FROM modulelistcache WHERE codename = :codename")
|
||||
fun getDonate(codename: String): String
|
||||
|
||||
@Query("SELECT config FROM modulelistcache WHERE codename = :codename")
|
||||
fun getConfig(codename: String): String
|
||||
|
||||
@Query("SELECT changeBoot FROM modulelistcache WHERE codename = :codename")
|
||||
fun getChangeBoot(codename: String): Boolean
|
||||
|
||||
@Query("SELECT mmtReborn FROM modulelistcache WHERE codename = :codename")
|
||||
fun getMmtReborn(codename: String): Boolean
|
||||
|
||||
@Query("SELECT repoId FROM modulelistcache WHERE codename = :codename")
|
||||
fun getRepoId(codename: String): String
|
||||
|
||||
@Query("SELECT lastUpdate FROM modulelistcache WHERE codename = :codename")
|
||||
fun getLastUpdate(codename: String): Long
|
||||
|
||||
@Query("SELECT * FROM modulelistcache WHERE codename = :codename")
|
||||
fun get(codename: String): ModuleListCache
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
|
||||
*/
|
||||
|
||||
package com.fox2code.mmm.utils.room
|
||||
|
||||
import androidx.room.Database
|
||||
|
||||
@Suppress("unused")
|
||||
@Database(entities = [ModuleListCache::class], version = 1)
|
||||
abstract class ModuleListCacheDatabase {
|
||||
abstract fun moduleListCacheDao(): ModuleListCacheDao
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
|
||||
*/
|
||||
|
||||
package com.fox2code.mmm.utils.room
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "ReposList")
|
||||
data class ReposList(
|
||||
@PrimaryKey var id: String,
|
||||
var url: String,
|
||||
var enabled: Boolean,
|
||||
var donate: String,
|
||||
var support: String,
|
||||
var submitModule: String,
|
||||
var lastUpdate: Long,
|
||||
var name: String,
|
||||
var website: String
|
||||
)
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
|
||||
*/
|
||||
|
||||
package com.fox2code.mmm.utils.room
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
|
||||
@Suppress("unused")
|
||||
@Dao
|
||||
interface ReposListDao {
|
||||
// contains
|
||||
// id (string, primary), url (string), enabled (boolean), donate (string), support (string), submitMoulde (string), lastUpdate (bigint), name (string) and website (string)
|
||||
|
||||
// functions:
|
||||
// getAll(): List<ReposList>
|
||||
// getById(id: String): ReposList
|
||||
// insert(reposList: ReposList)
|
||||
// update(reposList: ReposList)
|
||||
// delete(reposList: ReposList)
|
||||
|
||||
@Query("SELECT * FROM ReposList")
|
||||
fun getAll(): List<ReposList>
|
||||
|
||||
@Query("SELECT * FROM ReposList WHERE id = :id")
|
||||
fun getById(id: String): ReposList
|
||||
|
||||
@Query("INSERT INTO ReposList VALUES (:id, :url, :enabled, :donate, :support, :submitModule, :lastUpdate, :name, :website)")
|
||||
fun insert(id: String, url: String, enabled: Boolean, donate: String, support: String, submitModule: String, lastUpdate: Long, name: String, website: String)
|
||||
|
||||
@Query("UPDATE ReposList SET url = :url, enabled = :enabled, donate = :donate, support = :support, submitModule = :submitModule, lastUpdate = :lastUpdate, name = :name, website = :website WHERE id = :id")
|
||||
fun update(id: String, url: String, enabled: Boolean, donate: String, support: String, submitModule: String, lastUpdate: Long, name: String, website: String)
|
||||
|
||||
@Query("DELETE FROM ReposList WHERE id = :id")
|
||||
fun delete(id: String)
|
||||
|
||||
@Query("DELETE FROM ReposList")
|
||||
fun deleteAll()
|
||||
|
||||
@Query("SELECT COUNT(*) FROM ReposList")
|
||||
fun count(): Int
|
||||
|
||||
// get fun
|
||||
@Query("SELECT url FROM ReposList WHERE id = :id")
|
||||
fun getUrl(id: String): String
|
||||
|
||||
@Query("SELECT enabled FROM ReposList WHERE id = :id")
|
||||
fun getEnabled(id: String): Boolean
|
||||
|
||||
@Query("SELECT donate FROM ReposList WHERE id = :id")
|
||||
fun getDonate(id: String): String
|
||||
|
||||
@Query("SELECT support FROM ReposList WHERE id = :id")
|
||||
fun getSupport(id: String): String
|
||||
|
||||
@Query("SELECT submitModule FROM ReposList WHERE id = :id")
|
||||
fun getSubmitModule(id: String): String
|
||||
|
||||
@Query("SELECT lastUpdate FROM ReposList WHERE id = :id")
|
||||
fun getLastUpdate(id: String): Long
|
||||
|
||||
@Query("SELECT name FROM ReposList WHERE id = :id")
|
||||
fun getName(id: String): String
|
||||
|
||||
@Query("SELECT website FROM ReposList WHERE id = :id")
|
||||
fun getWebsite(id: String): String
|
||||
|
||||
// set fun
|
||||
@Query("UPDATE ReposList SET url = :url WHERE id = :id")
|
||||
fun setUrl(id: String, url: String)
|
||||
|
||||
@Query("UPDATE ReposList SET enabled = :enabled WHERE id = :id")
|
||||
fun setEnabled(id: String, enabled: Boolean)
|
||||
|
||||
@Query("UPDATE ReposList SET donate = :donate WHERE id = :id")
|
||||
fun setDonate(id: String, donate: String)
|
||||
|
||||
@Query("UPDATE ReposList SET support = :support WHERE id = :id")
|
||||
fun setSupport(id: String, support: String)
|
||||
|
||||
@Query("UPDATE ReposList SET submitModule = :submitModule WHERE id = :id")
|
||||
fun setSubmitModule(id: String, submitModule: String)
|
||||
|
||||
@Query("UPDATE ReposList SET lastUpdate = :lastUpdate WHERE id = :id")
|
||||
fun setLastUpdate(id: String, lastUpdate: Long)
|
||||
|
||||
@Query("UPDATE ReposList SET name = :name WHERE id = :id")
|
||||
fun setName(id: String, name: String)
|
||||
|
||||
@Query("UPDATE ReposList SET website = :website WHERE id = :id")
|
||||
fun setWebsite(id: String, website: String)
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
|
||||
*/
|
||||
|
||||
package com.fox2code.mmm.utils.room
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Suppress("unused")
|
||||
@Database(entities = [ReposList::class], version = 1)
|
||||
abstract class ReposListDatabase : RoomDatabase() {
|
||||
abstract fun reposListDao(): ReposListDao
|
||||
}
|
Loading…
Reference in New Issue