Loading app/src/main/java/foundation/e/apps/data/application/ApplicationRepository.kt +9 −8 Original line number Diff line number Diff line Loading @@ -38,10 +38,11 @@ import javax.inject.Singleton @Singleton class ApplicationRepository @Inject constructor( private val applicationAPIImpl: ApplicationApi, private val searchAPIImpl: SearchApi, private val homeApi: HomeApi, private val categoryApi: CategoryApi, private val appsApi: AppsApi, private val downloadInfoApi: DownloadInfoApi ) { suspend fun getHomeScreenData(authData: AuthData): LiveData<ResultSupreme<List<Home>>> { Loading @@ -49,7 +50,7 @@ class ApplicationRepository @Inject constructor( } fun getApplicationCategoryPreference(): List<String> { return applicationAPIImpl.getApplicationCategoryPreference() return searchAPIImpl.getApplicationCategoryPreference() } suspend fun getApplicationDetails( Loading Loading @@ -81,14 +82,14 @@ class ApplicationRepository @Inject constructor( origin: Origin, fusedDownload: FusedDownload ) { applicationAPIImpl.updateFusedDownloadWithDownloadingInfo( downloadInfoApi.updateFusedDownloadWithDownloadingInfo( origin, fusedDownload ) } suspend fun getOSSDownloadInfo(id: String, version: String? = null) = applicationAPIImpl.getOSSDownloadInfo(id, version) downloadInfoApi.getOSSDownloadInfo(id, version) suspend fun getOnDemandModule( packageName: String, Loading @@ -96,7 +97,7 @@ class ApplicationRepository @Inject constructor( versionCode: Int, offerType: Int ): String? { return applicationAPIImpl.getOnDemandModule(packageName, moduleName, versionCode, offerType) return downloadInfoApi.getOnDemandModule(packageName, moduleName, versionCode, offerType) } suspend fun getCategoriesList( Loading @@ -106,21 +107,21 @@ class ApplicationRepository @Inject constructor( } suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> { return applicationAPIImpl.getSearchSuggestions(query) return searchAPIImpl.getSearchSuggestions(query) } suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<Application>, Boolean>> { return applicationAPIImpl.getCleanApkSearchResults(query, authData) return searchAPIImpl.getCleanApkSearchResults(query, authData) } suspend fun getGplaySearchResults( query: String, nextPageSubBundle: Set<SearchBundle.SubBundle>? ): GplaySearchResult { return applicationAPIImpl.getGplaySearchResult(query, nextPageSubBundle) return searchAPIImpl.getGplaySearchResult(query, nextPageSubBundle) } suspend fun getAppsListBasedOnCategory( Loading app/src/main/java/foundation/e/apps/data/application/DownloadInfoApi.kt 0 → 100644 +23 −0 Original line number Diff line number Diff line package foundation.e.apps.data.application import foundation.e.apps.data.cleanapk.data.download.Download import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.fusedDownload.models.FusedDownload import retrofit2.Response interface DownloadInfoApi { suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int ): String? suspend fun updateFusedDownloadWithDownloadingInfo( origin: Origin, fusedDownload: FusedDownload ) suspend fun getOSSDownloadInfo(id: String, version: String?): Response<Download> } app/src/main/java/foundation/e/apps/data/application/DownloadInfoApiImpl.kt 0 → 100644 +68 −0 Original line number Diff line number Diff line package foundation.e.apps.data.application import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.data.playstore.PlayStoreRepository import javax.inject.Inject import javax.inject.Named class DownloadInfoApiImpl @Inject constructor( @Named("gplayRepository") private val gplayRepository: PlayStoreRepository, @Named("cleanApkAppsRepository") private val cleanApkAppsRepository: CleanApkRepository ) : DownloadInfoApi { override suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int ): String? { val list = gplayRepository.getOnDemandModule( packageName, moduleName, versionCode, offerType, ) for (element in list) { if (element.name == "$moduleName.apk") { return element.url } } return null } override suspend fun updateFusedDownloadWithDownloadingInfo( origin: Origin, fusedDownload: FusedDownload ) { val list = mutableListOf<String>() when (origin) { Origin.CLEANAPK -> { val downloadInfo = (cleanApkAppsRepository as CleanApkDownloadInfoFetcher).getDownloadInfo( fusedDownload.id ) .body() downloadInfo?.download_data?.download_link?.let { list.add(it) } fusedDownload.signature = downloadInfo?.download_data?.signature ?: "" } Origin.GPLAY -> { val downloadList = gplayRepository.getDownloadInfo( fusedDownload.packageName, fusedDownload.versionCode, fusedDownload.offerType ) fusedDownload.files = downloadList list.addAll(downloadList.map { it.url }) } } fusedDownload.downloadURLList = list } override suspend fun getOSSDownloadInfo(id: String, version: String?) = (cleanApkAppsRepository as CleanApkDownloadInfoFetcher).getDownloadInfo(id, version) } No newline at end of file app/src/main/java/foundation/e/apps/data/application/HomeApiImpl.kt +6 −6 Original line number Diff line number Diff line Loading @@ -115,19 +115,19 @@ class HomeApiImpl @Inject constructor( } Source.OPEN -> handleNetworkResult { handleCleanApkHomes(priorList, ApplicationApi.APP_TYPE_OPEN) handleCleanApkHomes(priorList, SearchApi.APP_TYPE_OPEN) } Source.PWA -> handleNetworkResult { handleCleanApkHomes(priorList, ApplicationApi.APP_TYPE_PWA) handleCleanApkHomes(priorList, SearchApi.APP_TYPE_PWA) } } setHomeErrorMessage(result.getResultStatus(), source) priorList.sortBy { when (it.source) { ApplicationApi.APP_TYPE_OPEN -> AppSourceWeight.OPEN_SOURCE.ordinal ApplicationApi.APP_TYPE_PWA -> AppSourceWeight.PWA.ordinal SearchApi.APP_TYPE_OPEN -> AppSourceWeight.OPEN_SOURCE.ordinal SearchApi.APP_TYPE_PWA -> AppSourceWeight.PWA.ordinal else -> AppSourceWeight.GPLAY.ordinal } } Loading @@ -139,7 +139,7 @@ class HomeApiImpl @Inject constructor( priorList: MutableList<Home>, appType: String ): MutableList<Home> { val response = if (appType == ApplicationApi.APP_TYPE_OPEN) { val response = if (appType == SearchApi.APP_TYPE_OPEN) { (cleanApkAppsRepository.getHomeScreenData() as Response<HomeScreen>).body() } else { (cleanApkPWARepository.getHomeScreenData() as Response<HomeScreen>).body() Loading @@ -154,7 +154,7 @@ class HomeApiImpl @Inject constructor( private suspend fun generateCleanAPKHome(home: CleanApkHome, appType: String): List<Home> { val list = mutableListOf<Home>() val headings = if (appType == ApplicationApi.APP_TYPE_OPEN) { val headings = if (appType == SearchApi.APP_TYPE_OPEN) { getOpenSourceHomeCategories() } else { getPWAHomeCategories() Loading app/src/main/java/foundation/e/apps/data/application/ApplicationApi.kt→app/src/main/java/foundation/e/apps/data/application/SearchApi.kt +1 −28 Original line number Diff line number Diff line package foundation.e.apps.data.application import androidx.lifecycle.LiveData import com.aurora.gplayapi.SearchSuggestEntry import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.data.models.SearchBundle import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.cleanapk.data.download.Download import foundation.e.apps.data.enums.FilterLevel import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.data.Category import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.fusedDownload.models.FusedDownload import retrofit2.Response typealias GplaySearchResult = ResultSupreme<Pair<List<Application>, Set<SearchBundle.SubBundle>>> interface ApplicationApi { interface SearchApi { companion object { const val APP_TYPE_ANY = "any" const val APP_TYPE_OPEN = "open" Loading @@ -47,19 +35,4 @@ interface ApplicationApi { ): GplaySearchResult suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int ): String? suspend fun updateFusedDownloadWithDownloadingInfo( origin: Origin, fusedDownload: FusedDownload ) suspend fun getOSSDownloadInfo(id: String, version: String?): Response<Download> } Loading
app/src/main/java/foundation/e/apps/data/application/ApplicationRepository.kt +9 −8 Original line number Diff line number Diff line Loading @@ -38,10 +38,11 @@ import javax.inject.Singleton @Singleton class ApplicationRepository @Inject constructor( private val applicationAPIImpl: ApplicationApi, private val searchAPIImpl: SearchApi, private val homeApi: HomeApi, private val categoryApi: CategoryApi, private val appsApi: AppsApi, private val downloadInfoApi: DownloadInfoApi ) { suspend fun getHomeScreenData(authData: AuthData): LiveData<ResultSupreme<List<Home>>> { Loading @@ -49,7 +50,7 @@ class ApplicationRepository @Inject constructor( } fun getApplicationCategoryPreference(): List<String> { return applicationAPIImpl.getApplicationCategoryPreference() return searchAPIImpl.getApplicationCategoryPreference() } suspend fun getApplicationDetails( Loading Loading @@ -81,14 +82,14 @@ class ApplicationRepository @Inject constructor( origin: Origin, fusedDownload: FusedDownload ) { applicationAPIImpl.updateFusedDownloadWithDownloadingInfo( downloadInfoApi.updateFusedDownloadWithDownloadingInfo( origin, fusedDownload ) } suspend fun getOSSDownloadInfo(id: String, version: String? = null) = applicationAPIImpl.getOSSDownloadInfo(id, version) downloadInfoApi.getOSSDownloadInfo(id, version) suspend fun getOnDemandModule( packageName: String, Loading @@ -96,7 +97,7 @@ class ApplicationRepository @Inject constructor( versionCode: Int, offerType: Int ): String? { return applicationAPIImpl.getOnDemandModule(packageName, moduleName, versionCode, offerType) return downloadInfoApi.getOnDemandModule(packageName, moduleName, versionCode, offerType) } suspend fun getCategoriesList( Loading @@ -106,21 +107,21 @@ class ApplicationRepository @Inject constructor( } suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> { return applicationAPIImpl.getSearchSuggestions(query) return searchAPIImpl.getSearchSuggestions(query) } suspend fun getCleanApkSearchResults( query: String, authData: AuthData ): ResultSupreme<Pair<List<Application>, Boolean>> { return applicationAPIImpl.getCleanApkSearchResults(query, authData) return searchAPIImpl.getCleanApkSearchResults(query, authData) } suspend fun getGplaySearchResults( query: String, nextPageSubBundle: Set<SearchBundle.SubBundle>? ): GplaySearchResult { return applicationAPIImpl.getGplaySearchResult(query, nextPageSubBundle) return searchAPIImpl.getGplaySearchResult(query, nextPageSubBundle) } suspend fun getAppsListBasedOnCategory( Loading
app/src/main/java/foundation/e/apps/data/application/DownloadInfoApi.kt 0 → 100644 +23 −0 Original line number Diff line number Diff line package foundation.e.apps.data.application import foundation.e.apps.data.cleanapk.data.download.Download import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.fusedDownload.models.FusedDownload import retrofit2.Response interface DownloadInfoApi { suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int ): String? suspend fun updateFusedDownloadWithDownloadingInfo( origin: Origin, fusedDownload: FusedDownload ) suspend fun getOSSDownloadInfo(id: String, version: String?): Response<Download> }
app/src/main/java/foundation/e/apps/data/application/DownloadInfoApiImpl.kt 0 → 100644 +68 −0 Original line number Diff line number Diff line package foundation.e.apps.data.application import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.data.playstore.PlayStoreRepository import javax.inject.Inject import javax.inject.Named class DownloadInfoApiImpl @Inject constructor( @Named("gplayRepository") private val gplayRepository: PlayStoreRepository, @Named("cleanApkAppsRepository") private val cleanApkAppsRepository: CleanApkRepository ) : DownloadInfoApi { override suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int ): String? { val list = gplayRepository.getOnDemandModule( packageName, moduleName, versionCode, offerType, ) for (element in list) { if (element.name == "$moduleName.apk") { return element.url } } return null } override suspend fun updateFusedDownloadWithDownloadingInfo( origin: Origin, fusedDownload: FusedDownload ) { val list = mutableListOf<String>() when (origin) { Origin.CLEANAPK -> { val downloadInfo = (cleanApkAppsRepository as CleanApkDownloadInfoFetcher).getDownloadInfo( fusedDownload.id ) .body() downloadInfo?.download_data?.download_link?.let { list.add(it) } fusedDownload.signature = downloadInfo?.download_data?.signature ?: "" } Origin.GPLAY -> { val downloadList = gplayRepository.getDownloadInfo( fusedDownload.packageName, fusedDownload.versionCode, fusedDownload.offerType ) fusedDownload.files = downloadList list.addAll(downloadList.map { it.url }) } } fusedDownload.downloadURLList = list } override suspend fun getOSSDownloadInfo(id: String, version: String?) = (cleanApkAppsRepository as CleanApkDownloadInfoFetcher).getDownloadInfo(id, version) } No newline at end of file
app/src/main/java/foundation/e/apps/data/application/HomeApiImpl.kt +6 −6 Original line number Diff line number Diff line Loading @@ -115,19 +115,19 @@ class HomeApiImpl @Inject constructor( } Source.OPEN -> handleNetworkResult { handleCleanApkHomes(priorList, ApplicationApi.APP_TYPE_OPEN) handleCleanApkHomes(priorList, SearchApi.APP_TYPE_OPEN) } Source.PWA -> handleNetworkResult { handleCleanApkHomes(priorList, ApplicationApi.APP_TYPE_PWA) handleCleanApkHomes(priorList, SearchApi.APP_TYPE_PWA) } } setHomeErrorMessage(result.getResultStatus(), source) priorList.sortBy { when (it.source) { ApplicationApi.APP_TYPE_OPEN -> AppSourceWeight.OPEN_SOURCE.ordinal ApplicationApi.APP_TYPE_PWA -> AppSourceWeight.PWA.ordinal SearchApi.APP_TYPE_OPEN -> AppSourceWeight.OPEN_SOURCE.ordinal SearchApi.APP_TYPE_PWA -> AppSourceWeight.PWA.ordinal else -> AppSourceWeight.GPLAY.ordinal } } Loading @@ -139,7 +139,7 @@ class HomeApiImpl @Inject constructor( priorList: MutableList<Home>, appType: String ): MutableList<Home> { val response = if (appType == ApplicationApi.APP_TYPE_OPEN) { val response = if (appType == SearchApi.APP_TYPE_OPEN) { (cleanApkAppsRepository.getHomeScreenData() as Response<HomeScreen>).body() } else { (cleanApkPWARepository.getHomeScreenData() as Response<HomeScreen>).body() Loading @@ -154,7 +154,7 @@ class HomeApiImpl @Inject constructor( private suspend fun generateCleanAPKHome(home: CleanApkHome, appType: String): List<Home> { val list = mutableListOf<Home>() val headings = if (appType == ApplicationApi.APP_TYPE_OPEN) { val headings = if (appType == SearchApi.APP_TYPE_OPEN) { getOpenSourceHomeCategories() } else { getPWAHomeCategories() Loading
app/src/main/java/foundation/e/apps/data/application/ApplicationApi.kt→app/src/main/java/foundation/e/apps/data/application/SearchApi.kt +1 −28 Original line number Diff line number Diff line package foundation.e.apps.data.application import androidx.lifecycle.LiveData import com.aurora.gplayapi.SearchSuggestEntry import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.data.models.SearchBundle import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.cleanapk.data.download.Download import foundation.e.apps.data.enums.FilterLevel import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.data.Category import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.fusedDownload.models.FusedDownload import retrofit2.Response typealias GplaySearchResult = ResultSupreme<Pair<List<Application>, Set<SearchBundle.SubBundle>>> interface ApplicationApi { interface SearchApi { companion object { const val APP_TYPE_ANY = "any" const val APP_TYPE_OPEN = "open" Loading @@ -47,19 +35,4 @@ interface ApplicationApi { ): GplaySearchResult suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int ): String? suspend fun updateFusedDownloadWithDownloadingInfo( origin: Origin, fusedDownload: FusedDownload ) suspend fun getOSSDownloadInfo(id: String, version: String?): Response<Download> }