diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index 98838bd35df83b31b705d1a9bf4207d8921a3fd9..ae7d1a5e6a6805b2de69683a88871c777ed488b0 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 19461db72783b10456324a8ffd9187190530eb2b..383f8e7c6e43a3914944d9e2708fbb45bfbc0bfe 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 @@ -52,7 +52,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 +77,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 +102,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 +113,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 +131,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 +142,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 +153,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 +185,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 +202,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 6f3646153fe5f95eb612fe6af00d4692df8e0d51..cc38464e217caff6daac4c85b38fa194d8e58700 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 6cbf9999810088217b171e77bf60b2b0564ed520..7cf920cbb55d1502b3f3b4a81bd60495b09de083 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() + } }