From 981d234d7185fdaf073ba847d34c1528b5a9ca03 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 15 Jul 2024 21:20:02 +0530 Subject: [PATCH 1/5] new Origin and new Source --- .../e/apps/data/application/ApplicationDataManager.kt | 1 + .../e/apps/data/application/data/Application.kt | 9 ++++++--- .../data/application/downloadInfo/DownloadInfoApiImpl.kt | 4 ++++ .../e/apps/data/application/home/HomeApiImpl.kt | 5 +++++ app/src/main/java/foundation/e/apps/data/enums/Origin.kt | 3 ++- app/src/main/java/foundation/e/apps/data/enums/Source.kt | 2 ++ .../e/apps/domain/ValidateAppAgeLimitUseCase.kt | 8 ++++++++ .../application/model/ApplicationScreenshotsRVAdapter.kt | 1 + .../apps/ui/applicationlist/ApplicationListRVAdapter.kt | 3 +++ app/src/main/res/values/strings.xml | 1 + 10 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt index b5daea536..15090a362 100644 --- a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt +++ b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt @@ -62,6 +62,7 @@ class ApplicationDataManager @Inject constructor( application.package_name.isBlank() -> FilterLevel.UNKNOWN !application.isFree && application.price.isBlank() -> FilterLevel.UI application.origin == Origin.CLEANAPK -> FilterLevel.NONE + application.origin == Origin.GITLAB -> FilterLevel.NONE !isRestricted(application) -> FilterLevel.NONE authData == null -> FilterLevel.UNKNOWN // cannot determine for gplay app !isApplicationVisible(application) -> FilterLevel.DATA diff --git a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt index 2ff78b947..520fe067c 100644 --- a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt @@ -112,9 +112,12 @@ data class Application( fun updateSource(context: Context) { this.apply { - source = if (origin != Origin.CLEANAPK) "" - else if (is_pwa) context.getString(R.string.pwa) - else context.getString(R.string.open_source) + source = when { + origin == Origin.GITLAB -> context.getString(R.string.system_app) + origin == Origin.GPLAY -> "" + is_pwa -> context.getString(R.string.pwa) + else -> context.getString(R.string.open_source) + } } } } diff --git a/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt index 896510856..71a085305 100644 --- a/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt @@ -68,6 +68,10 @@ class DownloadInfoApiImpl @Inject constructor( Origin.GPLAY -> { updateDownloadInfoFromGplay(appInstall, list) } + + Origin.GITLAB -> { + // TODO + } } appInstall.downloadURLList = list diff --git a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index d8b91b173..4f94e2afd 100644 --- a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt @@ -120,6 +120,10 @@ class HomeApiImpl @Inject constructor( Source.PWA -> handleNetworkResult { handleCleanApkHomes(priorList, SearchApi.APP_TYPE_PWA) } + + Source.GITLAB -> { + ResultSupreme.Error(message = "Gitlab source not allowed") + } } setHomeErrorMessage(result.getResultStatus(), source) @@ -223,6 +227,7 @@ class HomeApiImpl @Inject constructor( if (apiStatus != ResultStatus.OK) { apiStatus.message = when (source) { Source.GPLAY -> ("GPlay home loading error\n" + apiStatus.message).trim() + Source.GITLAB -> ("Gitlab home not allowed\n" + apiStatus.message).trim() Source.OPEN -> ("Open Source home loading error\n" + apiStatus.message).trim() Source.PWA -> ("PWA home loading error\n" + apiStatus.message).trim() } diff --git a/app/src/main/java/foundation/e/apps/data/enums/Origin.kt b/app/src/main/java/foundation/e/apps/data/enums/Origin.kt index b8bd98c83..eb2cdc782 100644 --- a/app/src/main/java/foundation/e/apps/data/enums/Origin.kt +++ b/app/src/main/java/foundation/e/apps/data/enums/Origin.kt @@ -20,5 +20,6 @@ package foundation.e.apps.data.enums enum class Origin { CLEANAPK, - GPLAY + GPLAY, + GITLAB, } diff --git a/app/src/main/java/foundation/e/apps/data/enums/Source.kt b/app/src/main/java/foundation/e/apps/data/enums/Source.kt index 86fd9c631..c672015c8 100644 --- a/app/src/main/java/foundation/e/apps/data/enums/Source.kt +++ b/app/src/main/java/foundation/e/apps/data/enums/Source.kt @@ -19,6 +19,7 @@ package foundation.e.apps.data.enums enum class Source { GPLAY, + GITLAB, OPEN, PWA; @@ -27,6 +28,7 @@ enum class Source { return when (source) { "Open Source" -> OPEN "PWA" -> PWA + "GITLAB" -> GITLAB else -> GPLAY } } diff --git a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt index 994289f21..f852766c5 100644 --- a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt +++ b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt @@ -56,6 +56,10 @@ class ValidateAppAgeLimitUseCase @Inject constructor( data = ContentRatingValidity(true) ) + isGitlabApp(app) -> ResultSupreme.Success( + data = ContentRatingValidity(true) + ) + isKnownNsfwApp(app) -> ResultSupreme.Success(data = ContentRatingValidity(false)) isCleanApkApp(app) -> ResultSupreme.Success( data = ContentRatingValidity(isValid = !isNsfwAppByCleanApkApi(app)) @@ -70,6 +74,10 @@ class ValidateAppAgeLimitUseCase @Inject constructor( } } + private fun isGitlabApp(app: AppInstall): Boolean { + return app.origin == Origin.GITLAB + } + private fun isCleanApkApp(app: AppInstall): Boolean { return app.id.isNotBlank() && app.origin == Origin.CLEANAPK diff --git a/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt index 9fefd43d0..b9d452f39 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt @@ -58,6 +58,7 @@ class ApplicationScreenshotsRVAdapter( Origin.GPLAY -> { imageView.load(oldList[position]) } + else -> {} } imageView.setOnClickListener { val action = diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt index 43cd66851..9c4e38d77 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt @@ -175,6 +175,9 @@ class ApplicationListRVAdapter( placeholder(shimmerDrawable) } } + Origin.GITLAB -> { + // TODO + } else -> Timber.wtf("${searchApp.package_name} is from an unknown origin") } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 85f7f2bb8..993dcea40 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -120,6 +120,7 @@ Open Source apps Some proprietary apps may also have an Open Source version. Whenever this happens App Lounge shows the Open Source version only, in order to avoid duplicates. Downloading… + System app Additional file for %s Having troubles? https://doc.e.foundation/support-topics/app_lounge_troubleshooting -- GitLab From 97def60cebf05f56fb5ae69ea9fcf890beda3b8a Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 16 Jul 2024 18:19:26 +0530 Subject: [PATCH 2/5] add TODO to remove updateSource from Application class --- .../java/foundation/e/apps/data/application/data/Application.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt index 520fe067c..c2d1a1523 100644 --- a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt @@ -110,6 +110,7 @@ data class Application( this.type = if (this.is_pwa) PWA else NATIVE } + // TODO: Make this logic separate from data layer. fun updateSource(context: Context) { this.apply { source = when { -- GitLab From a7330f60d52d1a0c4956c6282bda465f5071494d Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 17 Jul 2024 15:49:44 +0530 Subject: [PATCH 3/5] change Origin and Source from GITLAB to GITLAB_RELEASES --- .../e/apps/data/application/ApplicationDataManager.kt | 2 +- .../foundation/e/apps/data/application/data/Application.kt | 2 +- .../apps/data/application/downloadInfo/DownloadInfoApiImpl.kt | 2 +- .../foundation/e/apps/data/application/home/HomeApiImpl.kt | 4 ++-- app/src/main/java/foundation/e/apps/data/enums/Origin.kt | 2 +- app/src/main/java/foundation/e/apps/data/enums/Source.kt | 4 ++-- .../foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt | 2 +- .../e/apps/ui/applicationlist/ApplicationListRVAdapter.kt | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt index 15090a362..3364511b0 100644 --- a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt +++ b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt @@ -62,7 +62,7 @@ class ApplicationDataManager @Inject constructor( application.package_name.isBlank() -> FilterLevel.UNKNOWN !application.isFree && application.price.isBlank() -> FilterLevel.UI application.origin == Origin.CLEANAPK -> FilterLevel.NONE - application.origin == Origin.GITLAB -> FilterLevel.NONE + application.origin == Origin.GITLAB_RELEASES -> FilterLevel.NONE !isRestricted(application) -> FilterLevel.NONE authData == null -> FilterLevel.UNKNOWN // cannot determine for gplay app !isApplicationVisible(application) -> FilterLevel.DATA diff --git a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt index c2d1a1523..ae6153e29 100644 --- a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt @@ -114,7 +114,7 @@ data class Application( fun updateSource(context: Context) { this.apply { source = when { - origin == Origin.GITLAB -> context.getString(R.string.system_app) + origin == Origin.GITLAB_RELEASES -> context.getString(R.string.system_app) origin == Origin.GPLAY -> "" is_pwa -> context.getString(R.string.pwa) else -> context.getString(R.string.open_source) diff --git a/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt index 71a085305..a0e47ae3f 100644 --- a/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/downloadInfo/DownloadInfoApiImpl.kt @@ -69,7 +69,7 @@ class DownloadInfoApiImpl @Inject constructor( updateDownloadInfoFromGplay(appInstall, list) } - Origin.GITLAB -> { + Origin.GITLAB_RELEASES -> { // TODO } } diff --git a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index 4f94e2afd..53a402427 100644 --- a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt @@ -121,7 +121,7 @@ class HomeApiImpl @Inject constructor( handleCleanApkHomes(priorList, SearchApi.APP_TYPE_PWA) } - Source.GITLAB -> { + Source.GITLAB_RELEASES -> { ResultSupreme.Error(message = "Gitlab source not allowed") } } @@ -227,7 +227,7 @@ class HomeApiImpl @Inject constructor( if (apiStatus != ResultStatus.OK) { apiStatus.message = when (source) { Source.GPLAY -> ("GPlay home loading error\n" + apiStatus.message).trim() - Source.GITLAB -> ("Gitlab home not allowed\n" + apiStatus.message).trim() + Source.GITLAB_RELEASES -> ("Gitlab home not allowed\n" + apiStatus.message).trim() Source.OPEN -> ("Open Source home loading error\n" + apiStatus.message).trim() Source.PWA -> ("PWA home loading error\n" + apiStatus.message).trim() } diff --git a/app/src/main/java/foundation/e/apps/data/enums/Origin.kt b/app/src/main/java/foundation/e/apps/data/enums/Origin.kt index eb2cdc782..d5305b23d 100644 --- a/app/src/main/java/foundation/e/apps/data/enums/Origin.kt +++ b/app/src/main/java/foundation/e/apps/data/enums/Origin.kt @@ -21,5 +21,5 @@ package foundation.e.apps.data.enums enum class Origin { CLEANAPK, GPLAY, - GITLAB, + GITLAB_RELEASES, } diff --git a/app/src/main/java/foundation/e/apps/data/enums/Source.kt b/app/src/main/java/foundation/e/apps/data/enums/Source.kt index c672015c8..fdecbc5ee 100644 --- a/app/src/main/java/foundation/e/apps/data/enums/Source.kt +++ b/app/src/main/java/foundation/e/apps/data/enums/Source.kt @@ -19,7 +19,7 @@ package foundation.e.apps.data.enums enum class Source { GPLAY, - GITLAB, + GITLAB_RELEASES, OPEN, PWA; @@ -28,7 +28,7 @@ enum class Source { return when (source) { "Open Source" -> OPEN "PWA" -> PWA - "GITLAB" -> GITLAB + "GITLAB_RELEASES" -> GITLAB_RELEASES else -> GPLAY } } diff --git a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt index f852766c5..1370ad1cf 100644 --- a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt +++ b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt @@ -75,7 +75,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( } private fun isGitlabApp(app: AppInstall): Boolean { - return app.origin == Origin.GITLAB + return app.origin == Origin.GITLAB_RELEASES } private fun isCleanApkApp(app: AppInstall): Boolean { diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt index 9c4e38d77..40951778e 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt @@ -175,7 +175,7 @@ class ApplicationListRVAdapter( placeholder(shimmerDrawable) } } - Origin.GITLAB -> { + Origin.GITLAB_RELEASES -> { // TODO } else -> Timber.wtf("${searchApp.package_name} is from an unknown origin") -- GitLab From 239660e11e35d182c1637e51a23966480b322049 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 17 Jul 2024 15:50:35 +0530 Subject: [PATCH 4/5] update comment --- .../java/foundation/e/apps/data/application/data/Application.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt index ae6153e29..0d8bd5184 100644 --- a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt @@ -110,7 +110,7 @@ data class Application( this.type = if (this.is_pwa) PWA else NATIVE } - // TODO: Make this logic separate from data layer. + // TODO: Make this logic separate from data layer (https://gitlab.e.foundation/e/os/backlog/-/issues/2371) fun updateSource(context: Context) { this.apply { source = when { -- GitLab From 94f51de5e51847e0168772a70f9025e231e4f538 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 18 Jul 2024 06:36:41 +0530 Subject: [PATCH 5/5] suggestion --- .../ui/application/model/ApplicationScreenshotsRVAdapter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt index b9d452f39..7fa122efb 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/model/ApplicationScreenshotsRVAdapter.kt @@ -58,7 +58,9 @@ class ApplicationScreenshotsRVAdapter( Origin.GPLAY -> { imageView.load(oldList[position]) } - else -> {} + Origin.GITLAB_RELEASES -> { + // no operation + } } imageView.setOnClickListener { val action = -- GitLab