From dae1667fce6f7f1464b779f62d2bc3728713bbb3 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Fri, 8 Sep 2023 15:21:16 +0600 Subject: [PATCH 1/2] removed redundant login failed dialog --- .../java/foundation/e/apps/MainActivity.kt | 5 ----- .../data/gplay/GplayStoreRepositoryImpl.kt | 21 +++++++++++-------- .../e/apps/data/login/LoginCommon.kt | 4 ++++ .../apps/data/login/LoginSourceRepository.kt | 7 +++++++ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index 98838bd35..ae7d1a5e6 100644 --- a/app/src/main/java/foundation/e/apps/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/MainActivity.kt @@ -139,11 +139,6 @@ class MainActivity : AppCompatActivity() { ) } else if (exception != null) { Timber.e(exception, "Login failed! message: ${exception?.localizedMessage}") - ApplicationDialogFragment( - title = getString(R.string.sign_in_failed_title), - message = getString(R.string.sign_in_failed_desc), - positiveButtonText = getString(R.string.ok) - ).show(supportFragmentManager, TAG) } } } diff --git a/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt index 19461db72..661844aec 100644 --- a/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt @@ -35,13 +35,16 @@ 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.data.enums.User import foundation.e.apps.data.fused.utils.CategoryType import foundation.e.apps.data.gplay.utils.GPlayHttpClient import foundation.e.apps.data.login.LoginSourceRepository +import foundation.e.apps.data.login.exceptions.GPlayLoginException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import timber.log.Timber import javax.inject.Inject +import kotlin.math.log class GplayStoreRepositoryImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -52,7 +55,7 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getHomeScreenData(): Any { val homeScreenData = mutableMapOf>() val homeElements = createTopChartElements() - val authData = loginSourceRepository.gplayAuth ?: return homeScreenData + val authData = loginSourceRepository.gplayAuth!! homeElements.forEach { val chart = it.value.keys.iterator().next() @@ -77,7 +80,7 @@ class GplayStoreRepositoryImpl @Inject constructor( query: String, subBundle: MutableSet? ): Pair, MutableSet> { - var authData = loginSourceRepository.gplayAuth ?: return Pair(emptyList(), mutableSetOf()) + var authData = loginSourceRepository.gplayAuth!! val searchHelper = SearchHelper(authData).using(gPlayHttpClient) @@ -102,7 +105,7 @@ class GplayStoreRepositoryImpl @Inject constructor( } override suspend fun getSearchSuggestions(query: String): List { - val authData = loginSourceRepository.gplayAuth ?: return listOf() + val authData = loginSourceRepository.gplayAuth!! val searchData = mutableListOf() withContext(Dispatchers.IO) { @@ -113,7 +116,7 @@ class GplayStoreRepositoryImpl @Inject constructor( } override suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { - val authData = loginSourceRepository.gplayAuth ?: return StreamCluster() + val authData = loginSourceRepository.gplayAuth!! val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) @@ -131,7 +134,7 @@ class GplayStoreRepositoryImpl @Inject constructor( return categoryList } - val authData = loginSourceRepository.gplayAuth ?: return categoryList + val authData = loginSourceRepository.gplayAuth!! withContext(Dispatchers.IO) { val categoryHelper = CategoryHelper(authData).using(gPlayHttpClient) @@ -142,7 +145,7 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getAppDetails(packageNameOrId: String): App? { var appDetails: App? - val authData = loginSourceRepository.gplayAuth ?: return null + val authData = loginSourceRepository.gplayAuth!! withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) @@ -153,7 +156,7 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getAppsDetails(packageNamesOrIds: List): List { val appDetailsList = mutableListOf() - val authData = loginSourceRepository.gplayAuth ?: return appDetailsList + val authData = loginSourceRepository.gplayAuth!! withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) @@ -185,7 +188,7 @@ class GplayStoreRepositoryImpl @Inject constructor( offerType: Int ): List { val downloadData = mutableListOf() - val authData = loginSourceRepository.gplayAuth ?: return downloadData + val authData = loginSourceRepository.gplayAuth!! withContext(Dispatchers.IO) { val version = versionCode?.let { it as Int } ?: -1 @@ -202,7 +205,7 @@ class GplayStoreRepositoryImpl @Inject constructor( offerType: Int ): List { val downloadData = mutableListOf() - val authData = loginSourceRepository.gplayAuth ?: return downloadData + val authData = loginSourceRepository.gplayAuth!! withContext(Dispatchers.IO) { val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) 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 6f3646153..cc38464e2 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 @@ -36,6 +36,10 @@ class LoginCommon @Inject constructor( loginDataStore.saveUserType(user) } + fun getUserType(): User { + return loginDataStore.getUserType() + } + suspend fun saveGoogleLogin(email: String, oauth: String) { loginDataStore.saveGoogleLogin(email, oauth) } diff --git a/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt b/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt index 6cbf99998..7cf920cbb 100644 --- a/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt @@ -20,6 +20,7 @@ package foundation.e.apps.data.login import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.User +import foundation.e.apps.data.login.exceptions.GPlayLoginException import javax.inject.Inject import javax.inject.Singleton @@ -31,6 +32,8 @@ class LoginSourceRepository @Inject constructor( ) { var gplayAuth: AuthData? = null + get() = field ?: throw GPlayLoginException(false, "AuthData is not available!", getUserType()) + suspend fun getAuthObjects(clearAuthTypes: List = listOf()): List { val authObjectsLocal = ArrayList() @@ -71,4 +74,8 @@ class LoginSourceRepository @Inject constructor( this.gplayAuth = validateAuthData.data return validateAuthData } + + private fun getUserType(): User { + return loginCommon.getUserType() + } } -- GitLab From baf2fe4809529d556d28cd1f991e2c72381324c9 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Fri, 8 Sep 2023 19:12:14 +0600 Subject: [PATCH 2/2] fixed: lint issues --- .../foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt index 661844aec..383f8e7c6 100644 --- a/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt @@ -35,16 +35,13 @@ 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.data.enums.User import foundation.e.apps.data.fused.utils.CategoryType import foundation.e.apps.data.gplay.utils.GPlayHttpClient import foundation.e.apps.data.login.LoginSourceRepository -import foundation.e.apps.data.login.exceptions.GPlayLoginException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import timber.log.Timber import javax.inject.Inject -import kotlin.math.log class GplayStoreRepositoryImpl @Inject constructor( @ApplicationContext private val context: Context, -- GitLab