diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt b/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt index bd71f95c7..2298f228e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt @@ -52,7 +52,6 @@ class PolicyDao( } fun update(policy: MagiskPolicy) = query { - values(policy.toMap()) }.ignoreElement() diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/StringsDao.kt b/app/src/main/java/com/topjohnwu/magisk/data/database/StringDao.kt similarity index 94% rename from app/src/main/java/com/topjohnwu/magisk/data/database/StringsDao.kt rename to app/src/main/java/com/topjohnwu/magisk/data/database/StringDao.kt index 916c71d31..a1f7c03a1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/StringsDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/database/StringDao.kt @@ -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 diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/AppRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/AppRepository.kt new file mode 100644 index 000000000..9f5e6c587 --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/AppRepository.kt @@ -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) + +} \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/SettingRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/SettingRepository.kt new file mode 100644 index 000000000..5140ccc7a --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/SettingRepository.kt @@ -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) + +} \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/StringRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/StringRepository.kt new file mode 100644 index 000000000..0756cd63d --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/StringRepository.kt @@ -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) + +} \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt index 29b5dedaa..4a0b37d9d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt @@ -13,7 +13,7 @@ val databaseModule = module { single { LogDao() } single { PolicyDao(get()) } single { SettingsDao() } - single { StringsDao() } + single { StringDao() } single { createRepositoryDao(get()) } } diff --git a/app/src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt index bccccf18f..1c1383d52 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt @@ -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()) } }