From c371961fa8c7fa57040ba236de05099d72502d87 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Tue, 11 Mar 2025 22:58:35 +0600 Subject: [PATCH 1/6] fix: stores are returned based on if they are checked as active in Settings Previously on commit df2ac320, stores were introduced as an abstraction on Open Source, PWA and Google Play apps. However, when retrieving these stores, there was no check on the Stores class if the store is marked as selected by the user on the Settings screen. This fix takes the selection into consideration using AppLoungePreference and only returns those stores which are currently selected. --- .../java/foundation/e/apps/data/Stores.kt | 40 ++++++++++++++----- .../foundation/e/apps/ui/home/HomeFragment.kt | 5 ++- .../e/apps/ui/home/HomeViewModel.kt | 8 ++++ .../e/apps/category/CategoryApiTest.kt | 26 +++++++++--- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/Stores.kt b/app/src/main/java/foundation/e/apps/data/Stores.kt index ca8cf3c75..0a6215478 100644 --- a/app/src/main/java/foundation/e/apps/data/Stores.kt +++ b/app/src/main/java/foundation/e/apps/data/Stores.kt @@ -4,14 +4,16 @@ import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.enums.Source import foundation.e.apps.data.playstore.PlayStoreRepository +import foundation.e.apps.data.preference.AppLoungePreference import javax.inject.Inject import javax.inject.Singleton @Singleton class Stores @Inject constructor( - playStoreRepository: PlayStoreRepository, - cleanApkAppsRepository: CleanApkAppsRepository, - cleanApkPwaRepository: CleanApkPwaRepository, + private val playStoreRepository: PlayStoreRepository, + private val cleanApkAppsRepository: CleanApkAppsRepository, + private val cleanApkPwaRepository: CleanApkPwaRepository, + private val appLoungePreference: AppLoungePreference ) { private val defaultStores = mapOf( @@ -22,7 +24,29 @@ class Stores @Inject constructor( private val stores = defaultStores.toMutableMap() - fun getStores(): Map = stores + /** + * Retrieves a map of enabled store repositories based on user preferences. + * + * @return A map where the keys are the selected [Source] types and + * the values are their corresponding [StoreRepository] instances. + */ + fun getStores(): Map { + val showPlayStoreApps = appLoungePreference.isGplaySelected() + val showOpenSourceApps = appLoungePreference.isOpenSourceSelected() + val showPwaApps = appLoungePreference.isPWASelected() + + return buildMap { + if (showPlayStoreApps) { + put(Source.PLAY_STORE, playStoreRepository) + } + if (showOpenSourceApps) { + put(Source.OPEN_SOURCE, cleanApkAppsRepository) + } + if (showPwaApps) { + put(Source.PWA, cleanApkPwaRepository) + } + } + } fun getStore(source: Source): StoreRepository? = stores[source] @@ -31,9 +55,7 @@ class Stores @Inject constructor( stores[source] = repository } - fun disableStore(source: Source) { - stores.remove(source) - } + fun disableStore(source: Source) = stores.remove(source) - fun isStoreEnabled(source: Source): Boolean = stores.containsKey(source) -} \ No newline at end of file + fun isStoreEnabled(source: Source): Boolean = getStores().containsKey(source) +} diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt index 3992a2b68..053fd2c85 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt @@ -29,9 +29,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.R -import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.ApplicationInstaller import foundation.e.apps.data.application.data.Application +import foundation.e.apps.data.enums.Status import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.data.login.exceptions.GPlayLoginException @@ -46,7 +46,6 @@ import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment import foundation.e.apps.ui.home.model.HomeChildRVAdapter import foundation.e.apps.ui.home.model.HomeParentRVAdapter import foundation.e.apps.ui.parentFragment.TimeoutFragment -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import java.util.Locale import javax.inject.Inject @@ -183,7 +182,9 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall clearAndRestartGPlayLogin() true } + return } + homeViewModel.loadInMemoryData() } private fun shouldLoadData() = homeViewModel.haveSourcesChanged() || !homeViewModel.hasData() diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index 3e57bace0..7aed470c3 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -28,12 +28,14 @@ import foundation.e.apps.data.StoreRepository import foundation.e.apps.data.Stores import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Home +import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject @HiltViewModel @@ -161,4 +163,10 @@ class HomeViewModel @Inject constructor( return false } + + fun loadInMemoryData() { + val data = homeScreenData.value?.data ?: emptyList() + Timber.d("Loading in-memory home screen data, size = ${data.size}") + homeScreenData.postValue(ResultSupreme.create(ResultStatus.OK, data)) + } } diff --git a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt index b7e4a7673..e0e92eb28 100644 --- a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt +++ b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt @@ -21,7 +21,6 @@ package foundation.e.apps.category import android.content.Context import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.aurora.gplayapi.data.models.Category -import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.R import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.Stores @@ -35,8 +34,9 @@ import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.install.pkg.PwaManager +import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.install.pkg.AppLoungePackageManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.util.MainCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest @@ -81,6 +81,9 @@ class CategoryApiTest { @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository + @Mock + private lateinit var appLoungePreference: AppLoungePreference + private lateinit var fakeStores: Stores private lateinit var categoryApi: CategoryApi @@ -91,7 +94,7 @@ class CategoryApiTest { val applicationDataManager = ApplicationDataManager(appLoungePackageManager, pwaManager) - fakeStores = Stores(gPlayAPIRepository, cleanApkAppsRepository, cleanApkPWARepository) + fakeStores = Stores(gPlayAPIRepository, cleanApkAppsRepository, cleanApkPWARepository, appLoungePreference) val appSourcesContainer = AppSourcesContainer(gPlayAPIRepository, cleanApkAppsRepository, cleanApkPWARepository) @@ -118,6 +121,8 @@ class CategoryApiTest { Mockito.`when`(context.getString(eq(R.string.pwa))).thenReturn("PWA") + Mockito.`when`(appLoungePreference.isPWASelected()).thenReturn(true) + val categoryListResponse = categoryApi.getCategoriesList(CategoryType.APPLICATION) @@ -133,8 +138,11 @@ class CategoryApiTest { Mockito.`when`( cleanApkAppsRepository.getCategories() ).thenReturn(response) + Mockito.`when`(context.getString(eq(R.string.open_source))).thenReturn("Open source") + Mockito.`when`(appLoungePreference.isOpenSourceSelected()).thenReturn(true) + fakeStores.disableStore(Source.PWA) fakeStores.disableStore(Source.PLAY_STORE) @@ -152,6 +160,8 @@ class CategoryApiTest { gPlayAPIRepository.getCategories(CategoryType.APPLICATION) ).thenReturn(categories) + Mockito.`when`(appLoungePreference.isGplaySelected()).thenReturn(true) + fakeStores.disableStore(Source.PWA) fakeStores.disableStore(Source.OPEN_SOURCE) @@ -163,11 +173,12 @@ class CategoryApiTest { @Test fun `getCategory when gplay source is selected return error`() = runTest { - Mockito.`when`( gPlayAPIRepository.getCategories(CategoryType.APPLICATION) - ).thenThrow() - + ).thenThrow(RuntimeException()) + + Mockito.`when`(appLoungePreference.isGplaySelected()).thenReturn(true) + fakeStores.disableStore(Source.PWA) fakeStores.disableStore(Source.OPEN_SOURCE) @@ -204,6 +215,9 @@ class CategoryApiTest { Mockito.`when`(context.getString(eq(R.string.open_source))).thenReturn("Open source") Mockito.`when`(context.getString(eq(R.string.pwa))).thenReturn("pwa") + Mockito.`when`(appLoungePreference.isGplaySelected()).thenReturn(true) + Mockito.`when`(appLoungePreference.isOpenSourceSelected()).thenReturn(true) + Mockito.`when`(appLoungePreference.isPWASelected()).thenReturn(true) val categoryListResponse = categoryApi.getCategoriesList(CategoryType.APPLICATION) -- GitLab From e4b99f05bea4341f46c7b43d53c922ddc81293c0 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Wed, 12 Mar 2025 14:12:52 +0600 Subject: [PATCH 2/6] refactor: refactor store preference methods and enhance clarity Replace ambiguous method names in `AppLoungePreference` for consistency and clarity, changing `isGplaySelected` to `isPlayStoreSelected`. Implement enable/disable methods for store preferences, integrating these changes across affected classes. Remove redundant mutable map storage in `Stores` class, relying on dynamic store retrieval. Update copyright information. --- .../java/foundation/e/apps/data/Stores.kt | 55 +++++++++++++------ .../e/apps/data/login/LoginCommon.kt | 18 +++--- .../apps/data/login/PlayStoreAuthenticator.kt | 9 +-- .../data/preference/AppLoungePreference.kt | 23 ++++---- .../e/apps/FakeAppLoungePreference.kt | 5 +- .../e/apps/category/CategoryApiTest.kt | 7 ++- 6 files changed, 71 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/Stores.kt b/app/src/main/java/foundation/e/apps/data/Stores.kt index 0a6215478..2437dbc87 100644 --- a/app/src/main/java/foundation/e/apps/data/Stores.kt +++ b/app/src/main/java/foundation/e/apps/data/Stores.kt @@ -1,8 +1,30 @@ +/* + * Copyright (C) 2025 e Foundation + * Copyright (C) 2024 MURENA SAS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package foundation.e.apps.data import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.enums.Source +import foundation.e.apps.data.enums.Source.OPEN_SOURCE +import foundation.e.apps.data.enums.Source.PLAY_STORE +import foundation.e.apps.data.enums.Source.PWA import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.data.preference.AppLoungePreference import javax.inject.Inject @@ -16,14 +38,6 @@ class Stores @Inject constructor( private val appLoungePreference: AppLoungePreference ) { - private val defaultStores = mapOf( - Source.OPEN_SOURCE to cleanApkAppsRepository, - Source.PWA to cleanApkPwaRepository, - Source.PLAY_STORE to playStoreRepository - ) - - private val stores = defaultStores.toMutableMap() - /** * Retrieves a map of enabled store repositories based on user preferences. * @@ -31,31 +45,38 @@ class Stores @Inject constructor( * the values are their corresponding [StoreRepository] instances. */ fun getStores(): Map { - val showPlayStoreApps = appLoungePreference.isGplaySelected() val showOpenSourceApps = appLoungePreference.isOpenSourceSelected() val showPwaApps = appLoungePreference.isPWASelected() + val showPlayStoreApps = appLoungePreference.isPlayStoreSelected() return buildMap { if (showPlayStoreApps) { - put(Source.PLAY_STORE, playStoreRepository) + put(PLAY_STORE, playStoreRepository) } if (showOpenSourceApps) { - put(Source.OPEN_SOURCE, cleanApkAppsRepository) + put(OPEN_SOURCE, cleanApkAppsRepository) } if (showPwaApps) { - put(Source.PWA, cleanApkPwaRepository) + put(PWA, cleanApkPwaRepository) } } } - fun getStore(source: Source): StoreRepository? = stores[source] + fun getStore(source: Source): StoreRepository? = getStores()[source] - fun enableStore(source: Source) { - val repository = defaultStores[source] ?: throw IllegalStateException("store not found") - stores[source] = repository + fun enableStore(source: Source) = when (source) { + OPEN_SOURCE -> appLoungePreference.enableOpenSource() + PWA -> appLoungePreference.enablePwa() + PLAY_STORE -> appLoungePreference.enablePlayStore() + else -> error("No matching Store found for $source.") } - fun disableStore(source: Source) = stores.remove(source) + fun disableStore(source: Source) = when (source) { + OPEN_SOURCE -> appLoungePreference.disableOpenSource() + PWA -> appLoungePreference.disablePwa() + PLAY_STORE -> appLoungePreference.disablePlayStore() + else -> error("No matching Store found for $source.") + } fun isStoreEnabled(source: Source): Boolean = getStores().containsKey(source) } diff --git a/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt b/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt index 137ecf433..bf9a09543 100644 --- a/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt +++ b/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt @@ -1,4 +1,5 @@ /* + * Copyright (C) 2025 e Foundation * Copyright (C) 2019-2022 E FOUNDATION * * This program is free software: you can redistribute it and/or modify @@ -17,7 +18,6 @@ package foundation.e.apps.data.login -import foundation.e.apps.data.Constants import foundation.e.apps.data.enums.User import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.data.preference.AppLoungePreference @@ -48,9 +48,11 @@ class LoginCommon @Inject constructor( } suspend fun setNoGoogleMode() { - appLoungePreference.setSource(Constants.PREFERENCE_SHOW_FOSS, true) - appLoungePreference.setSource(Constants.PREFERENCE_SHOW_PWA, true) - appLoungePreference.setSource(Constants.PREFERENCE_SHOW_GPLAY, false) + appLoungePreference.run { + disablePlayStore() + enableOpenSource() + enablePwa() + } appLoungeDataStore.saveUserType(User.NO_GOOGLE) } @@ -58,8 +60,10 @@ class LoginCommon @Inject constructor( appLoungeDataStore.destroyCredentials() appLoungeDataStore.saveUserType(null) // reset app source preferences on logout. - appLoungePreference.setSource(Constants.PREFERENCE_SHOW_FOSS, true) - appLoungePreference.setSource(Constants.PREFERENCE_SHOW_PWA, true) - appLoungePreference.setSource(Constants.PREFERENCE_SHOW_GPLAY, true) + appLoungePreference.run { + enableOpenSource() + enablePwa() + enablePlayStore() + } } } diff --git a/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt b/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt index 823c84f63..b46b4ff07 100644 --- a/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt +++ b/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt @@ -1,4 +1,5 @@ /* + * Copyright (C) 2025 e Foundation * Copyright (C) 2019-2022 E FOUNDATION * * This program is free software: you can redistribute it and/or modify @@ -24,14 +25,14 @@ import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.User -import foundation.e.apps.data.login.api.PlayStoreLoginManagerFactory -import foundation.e.apps.data.login.api.PlayStoreLoginManager import foundation.e.apps.data.login.api.GoogleLoginManager +import foundation.e.apps.data.login.api.PlayStoreLoginManager +import foundation.e.apps.data.login.api.PlayStoreLoginManagerFactory import foundation.e.apps.data.login.api.PlayStoreLoginWrapper import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.data.preference.AppLoungePreference -import foundation.e.apps.data.retryWithBackoff import foundation.e.apps.data.preference.getSync +import foundation.e.apps.data.retryWithBackoff import timber.log.Timber import java.util.Locale import javax.inject.Inject @@ -73,7 +74,7 @@ class PlayStoreAuthenticator @Inject constructor( */ return false } - return appLoungePreference.isGplaySelected() + return appLoungePreference.isPlayStoreSelected() } /** diff --git a/app/src/main/java/foundation/e/apps/data/preference/AppLoungePreference.kt b/app/src/main/java/foundation/e/apps/data/preference/AppLoungePreference.kt index aca4e2188..1a67ad7ea 100644 --- a/app/src/main/java/foundation/e/apps/data/preference/AppLoungePreference.kt +++ b/app/src/main/java/foundation/e/apps/data/preference/AppLoungePreference.kt @@ -1,4 +1,5 @@ /* + * Copyright (C) 2025 e Foundation * Copyright (C) 2021-2024 MURENA SAS * * This program is free software: you can redistribute it and/or modify @@ -19,6 +20,7 @@ package foundation.e.apps.data.preference import android.content.Context +import androidx.core.content.edit import androidx.preference.PreferenceManager import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.OpenForTesting @@ -29,6 +31,7 @@ import foundation.e.apps.data.Constants.PREFERENCE_SHOW_PWA import javax.inject.Inject import javax.inject.Singleton +@Suppress("TooManyFunctions") @Singleton @OpenForTesting class AppLoungePreference @Inject constructor( @@ -50,13 +53,15 @@ class AppLoungePreference @Inject constructor( fun isOpenSourceSelected() = preferenceManager.getBoolean(PREFERENCE_SHOW_FOSS, true) fun isPWASelected() = preferenceManager.getBoolean(PREFERENCE_SHOW_PWA, true) - fun isGplaySelected() = preferenceManager.getBoolean(PREFERENCE_SHOW_GPLAY, true) + fun isPlayStoreSelected() = preferenceManager.getBoolean(PREFERENCE_SHOW_GPLAY, true) - fun disableGplay() = preferenceManager.edit().putBoolean(PREFERENCE_SHOW_GPLAY, false).apply() + fun disablePlayStore() = preferenceManager.edit { putBoolean(PREFERENCE_SHOW_GPLAY, false) } + fun disableOpenSource() = preferenceManager.edit { putBoolean(PREFERENCE_SHOW_FOSS, false) } + fun disablePwa() = preferenceManager.edit { putBoolean(PREFERENCE_SHOW_PWA, false) } - fun autoUpdatePreferred(): Boolean { - return preferenceManager.getBoolean("updateInstallAuto", false) - } + fun enablePlayStore() = preferenceManager.edit { putBoolean(PREFERENCE_SHOW_GPLAY, true) } + fun enableOpenSource() = preferenceManager.edit { putBoolean(PREFERENCE_SHOW_FOSS, true) } + fun enablePwa() = preferenceManager.edit { putBoolean(PREFERENCE_SHOW_PWA, true) } fun getUpdateInterval() = preferenceManager.getString( context.getString(R.string.update_check_intervals), @@ -67,12 +72,4 @@ class AppLoungePreference @Inject constructor( context.getString(R.string.update_apps_from_other_stores), true ) - - fun setSource(source: String, value: Boolean) { - val editor = preferenceManager.edit() - editor.run { - this.putBoolean(source, value) - } - editor.apply() - } } diff --git a/app/src/test/java/foundation/e/apps/FakeAppLoungePreference.kt b/app/src/test/java/foundation/e/apps/FakeAppLoungePreference.kt index 7fca0e5ba..00e3c57b3 100644 --- a/app/src/test/java/foundation/e/apps/FakeAppLoungePreference.kt +++ b/app/src/test/java/foundation/e/apps/FakeAppLoungePreference.kt @@ -1,5 +1,6 @@ /* - * Copyright (C) 2022 ECORP + * Copyright (C) 2025 e Foundation + * Copyright (C) 2022 ECORP * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +35,7 @@ class FakeAppLoungePreference(context: Context) : AppLoungePreference(context) { return isOpenSourceelectedFake } - override fun isGplaySelected(): Boolean { + override fun isPlayStoreSelected(): Boolean { return isGplaySelectedFake } diff --git a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt index e0e92eb28..e0718f55f 100644 --- a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt +++ b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt @@ -1,4 +1,5 @@ /* + * Copyright (C) 2025 e Foundation * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * @@ -160,7 +161,7 @@ class CategoryApiTest { gPlayAPIRepository.getCategories(CategoryType.APPLICATION) ).thenReturn(categories) - Mockito.`when`(appLoungePreference.isGplaySelected()).thenReturn(true) + Mockito.`when`(appLoungePreference.isPlayStoreSelected()).thenReturn(true) fakeStores.disableStore(Source.PWA) fakeStores.disableStore(Source.OPEN_SOURCE) @@ -177,7 +178,7 @@ class CategoryApiTest { gPlayAPIRepository.getCategories(CategoryType.APPLICATION) ).thenThrow(RuntimeException()) - Mockito.`when`(appLoungePreference.isGplaySelected()).thenReturn(true) + Mockito.`when`(appLoungePreference.isPlayStoreSelected()).thenReturn(true) fakeStores.disableStore(Source.PWA) fakeStores.disableStore(Source.OPEN_SOURCE) @@ -215,7 +216,7 @@ class CategoryApiTest { Mockito.`when`(context.getString(eq(R.string.open_source))).thenReturn("Open source") Mockito.`when`(context.getString(eq(R.string.pwa))).thenReturn("pwa") - Mockito.`when`(appLoungePreference.isGplaySelected()).thenReturn(true) + Mockito.`when`(appLoungePreference.isPlayStoreSelected()).thenReturn(true) Mockito.`when`(appLoungePreference.isOpenSourceSelected()).thenReturn(true) Mockito.`when`(appLoungePreference.isPWASelected()).thenReturn(true) -- GitLab From 30db1004f435c493a06a8d50b575fcc9d4a1ca0f Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Wed, 12 Mar 2025 14:15:42 +0600 Subject: [PATCH 3/6] chore: update copyright --- app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index 7aed470c3..c02c48a3b 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -1,5 +1,5 @@ /* - * Apps Quickly and easily install Android apps onto your device! + * Copyright (C) 2025 e Foundation * Copyright (C) 2021 E FOUNDATION * * This program is free software: you can redistribute it and/or modify -- GitLab From 9452b8385a47d15ab251ea344d6ada8699f8f8d7 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Wed, 12 Mar 2025 16:35:21 +0600 Subject: [PATCH 4/6] refactor: remove redundant call for loading home data --- app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt index 053fd2c85..da8abc757 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt @@ -182,9 +182,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall clearAndRestartGPlayLogin() true } - return } - homeViewModel.loadInMemoryData() } private fun shouldLoadData() = homeViewModel.haveSourcesChanged() || !homeViewModel.hasData() -- GitLab From cfc60aeb02bea7aa6343a283bc62412ccde91860 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Wed, 12 Mar 2025 17:10:23 +0600 Subject: [PATCH 5/6] refactor: remove redundant method from HomeViewModel --- .../main/java/foundation/e/apps/ui/home/HomeViewModel.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index c02c48a3b..07bdb9e52 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -28,14 +28,12 @@ import foundation.e.apps.data.StoreRepository import foundation.e.apps.data.Stores import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Home -import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch -import timber.log.Timber import javax.inject.Inject @HiltViewModel @@ -163,10 +161,4 @@ class HomeViewModel @Inject constructor( return false } - - fun loadInMemoryData() { - val data = homeScreenData.value?.data ?: emptyList() - Timber.d("Loading in-memory home screen data, size = ${data.size}") - homeScreenData.postValue(ResultSupreme.create(ResultStatus.OK, data)) - } } -- GitLab From 23e831f5daa36dd027096a300c66a83926d10f5b Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Wed, 12 Mar 2025 20:03:04 +0600 Subject: [PATCH 6/6] chore: update copyright --- app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt | 4 ++-- .../foundation/e/apps/data/login/PlayStoreAuthenticator.kt | 4 ++-- app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt | 3 ++- app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt b/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt index bf9a09543..8ba19f5ed 100644 --- a/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt +++ b/app/src/main/java/foundation/e/apps/data/login/LoginCommon.kt @@ -1,6 +1,5 @@ /* - * Copyright (C) 2025 e Foundation - * Copyright (C) 2019-2022 E FOUNDATION + * Copyright (C) 2019-2025 e Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * */ package foundation.e.apps.data.login diff --git a/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt b/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt index b46b4ff07..bb93cc826 100644 --- a/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt +++ b/app/src/main/java/foundation/e/apps/data/login/PlayStoreAuthenticator.kt @@ -1,6 +1,5 @@ /* - * Copyright (C) 2025 e Foundation - * Copyright (C) 2019-2022 E FOUNDATION + * Copyright (C) 2019-2025 e Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * */ package foundation.e.apps.data.login diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt index da8abc757..3992a2b68 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt @@ -29,9 +29,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.R +import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.ApplicationInstaller import foundation.e.apps.data.application.data.Application -import foundation.e.apps.data.enums.Status import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.data.login.exceptions.GPlayLoginException @@ -46,6 +46,7 @@ import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment import foundation.e.apps.ui.home.model.HomeChildRVAdapter import foundation.e.apps.ui.home.model.HomeParentRVAdapter import foundation.e.apps.ui.parentFragment.TimeoutFragment +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import java.util.Locale import javax.inject.Inject diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index 07bdb9e52..3e57bace0 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2025 e Foundation + * Apps Quickly and easily install Android apps onto your device! * Copyright (C) 2021 E FOUNDATION * * This program is free software: you can redistribute it and/or modify -- GitLab