Loading app/src/main/java/foundation/e/apps/data/fused/FusedAPIRepository.kt +2 −2 Original line number Diff line number Diff line Loading @@ -108,11 +108,11 @@ class FusedAPIRepository @Inject constructor(private val fusedAPIImpl: FusedApi) return fusedAPIImpl.getSearchSuggestions(query) } suspend fun getSearchResults( suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<FusedApp>, Boolean>> { return fusedAPIImpl.getSearchResults(query, authData) return fusedAPIImpl.getCleanApkSearchResults(query, authData) } suspend fun getGplaySearchResults( Loading app/src/main/java/foundation/e/apps/data/fused/FusedApi.kt +3 −4 Original line number Diff line number Diff line Loading @@ -58,11 +58,10 @@ interface FusedApi { * Fetches search results from cleanAPK and GPlay servers and returns them * @param query Query * @param authData [AuthData] * @return A livedata Pair of list of non-nullable [FusedApp] and * a Boolean signifying if more search results are being loaded. * Observe this livedata to display new apps as they are fetched from the network. * @return ResultSupreme which contains a Pair<List<FusedApp>, Boolean> where List<FusedApp> * is the app list and [Boolean] indicates more data to load or not. */ suspend fun getSearchResults( suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<FusedApp>, Boolean>> Loading app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +11 −4 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ class FusedApiImpl @Inject constructor( private const val CATEGORY_TITLE_REPLACEABLE_CONJUNCTION = "&" private const val CATEGORY_OPEN_GAMES_ID = "game_open_games" private const val CATEGORY_OPEN_GAMES_TITLE = "Open games" private const val ERROR_GPLAY_SEARCH = "Gplay search is failed!" private const val ERROR_GPLAY_SEARCH = "Gplay search has failed!" private const val ERROR_GPLAY_SOURCE_NOT_SELECTED = "Gplay apps are not selected!" } Loading Loading @@ -247,7 +247,7 @@ class FusedApiImpl @Inject constructor( * a Boolean signifying if more search results are being loaded. * Observe this livedata to display new apps as they are fetched from the network. */ override suspend fun getSearchResults( override suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<FusedApp>, Boolean>> { Loading Loading @@ -1086,19 +1086,25 @@ class FusedApiImpl @Inject constructor( val fusedAppList = searchResults.first.map { app -> replaceWithFDroid(app) }.toMutableList() if (searchResults.second.isNotEmpty()) { fusedAppList.add(FusedApp(isPlaceHolder = true)) } return ResultSupreme.Success(Pair(fusedAppList.toList(), searchResults.second.toSet())) } catch (e: GplayHttpRequestException) { val message = e.localizedMessage?.ifBlank { ERROR_GPLAY_SEARCH } ?: ERROR_GPLAY_SEARCH val message = ( e.localizedMessage?.ifBlank { ERROR_GPLAY_SEARCH } ?: ERROR_GPLAY_SEARCH ) + "Status: ${e.status}" val exception = GPlayException(e.status == 408, message) return ResultSupreme.Error(message, exception) } catch (e: Exception) { val exception = GPlayException(e is SocketTimeoutException, e.localizedMessage) return ResultSupreme.Error(e.localizedMessage, exception) return ResultSupreme.Error(e.localizedMessage ?: "", exception) } } Loading Loading @@ -1407,6 +1413,7 @@ class FusedApiImpl @Inject constructor( val status = runCodeWithTimeout({ val streamCluster = gplayRepository.getAppsByCategory(category, pageUrl) as StreamCluster val filteredAppList = filterRestrictedGPlayApps(authData, streamCluster.clusterAppList) filteredAppList.data?.let { fusedAppList = it.toMutableList() Loading app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ class GplayStoreRepositoryImpl @Inject constructor( var authData = loginSourceRepository.gplayAuth ?: return Pair(emptyList(), mutableSetOf()) val searchHelper = SearchHelper(authData).using(gPlayHttpClient) Timber.d("Fetching search result for $query, subBundle: $subBundle") subBundle?.let { Loading app/src/main/java/foundation/e/apps/data/gplay/utils/GPlayHttpClient.kt +3 −2 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class GPlayHttpClient @Inject constructor( companion object { private const val TAG = "GPlayHttpClient" private const val HTTP_TIMEOUT_IN_SECOND = 10L private const val SEARCH = "search" } private val okHttpClient = OkHttpClient().newBuilder() Loading Loading @@ -161,7 +162,7 @@ class GPlayHttpClient @Inject constructor( // TODO: exception will be thrown for all apis when all gplay api implementation // will handle the exceptions. this will be done in following issue. // Issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1483 if (request.url.toString().contains("search")) { if (request.url.toString().contains(SEARCH)) { throw e } Loading Loading @@ -198,7 +199,7 @@ class GPlayHttpClient @Inject constructor( // TODO: exception will be thrown for all apis when all gplay api implementation // will handle the exceptions. this will be done in following issue. // Issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1483 if (response.request.url.toString().contains("search") && code != 200) { if (response.request.url.toString().contains(SEARCH) && code != 200) { throw GplayHttpRequestException(code, response.message) } Loading Loading
app/src/main/java/foundation/e/apps/data/fused/FusedAPIRepository.kt +2 −2 Original line number Diff line number Diff line Loading @@ -108,11 +108,11 @@ class FusedAPIRepository @Inject constructor(private val fusedAPIImpl: FusedApi) return fusedAPIImpl.getSearchSuggestions(query) } suspend fun getSearchResults( suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<FusedApp>, Boolean>> { return fusedAPIImpl.getSearchResults(query, authData) return fusedAPIImpl.getCleanApkSearchResults(query, authData) } suspend fun getGplaySearchResults( Loading
app/src/main/java/foundation/e/apps/data/fused/FusedApi.kt +3 −4 Original line number Diff line number Diff line Loading @@ -58,11 +58,10 @@ interface FusedApi { * Fetches search results from cleanAPK and GPlay servers and returns them * @param query Query * @param authData [AuthData] * @return A livedata Pair of list of non-nullable [FusedApp] and * a Boolean signifying if more search results are being loaded. * Observe this livedata to display new apps as they are fetched from the network. * @return ResultSupreme which contains a Pair<List<FusedApp>, Boolean> where List<FusedApp> * is the app list and [Boolean] indicates more data to load or not. */ suspend fun getSearchResults( suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<FusedApp>, Boolean>> Loading
app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +11 −4 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ class FusedApiImpl @Inject constructor( private const val CATEGORY_TITLE_REPLACEABLE_CONJUNCTION = "&" private const val CATEGORY_OPEN_GAMES_ID = "game_open_games" private const val CATEGORY_OPEN_GAMES_TITLE = "Open games" private const val ERROR_GPLAY_SEARCH = "Gplay search is failed!" private const val ERROR_GPLAY_SEARCH = "Gplay search has failed!" private const val ERROR_GPLAY_SOURCE_NOT_SELECTED = "Gplay apps are not selected!" } Loading Loading @@ -247,7 +247,7 @@ class FusedApiImpl @Inject constructor( * a Boolean signifying if more search results are being loaded. * Observe this livedata to display new apps as they are fetched from the network. */ override suspend fun getSearchResults( override suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<FusedApp>, Boolean>> { Loading Loading @@ -1086,19 +1086,25 @@ class FusedApiImpl @Inject constructor( val fusedAppList = searchResults.first.map { app -> replaceWithFDroid(app) }.toMutableList() if (searchResults.second.isNotEmpty()) { fusedAppList.add(FusedApp(isPlaceHolder = true)) } return ResultSupreme.Success(Pair(fusedAppList.toList(), searchResults.second.toSet())) } catch (e: GplayHttpRequestException) { val message = e.localizedMessage?.ifBlank { ERROR_GPLAY_SEARCH } ?: ERROR_GPLAY_SEARCH val message = ( e.localizedMessage?.ifBlank { ERROR_GPLAY_SEARCH } ?: ERROR_GPLAY_SEARCH ) + "Status: ${e.status}" val exception = GPlayException(e.status == 408, message) return ResultSupreme.Error(message, exception) } catch (e: Exception) { val exception = GPlayException(e is SocketTimeoutException, e.localizedMessage) return ResultSupreme.Error(e.localizedMessage, exception) return ResultSupreme.Error(e.localizedMessage ?: "", exception) } } Loading Loading @@ -1407,6 +1413,7 @@ class FusedApiImpl @Inject constructor( val status = runCodeWithTimeout({ val streamCluster = gplayRepository.getAppsByCategory(category, pageUrl) as StreamCluster val filteredAppList = filterRestrictedGPlayApps(authData, streamCluster.clusterAppList) filteredAppList.data?.let { fusedAppList = it.toMutableList() Loading
app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ class GplayStoreRepositoryImpl @Inject constructor( var authData = loginSourceRepository.gplayAuth ?: return Pair(emptyList(), mutableSetOf()) val searchHelper = SearchHelper(authData).using(gPlayHttpClient) Timber.d("Fetching search result for $query, subBundle: $subBundle") subBundle?.let { Loading
app/src/main/java/foundation/e/apps/data/gplay/utils/GPlayHttpClient.kt +3 −2 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class GPlayHttpClient @Inject constructor( companion object { private const val TAG = "GPlayHttpClient" private const val HTTP_TIMEOUT_IN_SECOND = 10L private const val SEARCH = "search" } private val okHttpClient = OkHttpClient().newBuilder() Loading Loading @@ -161,7 +162,7 @@ class GPlayHttpClient @Inject constructor( // TODO: exception will be thrown for all apis when all gplay api implementation // will handle the exceptions. this will be done in following issue. // Issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1483 if (request.url.toString().contains("search")) { if (request.url.toString().contains(SEARCH)) { throw e } Loading Loading @@ -198,7 +199,7 @@ class GPlayHttpClient @Inject constructor( // TODO: exception will be thrown for all apis when all gplay api implementation // will handle the exceptions. this will be done in following issue. // Issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1483 if (response.request.url.toString().contains("search") && code != 200) { if (response.request.url.toString().contains(SEARCH) && code != 200) { throw GplayHttpRequestException(code, response.message) } Loading