diff --git a/app/src/main/java/foundation/e/apps/api/StoreRepository.kt b/app/src/main/java/foundation/e/apps/api/StoreRepository.kt
new file mode 100644
index 0000000000000000000000000000000000000000..96d182cc35dea23e577c236cc8c666501f19f385
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/api/StoreRepository.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright MURENA SAS 2023
+ * Apps Quickly and easily install Android apps onto your device!
+ *
+ * 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.api
+
+interface StoreRepository {
+ suspend fun getHomeScreenData(): Any
+ suspend fun getSearchResult(query: String): Any
+ suspend fun getSearchSuggestions(query: String): Any
+}
diff --git a/app/src/main/java/foundation/e/apps/api/cleanapk/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/api/cleanapk/CleanApkAppsRepository.kt
new file mode 100644
index 0000000000000000000000000000000000000000..709b22f9e746f7db899cc80c507696cb6421fb9a
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/api/cleanapk/CleanApkAppsRepository.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright MURENA SAS 2023
+ * Apps Quickly and easily install Android apps onto your device!
+ *
+ * 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.api.cleanapk
+
+import foundation.e.apps.api.StoreRepository
+import foundation.e.apps.api.cleanapk.data.home.HomeScreen
+import foundation.e.apps.api.cleanapk.data.search.Search
+import retrofit2.Response
+
+class CleanApkAppsRepository(
+ private val cleanAPKInterface: CleanAPKInterface,
+) : StoreRepository {
+
+ override suspend fun getHomeScreenData(): Response {
+ return cleanAPKInterface.getHomeScreenData(
+ CleanAPKInterface.APP_TYPE_ANY,
+ CleanAPKInterface.APP_SOURCE_FOSS
+ )
+ }
+
+ override suspend fun getSearchResult(query: String): Response {
+ return cleanAPKInterface.searchApps(
+ query,
+ CleanAPKInterface.APP_SOURCE_FOSS,
+ CleanAPKInterface.APP_TYPE_ANY,
+ 20,
+ 1,
+ null
+ )
+ }
+
+ override suspend fun getSearchSuggestions(query: String): Any {
+ TODO("Not yet implemented")
+ }
+}
diff --git a/app/src/main/java/foundation/e/apps/api/cleanapk/CleanApkPWARepository.kt b/app/src/main/java/foundation/e/apps/api/cleanapk/CleanApkPWARepository.kt
new file mode 100644
index 0000000000000000000000000000000000000000..fa4ad5c275a0a23da6a6604367809bdcaf49e375
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/api/cleanapk/CleanApkPWARepository.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright MURENA SAS 2023
+ * Apps Quickly and easily install Android apps onto your device!
+ *
+ * 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.api.cleanapk
+
+import foundation.e.apps.api.StoreRepository
+import foundation.e.apps.api.cleanapk.data.search.Search
+import retrofit2.Response
+
+class CleanApkPWARepository(
+ private val cleanAPKInterface: CleanAPKInterface,
+) : StoreRepository {
+
+ override suspend fun getHomeScreenData(): Any {
+ return cleanAPKInterface.getHomeScreenData(
+ CleanAPKInterface.APP_TYPE_PWA,
+ CleanAPKInterface.APP_SOURCE_ANY
+ )
+ }
+
+ override suspend fun getSearchResult(query: String): Response {
+ return cleanAPKInterface.searchApps(
+ query,
+ CleanAPKInterface.APP_SOURCE_ANY,
+ CleanAPKInterface.APP_TYPE_PWA,
+ 20,
+ 1,
+ null
+ )
+ }
+
+ override suspend fun getSearchSuggestions(query: String): Any {
+ TODO("Not yet implemented")
+ }
+}
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 889cbb9993a6a285b02b47e9e803dc5b37bbde12..2eba6f4be2ffd150e7f9bfa24a40208859658b33 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
@@ -22,6 +22,7 @@ import android.content.Context
import android.text.format.Formatter
import androidx.lifecycle.LiveData
import androidx.lifecycle.LiveDataScope
+import androidx.lifecycle.asLiveData
import androidx.lifecycle.liveData
import androidx.lifecycle.map
import com.aurora.gplayapi.Constants
@@ -32,14 +33,15 @@ import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.models.Category
import com.aurora.gplayapi.data.models.StreamBundle
import com.aurora.gplayapi.data.models.StreamCluster
-import com.aurora.gplayapi.helpers.TopChartsHelper
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.R
import foundation.e.apps.api.ResultSupreme
+import foundation.e.apps.api.StoreRepository
import foundation.e.apps.api.cleanapk.CleanAPKInterface
import foundation.e.apps.api.cleanapk.CleanAPKRepository
import foundation.e.apps.api.cleanapk.data.categories.Categories
import foundation.e.apps.api.cleanapk.data.home.Home
+import foundation.e.apps.api.cleanapk.data.home.HomeScreen
import foundation.e.apps.api.cleanapk.data.search.Search
import foundation.e.apps.api.fdroid.FdroidWebInterface
import foundation.e.apps.api.fused.data.FusedApp
@@ -63,11 +65,17 @@ import foundation.e.apps.utils.enums.isUnFiltered
import foundation.e.apps.utils.modules.PWAManagerModule
import foundation.e.apps.utils.modules.PreferenceManagerModule
import kotlinx.coroutines.TimeoutCancellationException
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withTimeout
+import retrofit2.Response
import timber.log.Timber
import javax.inject.Inject
+import javax.inject.Named
import javax.inject.Singleton
+typealias GplaySearchResultFlow = Flow, Boolean>>>
+
@Singleton
class FusedAPIImpl @Inject constructor(
private val cleanAPKRepository: CleanAPKRepository,
@@ -76,6 +84,9 @@ class FusedAPIImpl @Inject constructor(
private val pwaManagerModule: PWAManagerModule,
private val preferenceManagerModule: PreferenceManagerModule,
private val fdroidWebInterface: FdroidWebInterface,
+ @Named("gplayRepository") private val gplayRepository: StoreRepository,
+ @Named("cleanApkAppsRepository") private val cleanApkAppsRepository: StoreRepository,
+ @Named("cleanApkPWARepository") private val cleanApkPWARepository: StoreRepository,
@ApplicationContext private val context: Context
) {
@@ -152,20 +163,16 @@ class FusedAPIImpl @Inject constructor(
})
Source.OPEN -> runCodeBlockWithTimeout({
- val response = cleanAPKRepository.getHomeScreenData(
- CleanAPKInterface.APP_TYPE_ANY,
- CleanAPKInterface.APP_SOURCE_FOSS
- ).body()
+ val response =
+ (cleanApkAppsRepository.getHomeScreenData() as Response).body()
response?.home?.let {
priorList.addAll(generateCleanAPKHome(it, APP_TYPE_OPEN))
}
})
Source.PWA -> runCodeBlockWithTimeout({
- val response = cleanAPKRepository.getHomeScreenData(
- CleanAPKInterface.APP_TYPE_PWA,
- CleanAPKInterface.APP_SOURCE_ANY
- ).body()
+ val response =
+ (cleanApkPWARepository.getHomeScreenData() as Response).body()
response?.home?.let {
priorList.addAll(generateCleanAPKHome(it, APP_TYPE_PWA))
}
@@ -272,7 +279,7 @@ class FusedAPIImpl @Inject constructor(
authData,
searchResult,
packageSpecificResults
- )
+ ).asLiveData()
)
}
}
@@ -286,11 +293,9 @@ class FusedAPIImpl @Inject constructor(
): ResultSupreme, Boolean>> {
val pwaApps: MutableList = mutableListOf()
val status = fusedAPIImpl.runCodeBlockWithTimeout({
- getCleanAPKSearchResults(
- query,
- CleanAPKInterface.APP_SOURCE_ANY,
- CleanAPKInterface.APP_TYPE_PWA
- ).apply {
+ val apps =
+ (cleanApkPWARepository.getSearchResult(query) as Response).body()?.apps
+ apps?.apply {
if (this.isNotEmpty()) {
pwaApps.addAll(this)
}
@@ -314,27 +319,26 @@ class FusedAPIImpl @Inject constructor(
)
}
- private fun fetchGplaySearchResults(
+ private suspend fun fetchGplaySearchResults(
query: String,
authData: AuthData,
searchResult: MutableList,
packageSpecificResults: ArrayList
- ): LiveData, Boolean>>> =
- getGplaySearchResults(query, authData).map {
- if (it.first.isNotEmpty()) {
- searchResult.addAll(it.first)
- }
- ResultSupreme.Success(
- Pair(
- filterWithKeywordSearch(
- searchResult,
- packageSpecificResults,
- query
- ),
- it.second
- )
- )
+ ): GplaySearchResultFlow = getGplaySearchResult(query, authData).map {
+ if (it.first.isNotEmpty()) {
+ searchResult.addAll(it.first)
}
+ ResultSupreme.Success(
+ Pair(
+ filterWithKeywordSearch(
+ searchResult,
+ packageSpecificResults,
+ query
+ ),
+ it.second
+ )
+ )
+ }
private suspend fun fetchOpenSourceSearchResult(
fusedAPIImpl: FusedAPIImpl,
@@ -469,7 +473,7 @@ class FusedAPIImpl @Inject constructor(
}
suspend fun getSearchSuggestions(query: String, authData: AuthData): List {
- return gPlayAPIRepository.getSearchSuggestions(query, authData)
+ return gplayRepository.getSearchSuggestions(query) as List
}
suspend fun getOnDemandModule(
@@ -1052,7 +1056,7 @@ class FusedAPIImpl @Inject constructor(
private fun getCategoryIconName(category: FusedCategory): String {
var categoryTitle = if (category.tag.getOperationalTag()
- .contentEquals(AppTag.GPlay().getOperationalTag())
+ .contentEquals(AppTag.GPlay().getOperationalTag())
) category.id else category.title
if (categoryTitle.contains(CATEGORY_TITLE_REPLACEABLE_CONJUNCTION)) {
@@ -1174,7 +1178,7 @@ class FusedAPIImpl @Inject constructor(
): List {
val list = mutableListOf()
val response =
- cleanAPKRepository.searchApps(keyword, source, type, nres, page, by).body()?.apps
+ (cleanApkAppsRepository.getSearchResult(keyword) as Response).body()?.apps
response?.forEach {
it.updateStatus()
@@ -1190,7 +1194,8 @@ class FusedAPIImpl @Inject constructor(
query: String,
authData: AuthData
): LiveData, Boolean>> {
- val searchResults = gPlayAPIRepository.getSearchResults(query, authData, ::replaceWithFDroid)
+ val searchResults =
+ gPlayAPIRepository.getSearchResults(query, authData, ::replaceWithFDroid)
return searchResults.map {
Pair(
it.first,
@@ -1199,6 +1204,20 @@ class FusedAPIImpl @Inject constructor(
}
}
+ private suspend fun getGplaySearchResult(
+ query: String,
+ authData: AuthData
+ ): Flow, Boolean>> {
+ val searchResults = gplayRepository.getSearchResult(query) as Flow, Boolean>>
+ return searchResults.map {
+ val fusedAppList = it.first.map { app -> replaceWithFDroid(app) }
+ Pair(
+ fusedAppList,
+ it.second
+ )
+ }
+ }
+
/*
* This function will replace a GPlay app with F-Droid app if exists,
* else will show the GPlay app itself.
@@ -1320,24 +1339,16 @@ class FusedAPIImpl @Inject constructor(
private suspend fun fetchGPlayHome(authData: AuthData): List {
val list = mutableListOf()
- val homeElements = mutableMapOf(
- context.getString(R.string.topselling_free_apps) to mapOf(TopChartsHelper.Chart.TOP_SELLING_FREE to TopChartsHelper.Type.APPLICATION),
- context.getString(R.string.topselling_free_games) to mapOf(TopChartsHelper.Chart.TOP_SELLING_FREE to TopChartsHelper.Type.GAME),
- context.getString(R.string.topgrossing_apps) to mapOf(TopChartsHelper.Chart.TOP_GROSSING to TopChartsHelper.Type.APPLICATION),
- context.getString(R.string.topgrossing_games) to mapOf(TopChartsHelper.Chart.TOP_GROSSING to TopChartsHelper.Type.GAME),
- context.getString(R.string.movers_shakers_apps) to mapOf(TopChartsHelper.Chart.MOVERS_SHAKERS to TopChartsHelper.Type.APPLICATION),
- context.getString(R.string.movers_shakers_games) to mapOf(TopChartsHelper.Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME),
- )
- homeElements.forEach {
- val chart = it.value.keys.iterator().next()
- val type = it.value.values.iterator().next()
- val result = gPlayAPIRepository.getTopApps(type, chart, authData).map { app ->
+ val gplayHomeData = gplayRepository.getHomeScreenData() as Map>
+ gplayHomeData.map {
+ val fusedApps = it.value.map { app ->
app.transformToFusedApp().apply {
updateFilterLevel(authData)
}
}
- list.add(FusedHome(it.key, result))
+ list.add(FusedHome(it.key, fusedApps))
}
+ Timber.d("===> $list")
return list
}
diff --git a/app/src/main/java/foundation/e/apps/api/gplay/GplayRepository.kt b/app/src/main/java/foundation/e/apps/api/gplay/GplayRepository.kt
new file mode 100644
index 0000000000000000000000000000000000000000..76ed53e79f6dd1da6276f8675a636fdbaeafdf02
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/api/gplay/GplayRepository.kt
@@ -0,0 +1,206 @@
+/*
+ * Copyright MURENA SAS 2023
+ * Apps Quickly and easily install Android apps onto your device!
+ *
+ * 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.api.gplay
+
+import android.content.Context
+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 com.aurora.gplayapi.helpers.SearchHelper
+import com.aurora.gplayapi.helpers.TopChartsHelper
+import dagger.hilt.android.qualifiers.ApplicationContext
+import foundation.e.apps.R
+import foundation.e.apps.api.StoreRepository
+import foundation.e.apps.api.gplay.utils.GPlayHttpClient
+import foundation.e.apps.login.LoginSourceRepository
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.FlowCollector
+import kotlinx.coroutines.flow.flow
+import kotlinx.coroutines.flow.flowOn
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+class GplayRepository @Inject constructor(
+ @ApplicationContext private val context: Context,
+ private val gPlayHttpClient: GPlayHttpClient,
+ private val loginSourceRepository: LoginSourceRepository
+) : StoreRepository {
+
+ override suspend fun getHomeScreenData(): Any {
+ val homeScreenData = mutableMapOf>()
+ val homeElements = createTopChartElements()
+
+ homeElements.forEach {
+ val chart = it.value.keys.iterator().next()
+ val type = it.value.values.iterator().next()
+ val result = getTopApps(type, chart, loginSourceRepository.gplayAuth!!)
+ homeScreenData[it.key] = result
+ }
+
+ return homeScreenData
+ }
+
+ private fun createTopChartElements() = mutableMapOf(
+ context.getString(R.string.topselling_free_apps) to mapOf(TopChartsHelper.Chart.TOP_SELLING_FREE to TopChartsHelper.Type.APPLICATION),
+ context.getString(R.string.topselling_free_games) to mapOf(TopChartsHelper.Chart.TOP_SELLING_FREE to TopChartsHelper.Type.GAME),
+ context.getString(R.string.topgrossing_apps) to mapOf(TopChartsHelper.Chart.TOP_GROSSING to TopChartsHelper.Type.APPLICATION),
+ context.getString(R.string.topgrossing_games) to mapOf(TopChartsHelper.Chart.TOP_GROSSING to TopChartsHelper.Type.GAME),
+ context.getString(R.string.movers_shakers_apps) to mapOf(TopChartsHelper.Chart.MOVERS_SHAKERS to TopChartsHelper.Type.APPLICATION),
+ context.getString(R.string.movers_shakers_games) to mapOf(TopChartsHelper.Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME),
+ )
+
+ override suspend fun getSearchResult(query: String): Flow, Boolean>> {
+ return flow {
+ /*
+ * Variable names and logic made same as that of Aurora store.
+ * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171
+ */
+ val searchHelper =
+ SearchHelper(loginSourceRepository.gplayAuth!!).using(gPlayHttpClient)
+ val searchBundle = searchHelper.searchResults(query)
+
+ val initialReplacedList = mutableListOf()
+ val INITIAL_LIMIT = 4
+
+ emitReplacedList(
+ this@flow,
+ initialReplacedList,
+ INITIAL_LIMIT,
+ searchBundle,
+ true,
+ )
+
+ var nextSubBundleSet: MutableSet
+ do {
+ nextSubBundleSet = fetchNextSubBundle(
+ searchBundle,
+ searchHelper,
+ this@flow,
+ initialReplacedList,
+ INITIAL_LIMIT
+ )
+ } while (nextSubBundleSet.isNotEmpty())
+
+ /*
+ * If initialReplacedList size is less than INITIAL_LIMIT,
+ * it means the results were very less and nothing has been emitted so far.
+ * Hence emit the list.
+ */
+ if (initialReplacedList.size < INITIAL_LIMIT) {
+ emitInMain(this@flow, initialReplacedList, false)
+ }
+ }.flowOn(Dispatchers.IO)
+ }
+
+ private suspend fun fetchNextSubBundle(
+ searchBundle: SearchBundle,
+ searchHelper: SearchHelper,
+ scope: FlowCollector, Boolean>>,
+ accumulationList: MutableList,
+ accumulationLimit: Int,
+ ): MutableSet {
+ val nextSubBundleSet = searchBundle.subBundles
+ val newSearchBundle = searchHelper.next(nextSubBundleSet)
+ if (newSearchBundle.appList.isNotEmpty()) {
+ searchBundle.apply {
+ subBundles.clear()
+ subBundles.addAll(newSearchBundle.subBundles)
+ emitReplacedList(
+ scope,
+ accumulationList,
+ accumulationLimit,
+ newSearchBundle,
+ nextSubBundleSet.isNotEmpty(),
+ )
+ }
+ }
+ return nextSubBundleSet
+ }
+
+ override suspend fun getSearchSuggestions(query: String): List {
+ val searchData = mutableListOf()
+ withContext(Dispatchers.IO) {
+ val searchHelper =
+ SearchHelper(loginSourceRepository.gplayAuth!!).using(gPlayHttpClient)
+ searchData.addAll(searchHelper.searchSuggestions(query))
+ }
+ return searchData.filter { it.suggestedQuery.isNotBlank() }
+ }
+
+ private suspend fun emitReplacedList(
+ scope: FlowCollector, Boolean>>,
+ accumulationList: MutableList,
+ accumulationLimit: Int,
+ searchBundle: SearchBundle,
+ moreToEmit: Boolean,
+ ) {
+ searchBundle.appList.forEach {
+ when {
+ accumulationList.size < accumulationLimit - 1 -> {
+ /*
+ * If initial limit is 4, add apps to list (without emitting)
+ * till 2 apps.
+ */
+ accumulationList.add(it)
+ }
+
+ accumulationList.size == accumulationLimit - 1 -> {
+ /*
+ * If initial limit is 4, and we have reached till 3 apps,
+ * add the 4th app and emit the list.
+ */
+ accumulationList.add(it)
+ scope.emit(Pair(accumulationList, moreToEmit))
+ emitInMain(scope, accumulationList, moreToEmit)
+ }
+
+ accumulationList.size == accumulationLimit -> {
+ /*
+ * If initial limit is 4, and we have emitted 4 apps,
+ * for all rest of the apps, emit each app one by one.
+ */
+ emitInMain(scope, listOf(it), moreToEmit)
+ }
+ }
+ }
+ }
+
+ private suspend fun emitInMain(
+ scope: FlowCollector, Boolean>>,
+ it: List,
+ moreToEmit: Boolean
+ ) {
+ scope.emit(Pair(it, moreToEmit))
+ }
+
+ private suspend fun getTopApps(
+ type: TopChartsHelper.Type,
+ chart: TopChartsHelper.Chart,
+ authData: AuthData
+ ): List {
+ val topApps = mutableListOf()
+ withContext(Dispatchers.IO) {
+ val topChartsHelper = TopChartsHelper(authData).using(gPlayHttpClient)
+ topApps.addAll(topChartsHelper.getCluster(type, chart).clusterAppList)
+ }
+ return topApps
+ }
+}
diff --git a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt
new file mode 100644
index 0000000000000000000000000000000000000000..102ef6e292be13469afa6bbeb9061e29efe818cb
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright MURENA SAS 2023
+ * Apps Quickly and easily install Android apps onto your device!
+ *
+ * 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.di
+
+
+import android.content.Context
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.android.qualifiers.ApplicationContext
+import dagger.hilt.components.SingletonComponent
+import foundation.e.apps.api.StoreRepository
+import foundation.e.apps.api.cleanapk.CleanAPKInterface
+import foundation.e.apps.api.cleanapk.CleanApkAppDetailApi
+import foundation.e.apps.api.cleanapk.CleanApkAppsRepository
+import foundation.e.apps.api.cleanapk.CleanApkPWARepository
+import foundation.e.apps.api.gplay.GplayRepository
+import foundation.e.apps.api.gplay.utils.GPlayHttpClient
+import foundation.e.apps.login.LoginSourceRepository
+import javax.inject.Named
+import javax.inject.Singleton
+
+@InstallIn(SingletonComponent::class)
+@Module
+object NamedRepositoryModule {
+ @Singleton
+ @Provides
+ @Named("gplayRepository")
+ fun getGplayRepository(
+ @ApplicationContext context: Context,
+ gPlayHttpClient: GPlayHttpClient,
+ loginSourceRepository: LoginSourceRepository
+ ): StoreRepository {
+ return GplayRepository(context, gPlayHttpClient, loginSourceRepository)
+ }
+
+ @Singleton
+ @Provides
+ @Named("cleanApkAppsRepository")
+ fun getCleanApkAppsRepository(
+ cleanAPKInterface: CleanAPKInterface,
+ ): StoreRepository {
+ return CleanApkAppsRepository(cleanAPKInterface)
+ }
+
+ @Singleton
+ @Provides
+ @Named("cleanApkPWARepository")
+ fun getCleanApkPWARepository(
+ cleanAPKInterface: CleanAPKInterface,
+ ): StoreRepository {
+ return CleanApkPWARepository(cleanAPKInterface)
+ }
+}
diff --git a/app/src/main/java/foundation/e/apps/login/LoginSourceRepository.kt b/app/src/main/java/foundation/e/apps/login/LoginSourceRepository.kt
index ddc4bb392f7e478cef09cbdb36ad7ad4de5dfc7f..43dc65c94caaea0b685436ba254acd23425f3be8 100644
--- a/app/src/main/java/foundation/e/apps/login/LoginSourceRepository.kt
+++ b/app/src/main/java/foundation/e/apps/login/LoginSourceRepository.kt
@@ -17,6 +17,7 @@
package foundation.e.apps.login
+import com.aurora.gplayapi.data.models.AuthData
import foundation.e.apps.utils.enums.User
import javax.inject.Inject
import javax.inject.Singleton
@@ -28,6 +29,7 @@ class LoginSourceRepository @Inject constructor(
private val sources: List,
) {
+ var gplayAuth: AuthData? = null
suspend fun getAuthObjects(clearAuthTypes: List = listOf()): List {
val authObjectsLocal = ArrayList()
@@ -37,6 +39,9 @@ class LoginSourceRepository @Inject constructor(
if (source::class.java.simpleName in clearAuthTypes) {
source.clearSavedAuth()
}
+ if (source is LoginSourceGPlay) {
+ gplayAuth = source.getAuthObject().result.data
+ }
authObjectsLocal.add(source.getAuthObject())
}