Added missing repositories

This commit is contained in:
Viktor De Pasquale 2019-05-10 19:13:15 +02:00
parent d39d885ec2
commit 2624706c69
7 changed files with 43 additions and 6 deletions

View File

@ -52,7 +52,6 @@ class PolicyDao(
}
fun update(policy: MagiskPolicy) = query<Replace> {
values(policy.toMap())
}.ignoreElement()

View File

@ -2,7 +2,7 @@ package com.topjohnwu.magisk.data.database
import com.topjohnwu.magisk.data.database.base.*
class StringsDao : BaseDao() {
class StringDao : BaseDao() {
override val table = DatabaseDefinition.Table.STRINGS

View File

@ -0,0 +1,15 @@
package com.topjohnwu.magisk.data.repository
import com.topjohnwu.magisk.data.database.PolicyDao
import com.topjohnwu.magisk.model.entity.MagiskPolicy
class AppRepository(private val policyDao: PolicyDao) {
fun deleteOutdated() = policyDao.deleteOutdated()
fun delete(packageName: String) = policyDao.delete(packageName)
fun delete(uid: Int) = policyDao.delete(uid)
fun fetch(uid: Int) = policyDao.fetch(uid)
fun fetchAll() = policyDao.fetchAll()
fun update(policy: MagiskPolicy) = policyDao.update(policy)
}

View File

@ -0,0 +1,11 @@
package com.topjohnwu.magisk.data.repository
import com.topjohnwu.magisk.data.database.SettingsDao
class SettingRepository(private val settingsDao: SettingsDao) {
fun fetch(key: String) = settingsDao.fetch(key)
fun put(key: String, value: Int) = settingsDao.put(key, value)
fun delete(key: String) = settingsDao.delete(key)
}

View File

@ -0,0 +1,11 @@
package com.topjohnwu.magisk.data.repository
import com.topjohnwu.magisk.data.database.StringDao
class StringRepository(private val stringDao: StringDao) {
fun fetch(key: String) = stringDao.fetch(key)
fun put(key: String, value: String) = stringDao.put(key, value)
fun delete(key: String) = stringDao.delete(key)
}

View File

@ -13,7 +13,7 @@ val databaseModule = module {
single { LogDao() }
single { PolicyDao(get()) }
single { SettingsDao() }
single { StringsDao() }
single { StringDao() }
single { createRepositoryDao(get()) }
}

View File

@ -1,8 +1,6 @@
package com.topjohnwu.magisk.di
import com.topjohnwu.magisk.data.repository.LogRepository
import com.topjohnwu.magisk.data.repository.MagiskRepository
import com.topjohnwu.magisk.data.repository.ModuleRepository
import com.topjohnwu.magisk.data.repository.*
import org.koin.dsl.module
@ -10,4 +8,7 @@ val repositoryModule = module {
single { MagiskRepository(get(), get(), get()) }
single { ModuleRepository(get(), get(), get(), get()) }
single { LogRepository(get()) }
single { AppRepository(get()) }
single { SettingRepository(get()) }
single { StringRepository(get()) }
}