Loading app/build.gradle +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ android { buildTypes { debug { versionNameSuffix ".debug" applicationIdSuffix ".debug" // versionNameSuffix ".debug" // applicationIdSuffix ".debug" signingConfig signingConfigs.debugConfig proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } Loading app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +1 −1 Original line number Diff line number Diff line Loading @@ -1118,7 +1118,7 @@ class FusedApiImpl @Inject constructor( private suspend fun getGplaySearchResult( query: String, ): Flow<Pair<List<FusedApp>, Boolean>> { val searchResults = gplayRepository.getSearchResult(query) val searchResults = gplayRepository.getSearchResult(query, null) return searchResults.map { val fusedAppList = it.first.map { app -> replaceWithFDroid(app) } Pair( Loading app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepository.kt +2 −1 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import com.aurora.gplayapi.SearchSuggestEntry import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.Category import com.aurora.gplayapi.data.models.File import com.aurora.gplayapi.data.models.SearchBundle import foundation.e.apps.data.BaseStoreRepository import foundation.e.apps.data.fused.utils.CategoryType import kotlinx.coroutines.flow.Flow interface GplayStoreRepository : BaseStoreRepository { suspend fun getSearchResult(query: String): Flow<Pair<List<App>, Boolean>> suspend fun getSearchResult(query: String, subBundle: MutableSet<SearchBundle.SubBundle>?): Flow<Pair<List<App>, Boolean>> suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> suspend fun getAppsByCategory(category: String, pageUrl: String? = null): Any suspend fun getCategories(type: CategoryType? = null): List<Category> Loading app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +66 −36 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.withContext import timber.log.Timber import javax.inject.Inject class GplayStoreRepositoryImpl @Inject constructor( Loading Loading @@ -76,52 +77,81 @@ class GplayStoreRepositoryImpl @Inject constructor( context.getString(R.string.movers_shakers_games) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME), ) // override suspend fun getSearchResult( // query: String, // ): Flow<Pair<List<App>, Boolean>> { // return flow { // // /* // * Variable names and logic made same as that of Aurora store. // * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171 // */ // var authData = loginSourceRepository.gplayAuth ?: return@flow // // val searchHelper = // SearchHelper(authData).using(gPlayHttpClient) // val searchBundle = searchHelper.searchResults(query) // // val initialReplacedList = mutableListOf<App>() // val INITIAL_LIMIT = 4 // // emitReplacedList( // this@flow, // initialReplacedList, // INITIAL_LIMIT, // searchBundle, // true, // ) // // var nextSubBundleSet: MutableSet<SearchBundle.SubBundle> // do { // nextSubBundleSet = fetchNextSubBundle( // searchBundle, // searchHelper, // this@flow, // initialReplacedList, // INITIAL_LIMIT // ) // } while (nextSubBundleSet.isNotEmpty()) // // /* // * If initialReplacedList size is less than INITIAL_LIMIT, // * it means the results were very less and nothing has been emitted so far. // * Hence emit the list. // */ // if (initialReplacedList.size < INITIAL_LIMIT) { // emitInMain(this@flow, initialReplacedList, false) // } // }.flowOn(Dispatchers.IO) // } override suspend fun getSearchResult( query: String, subBundle: MutableSet<SearchBundle.SubBundle>? ): Flow<Pair<List<App>, Boolean>> { return flow { /* * Variable names and logic made same as that of Aurora store. * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171 */ var authData = loginSourceRepository.gplayAuth ?: return@flow val searchHelper = SearchHelper(authData).using(gPlayHttpClient) val searchBundle = searchHelper.searchResults(query) val initialReplacedList = mutableListOf<App>() val INITIAL_LIMIT = 4 emitReplacedList( this@flow, initialReplacedList, INITIAL_LIMIT, searchBundle, true, ) Timber.d("Fetching search result for $query, subBundle: $subBundle") var nextSubBundleSet: MutableSet<SearchBundle.SubBundle> do { nextSubBundleSet = fetchNextSubBundle( searchBundle, searchHelper, this@flow, initialReplacedList, INITIAL_LIMIT ) } while (nextSubBundleSet.isNotEmpty()) subBundle?.let { val searchResult = searchHelper.next(it) emitSearchResult(searchResult) return@let } /* * If initialReplacedList size is less than INITIAL_LIMIT, * it means the results were very less and nothing has been emitted so far. * Hence emit the list. */ if (initialReplacedList.size < INITIAL_LIMIT) { emitInMain(this@flow, initialReplacedList, false) val searchResult = searchHelper.searchResults(query) emitSearchResult(searchResult) } } }.flowOn(Dispatchers.IO) private suspend fun FlowCollector<Pair<List<App>, Boolean>>.emitSearchResult( searchBundle: SearchBundle ) { val apps = searchBundle.appList Timber.d("Search result is found: ${apps.size}") emit(Pair(apps, searchBundle.subBundles.isNotEmpty())) } private suspend fun fetchNextSubBundle( Loading Loading
app/build.gradle +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ android { buildTypes { debug { versionNameSuffix ".debug" applicationIdSuffix ".debug" // versionNameSuffix ".debug" // applicationIdSuffix ".debug" signingConfig signingConfigs.debugConfig proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } Loading
app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +1 −1 Original line number Diff line number Diff line Loading @@ -1118,7 +1118,7 @@ class FusedApiImpl @Inject constructor( private suspend fun getGplaySearchResult( query: String, ): Flow<Pair<List<FusedApp>, Boolean>> { val searchResults = gplayRepository.getSearchResult(query) val searchResults = gplayRepository.getSearchResult(query, null) return searchResults.map { val fusedAppList = it.first.map { app -> replaceWithFDroid(app) } Pair( Loading
app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepository.kt +2 −1 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import com.aurora.gplayapi.SearchSuggestEntry import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.Category import com.aurora.gplayapi.data.models.File import com.aurora.gplayapi.data.models.SearchBundle import foundation.e.apps.data.BaseStoreRepository import foundation.e.apps.data.fused.utils.CategoryType import kotlinx.coroutines.flow.Flow interface GplayStoreRepository : BaseStoreRepository { suspend fun getSearchResult(query: String): Flow<Pair<List<App>, Boolean>> suspend fun getSearchResult(query: String, subBundle: MutableSet<SearchBundle.SubBundle>?): Flow<Pair<List<App>, Boolean>> suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> suspend fun getAppsByCategory(category: String, pageUrl: String? = null): Any suspend fun getCategories(type: CategoryType? = null): List<Category> Loading
app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +66 −36 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.withContext import timber.log.Timber import javax.inject.Inject class GplayStoreRepositoryImpl @Inject constructor( Loading Loading @@ -76,52 +77,81 @@ class GplayStoreRepositoryImpl @Inject constructor( context.getString(R.string.movers_shakers_games) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME), ) // override suspend fun getSearchResult( // query: String, // ): Flow<Pair<List<App>, Boolean>> { // return flow { // // /* // * Variable names and logic made same as that of Aurora store. // * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171 // */ // var authData = loginSourceRepository.gplayAuth ?: return@flow // // val searchHelper = // SearchHelper(authData).using(gPlayHttpClient) // val searchBundle = searchHelper.searchResults(query) // // val initialReplacedList = mutableListOf<App>() // val INITIAL_LIMIT = 4 // // emitReplacedList( // this@flow, // initialReplacedList, // INITIAL_LIMIT, // searchBundle, // true, // ) // // var nextSubBundleSet: MutableSet<SearchBundle.SubBundle> // do { // nextSubBundleSet = fetchNextSubBundle( // searchBundle, // searchHelper, // this@flow, // initialReplacedList, // INITIAL_LIMIT // ) // } while (nextSubBundleSet.isNotEmpty()) // // /* // * If initialReplacedList size is less than INITIAL_LIMIT, // * it means the results were very less and nothing has been emitted so far. // * Hence emit the list. // */ // if (initialReplacedList.size < INITIAL_LIMIT) { // emitInMain(this@flow, initialReplacedList, false) // } // }.flowOn(Dispatchers.IO) // } override suspend fun getSearchResult( query: String, subBundle: MutableSet<SearchBundle.SubBundle>? ): Flow<Pair<List<App>, Boolean>> { return flow { /* * Variable names and logic made same as that of Aurora store. * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171 */ var authData = loginSourceRepository.gplayAuth ?: return@flow val searchHelper = SearchHelper(authData).using(gPlayHttpClient) val searchBundle = searchHelper.searchResults(query) val initialReplacedList = mutableListOf<App>() val INITIAL_LIMIT = 4 emitReplacedList( this@flow, initialReplacedList, INITIAL_LIMIT, searchBundle, true, ) Timber.d("Fetching search result for $query, subBundle: $subBundle") var nextSubBundleSet: MutableSet<SearchBundle.SubBundle> do { nextSubBundleSet = fetchNextSubBundle( searchBundle, searchHelper, this@flow, initialReplacedList, INITIAL_LIMIT ) } while (nextSubBundleSet.isNotEmpty()) subBundle?.let { val searchResult = searchHelper.next(it) emitSearchResult(searchResult) return@let } /* * If initialReplacedList size is less than INITIAL_LIMIT, * it means the results were very less and nothing has been emitted so far. * Hence emit the list. */ if (initialReplacedList.size < INITIAL_LIMIT) { emitInMain(this@flow, initialReplacedList, false) val searchResult = searchHelper.searchResults(query) emitSearchResult(searchResult) } } }.flowOn(Dispatchers.IO) private suspend fun FlowCollector<Pair<List<App>, Boolean>>.emitSearchResult( searchBundle: SearchBundle ) { val apps = searchBundle.appList Timber.d("Search result is found: ${apps.size}") emit(Pair(apps, searchBundle.subBundles.isNotEmpty())) } private suspend fun fetchNextSubBundle( Loading