+4
-6
@@ -1,5 +1,6 @@
|
||||
package de.mm20.launcher2.data.customattrs
|
||||
|
||||
import de.mm20.launcher2.backup.Backupable
|
||||
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||
import de.mm20.launcher2.database.AppDatabase
|
||||
import de.mm20.launcher2.database.entities.CustomAttributeEntity
|
||||
@@ -18,7 +19,7 @@ import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import java.io.File
|
||||
|
||||
interface CustomAttributesRepository {
|
||||
interface CustomAttributesRepository: Backupable {
|
||||
|
||||
fun search(query: String): Flow<ImmutableList<SavableSearchable>>
|
||||
|
||||
@@ -32,9 +33,6 @@ interface CustomAttributesRepository {
|
||||
fun setTags(searchable: SavableSearchable, tags: List<String>)
|
||||
fun getTags(searchable: SavableSearchable): Flow<List<String>>
|
||||
|
||||
suspend fun export(toDir: File)
|
||||
suspend fun import(fromDir: File)
|
||||
|
||||
fun getAllTags(startsWith: String? = null): Flow<List<String>>
|
||||
fun getItemsForTag(tag: String): Flow<List<SavableSearchable>>
|
||||
fun setItemsForTag(tag: String, items: List<SavableSearchable>): Job
|
||||
@@ -188,7 +186,7 @@ internal class CustomAttributesRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun export(toDir: File) = withContext(Dispatchers.IO) {
|
||||
override suspend fun backup(toDir: File) = withContext(Dispatchers.IO) {
|
||||
val dao = appDatabase.backupDao()
|
||||
var page = 0
|
||||
do {
|
||||
@@ -212,7 +210,7 @@ internal class CustomAttributesRepositoryImpl(
|
||||
} while (customAttrs.size == 100)
|
||||
}
|
||||
|
||||
override suspend fun import(fromDir: File) = withContext(Dispatchers.IO) {
|
||||
override suspend fun restore(fromDir: File) = withContext(Dispatchers.IO) {
|
||||
val dao = appDatabase.backupDao()
|
||||
dao.wipeCustomAttributes()
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package de.mm20.launcher2.data.customattrs
|
||||
|
||||
import de.mm20.launcher2.backup.Backupable
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
val customAttrsModule = module {
|
||||
single<CustomAttributesRepository> { CustomAttributesRepositoryImpl(get(), get()) }
|
||||
factory<Backupable>(named<CustomAttributesRepository>()) { CustomAttributesRepositoryImpl(get(), get()) }
|
||||
factory<CustomAttributesRepository> { CustomAttributesRepositoryImpl(get(), get()) }
|
||||
}
|
||||
Reference in New Issue
Block a user