From 1619cd475453bed35225263d1f76fae334b88da4 Mon Sep 17 00:00:00 2001 From: SayantanRC Date: Mon, 2 May 2022 16:22:32 +0530 Subject: [PATCH 1/3] App lounge: (issue_4945-2) create new method getFusedAppInstallationStatus() in FusedAPIImpl --- .../e/apps/api/fused/FusedAPIImpl.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 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 15d77d99b..d1b27c376 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 @@ -653,13 +653,21 @@ class FusedAPIImpl @Inject constructor( return app } + /* + * Get fused app installation status. + * Applicable for both native apps and PWAs. + */ + fun getFusedAppInstallationStatus(fusedApp: FusedApp): Status { + return if (fusedApp.is_pwa) { + pwaManagerModule.getPwaStatus(fusedApp) + } else { + pkgManagerModule.getPackageStatus(fusedApp.package_name, fusedApp.latest_version_code) + } + } + private fun FusedApp.updateStatus() { if (this.status != Status.INSTALLATION_ISSUE) { - this.status = if (this.is_pwa) { - pwaManagerModule.getPwaStatus(this) - } else { - pkgManagerModule.getPackageStatus(this.package_name, this.latest_version_code) - } + this.status = getFusedAppInstallationStatus(this) } } -- GitLab From 8a65e374ada71c4e1f1fe0cfcdf92fa0f07e2e9c Mon Sep 17 00:00:00 2001 From: SayantanRC Date: Mon, 2 May 2022 16:37:15 +0530 Subject: [PATCH 2/3] App lounge: (issue_4945-2) implement fusedAPIImpl.getFusedAppInstallationStatus --- app/src/main/java/foundation/e/apps/MainActivityViewModel.kt | 2 +- .../java/foundation/e/apps/api/fused/FusedAPIRepository.kt | 5 +++++ .../foundation/e/apps/application/ApplicationViewModel.kt | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt index 73ff62972..42d290e54 100644 --- a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt @@ -309,7 +309,7 @@ class MainActivityViewModel @Inject constructor( val downloadingItem = fusedDownloadList.find { fusedDownload -> fusedDownload.origin == it.origin && (fusedDownload.packageName == it.package_name || fusedDownload.id == it._id) } - it.status = downloadingItem?.status ?: pkgManagerModule.getPackageStatus(it.package_name, it.latest_version_code) + it.status = downloadingItem?.status ?: fusedAPIRepository.getFusedAppInstallationStatus(it) } } } 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 2e98dbc1d..f5f2ea17f 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 @@ -26,6 +26,7 @@ import foundation.e.apps.api.fused.data.FusedCategory import foundation.e.apps.api.fused.data.FusedHome import foundation.e.apps.manager.database.fusedDownload.FusedDownload import foundation.e.apps.utils.enums.Origin +import foundation.e.apps.utils.enums.Status import javax.inject.Inject import javax.inject.Singleton @@ -114,4 +115,8 @@ class FusedAPIRepository @Inject constructor( else -> fusedAPIImpl.getPlayStoreApps(browseUrl, authData) } } + + fun getFusedAppInstallationStatus(fusedApp: FusedApp): Status { + return fusedAPIImpl.getFusedAppInstallationStatus(fusedApp) + } } diff --git a/app/src/main/java/foundation/e/apps/application/ApplicationViewModel.kt b/app/src/main/java/foundation/e/apps/application/ApplicationViewModel.kt index 83c42a5f8..aa902b8f5 100644 --- a/app/src/main/java/foundation/e/apps/application/ApplicationViewModel.kt +++ b/app/src/main/java/foundation/e/apps/application/ApplicationViewModel.kt @@ -107,10 +107,7 @@ class ApplicationViewModel @Inject constructor( fusedApp.value?.let { app -> val downloadingItem = downloadList.find { it.origin == app.origin && (it.packageName == app.package_name || it.id == app.package_name) } - appStatus.value = downloadingItem?.status ?: pkgManagerModule.getPackageStatus( - app.package_name, - app.latest_version_code - ) + appStatus.value = downloadingItem?.status ?: fusedAPIRepository.getFusedAppInstallationStatus(app) } } } -- GitLab From 301bef1b9a157feed6d729f59168fe537aa874c0 Mon Sep 17 00:00:00 2001 From: SayantanRC Date: Mon, 2 May 2022 19:00:52 +0530 Subject: [PATCH 3/3] App lounge: (issue_4945-2) update documentation. --- .../main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt | 4 +++- .../java/foundation/e/apps/manager/pkg/PkgManagerModule.kt | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 d1b27c376..6079585b1 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 @@ -653,9 +653,11 @@ class FusedAPIImpl @Inject constructor( return app } - /* + /** * Get fused app installation status. * Applicable for both native apps and PWAs. + * + * Recommended to use this instead of [PkgManagerModule.getPackageStatus]. */ fun getFusedAppInstallationStatus(fusedApp: FusedApp): Status { return if (fusedApp.is_pwa) { diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt index 716a935d5..a4b11fc9a 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt @@ -30,6 +30,7 @@ import android.os.Build import android.util.Log import androidx.core.content.pm.PackageInfoCompat import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.api.fused.FusedAPIImpl import foundation.e.apps.manager.database.fusedDownload.FusedDownload import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status @@ -78,6 +79,12 @@ class PkgManagerModule @Inject constructor( return packageManager.getPackageInfo(packageName, 0) } + /** + * This method should be only used for native apps! + * If you are using for any FusedApp, please consider that it can be a PWA! + * + * Recommended to use: [FusedAPIImpl.getFusedAppInstallationStatus]. + */ fun getPackageStatus(packageName: String, versionCode: Int): Status { return if (isInstalled(packageName)) { if (isUpdatable(packageName, versionCode)) { -- GitLab