From ca67ea2d4f0deb17f70b7e10fd07a8481959c112 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 2 Jan 2023 13:53:06 +0530 Subject: [PATCH 1/2] update FusedApi getApplicationCategoryPreference to return list of strings --- .../main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt | 8 ++++++-- .../foundation/e/apps/api/fused/FusedAPIRepository.kt | 2 +- app/src/main/java/foundation/e/apps/home/HomeViewModel.kt | 2 +- .../java/foundation/e/apps/updates/UpdatesViewModel.kt | 2 +- .../e/apps/updates/manager/UpdatesManagerImpl.kt | 2 +- .../e/apps/updates/manager/UpdatesManagerRepository.kt | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index 9657199e1..8f29b0569 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt @@ -109,8 +109,12 @@ class FusedAPIImpl @Inject constructor( return true } - fun getApplicationCategoryPreference(): String { - return preferenceManagerModule.preferredApplicationType() + fun getApplicationCategoryPreference(): List { + val prefs = mutableListOf() + if (preferenceManagerModule.isGplaySelected()) prefs.add(APP_TYPE_ANY) + if (preferenceManagerModule.isOpenSourceSelected()) prefs.add(APP_TYPE_OPEN) + if (preferenceManagerModule.isPWASelected()) prefs.add(APP_TYPE_PWA) + return prefs } suspend fun getHomeScreenData( diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt index 28000e635..537b533c0 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt @@ -86,7 +86,7 @@ class FusedAPIRepository @Inject constructor(private val fusedAPIImpl: FusedAPII return fusedAPIImpl.isFusedHomesEmpty(fusedHomes) } - fun getApplicationCategoryPreference(): String { + fun getApplicationCategoryPreference(): List { return fusedAPIImpl.getApplicationCategoryPreference() } diff --git a/app/src/main/java/foundation/e/apps/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/home/HomeViewModel.kt index d42e4dce0..dd24925e7 100644 --- a/app/src/main/java/foundation/e/apps/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/home/HomeViewModel.kt @@ -93,7 +93,7 @@ class HomeViewModel @Inject constructor( } } - fun getApplicationCategoryPreference(): String { + fun getApplicationCategoryPreference(): List { return fusedAPIRepository.getApplicationCategoryPreference() } diff --git a/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt b/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt index 12b98283d..d576b6ae8 100644 --- a/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt +++ b/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt @@ -115,7 +115,7 @@ class UpdatesViewModel @Inject constructor( return false } - fun getApplicationCategoryPreference(): String { + fun getApplicationCategoryPreference(): List { return updatesManagerRepository.getApplicationCategoryPreference() } diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt index 85c3dd009..6eac68ae8 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt @@ -113,7 +113,7 @@ class UpdatesManagerImpl @Inject constructor( return Pair(nonFaultyUpdateList, status) } - fun getApplicationCategoryPreference(): String { + fun getApplicationCategoryPreference(): List { return fusedAPIRepository.getApplicationCategoryPreference() } } diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerRepository.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerRepository.kt index ca69ff104..f15c8bde0 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerRepository.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerRepository.kt @@ -43,7 +43,7 @@ class UpdatesManagerRepository @Inject constructor( return updatesManagerImpl.getUpdatesOSS() } - fun getApplicationCategoryPreference(): String { + fun getApplicationCategoryPreference(): List { return updatesManagerImpl.getApplicationCategoryPreference() } } -- GitLab From 63d148b7807ef697abc604c5f71133461149d55c Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 2 Jan 2023 13:57:35 +0530 Subject: [PATCH 2/2] check if preferences have gplay selected before checking updates in gplay --- .../updates/manager/UpdatesManagerImpl.kt | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt index 6eac68ae8..d80a5ded2 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesManagerImpl.kt @@ -20,6 +20,7 @@ package foundation.e.apps.updates.manager import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.api.faultyApps.FaultyAppRepository +import foundation.e.apps.api.fused.FusedAPIImpl.Companion.APP_TYPE_ANY import foundation.e.apps.api.fused.FusedAPIRepository import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.manager.pkg.PkgManagerModule @@ -63,18 +64,22 @@ class UpdatesManagerImpl @Inject constructor( } } - // Check for remaining apps from GPlay - val gPlayResult = fusedAPIRepository.getApplicationDetails( - pkgList, - authData, - Origin.GPLAY - ) - gPlayResult.first.forEach { - if (it.status == Status.UPDATABLE && it.filterLevel.isUnFiltered()) updateList.add(it) - } - gPlayResult.second.let { - if (it != ResultStatus.OK) { - status = it + if (getApplicationCategoryPreference().contains(APP_TYPE_ANY)) { + // Check for remaining apps from GPlay + val gPlayResult = fusedAPIRepository.getApplicationDetails( + pkgList, + authData, + Origin.GPLAY + ) + gPlayResult.first.forEach { + if (it.status == Status.UPDATABLE && it.filterLevel.isUnFiltered()) updateList.add( + it + ) + } + gPlayResult.second.let { + if (it != ResultStatus.OK) { + status = it + } } } } -- GitLab