Add API to control online search

This commit is contained in:
MM20
2024-01-28 21:35:36 +01:00
parent d7340c485b
commit 426473e397
20 changed files with 44 additions and 36 deletions
@@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.map
class FakeAppRepository(private val context: Context, private val fakePackages: Int) : SearchableRepository<Application> {
override fun search(query: String): Flow<ImmutableList<Application>> {
override fun search(query: String, allowNetwork: Boolean): Flow<ImmutableList<Application>> {
return if (query.isEmpty()) {
buildList {
repeat(fakePackages) {
@@ -29,8 +29,6 @@ import org.apache.commons.text.similarity.FuzzyScore
import java.util.Locale
interface AppRepository : SearchableRepository<Application> {
override fun search(query: String): Flow<ImmutableList<Application>>
fun findMany(): Flow<ImmutableList<Application>>
}
@@ -197,7 +195,7 @@ internal class AppRepositoryImpl(
return installedApps.map { it.toImmutableList() }
}
override fun search(query: String): Flow<ImmutableList<LauncherApp>> {
override fun search(query: String, allowNetwork: Boolean): Flow<ImmutableList<LauncherApp>> {
return installedApps.map { apps ->
withContext(Dispatchers.Default) {
val appResults = mutableListOf<LauncherApp>()