diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index f095a39d5ee850a885d087c8f116a10e59e8c802..8f44d8b464f07ad7dc5f0a8f97c57757a81c1b09 100644 --- a/app/src/main/java/foundation/e/apps/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/MainActivity.kt @@ -44,7 +44,6 @@ import foundation.e.apps.purchase.AppPurchaseFragmentDirections import foundation.e.apps.setup.signin.SignInViewModel import foundation.e.apps.updates.UpdatesNotifier import foundation.e.apps.utils.enums.Status -import foundation.e.apps.utils.enums.User import foundation.e.apps.utils.modules.CommonUtilsModule import foundation.e.apps.utils.parentFragment.TimeoutFragment import kotlinx.coroutines.launch @@ -53,6 +52,7 @@ import java.util.UUID @AndroidEntryPoint class MainActivity : AppCompatActivity() { + private lateinit var signInViewModel: SignInViewModel private lateinit var binding: ActivityMainBinding private val TAG = MainActivity::class.java.simpleName private lateinit var viewModel: MainActivityViewModel @@ -71,7 +71,7 @@ class MainActivity : AppCompatActivity() { var hasInternet = true viewModel = ViewModelProvider(this)[MainActivityViewModel::class.java] - val signInViewModel = ViewModelProvider(this)[SignInViewModel::class.java] + signInViewModel = ViewModelProvider(this)[SignInViewModel::class.java] // navOptions and activityNavController for TOS and SignIn Fragments val navOptions = NavOptions.Builder() @@ -85,30 +85,6 @@ class MainActivity : AppCompatActivity() { } } - fun generateAuthDataBasedOnUserType(user: String) { - if (user.isNotBlank() && viewModel.tocStatus.value == true) { - when (User.valueOf(user)) { - User.ANONYMOUS -> { - if (viewModel.authDataJson.value.isNullOrEmpty() && !viewModel.authRequestRunning) { - Log.d(TAG, "Fetching new authentication data") - viewModel.setFirstTokenFetchTime() - viewModel.getAuthData() - } - } - User.UNAVAILABLE -> { - viewModel.destroyCredentials(null) - } - User.GOOGLE -> { - if (viewModel.authData.value == null && !viewModel.authRequestRunning) { - Log.d(TAG, "Fetching new authentication data") - viewModel.setFirstTokenFetchTime() - signInViewModel.fetchAuthData() - } - } - } - } - } - viewModel.internetConnection.observe(this) { isInternetAvailable -> hasInternet = isInternetAvailable if (isInternetAvailable) { @@ -116,7 +92,7 @@ class MainActivity : AppCompatActivity() { binding.fragment.visibility = View.VISIBLE viewModel.userType.observe(this) { user -> - generateAuthDataBasedOnUserType(user) + viewModel.handleAuthDataJson() } signInViewModel.authLiveData.observe(this) { @@ -125,35 +101,24 @@ class MainActivity : AppCompatActivity() { // Watch and refresh authentication data viewModel.authDataJson.observe(this) { - if (!it.isNullOrEmpty()) { - viewModel.generateAuthData() - Log.d(TAG, "Authentication data is available!") - } + viewModel.handleAuthDataJson() } } } viewModel.authValidity.observe(this) { - if (it != true) { - Log.d(TAG, "Authentication data validation failed!") - viewModel.destroyCredentials { user -> - if (viewModel.isTimeEligibleForTokenRefresh()) { - generateAuthDataBasedOnUserType(user) - } else { - Log.d(TAG, "Timeout validating auth data!") - val lastFragment = navHostFragment.childFragmentManager.fragments[0] - if (lastFragment is TimeoutFragment) { - Log.d( - TAG, - "Displaying timeout from MainActivity on fragment: " + - lastFragment::class.java.name - ) - lastFragment.onTimeout() - } - } + + viewModel.handleAuthValidity(it) { + Log.d(TAG, "Timeout validating auth data!") + val lastFragment = navHostFragment.childFragmentManager.fragments[0] + if (lastFragment is TimeoutFragment) { + Log.d( + TAG, + "Displaying timeout from MainActivity on fragment: " + + lastFragment::class.java.name + ) + lastFragment.onTimeout() } - } else { - Log.d(TAG, "Authentication data is valid!") } } diff --git a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt index 4e54172e0b0fabc39a94a82828cfeddc7400b3ec..b66a7d49d27a422991493f99a41a4a9c4206a49d 100644 --- a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt @@ -42,6 +42,7 @@ import foundation.e.apps.api.cleanapk.blockedApps.BlockedAppRepository import foundation.e.apps.api.ecloud.EcloudRepository import foundation.e.apps.api.fused.FusedAPIRepository import foundation.e.apps.api.fused.data.FusedApp +import foundation.e.apps.api.gplay.utils.AC2DMTask import foundation.e.apps.manager.database.fusedDownload.FusedDownload import foundation.e.apps.manager.fused.FusedManagerRepository import foundation.e.apps.manager.pkg.PkgManagerModule @@ -53,6 +54,7 @@ import foundation.e.apps.utils.modules.CommonUtilsModule.timeoutDurationInMillis import foundation.e.apps.utils.modules.DataStoreModule import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import ru.beryukhov.reactivenetwork.ReactiveNetwork import java.io.ByteArrayOutputStream import javax.inject.Inject @@ -66,6 +68,7 @@ class MainActivityViewModel @Inject constructor( private val pkgManagerModule: PkgManagerModule, private val ecloudRepository: EcloudRepository, private val blockedAppRepository: BlockedAppRepository, + private val aC2DMTask: AC2DMTask, ) : ViewModel() { val authDataJson: LiveData = dataStoreModule.authData.asLiveData() @@ -89,6 +92,8 @@ class MainActivityViewModel @Inject constructor( */ var firstAuthDataFetchTime = 0L + var isTokenValidationCompletedOnce = false + // Downloads val downloadList = fusedManagerRepository.getDownloadLiveList() var installInProgress = false @@ -103,15 +108,16 @@ class MainActivityViewModel @Inject constructor( companion object { private const val TAG = "MainActivityViewModel" + private var isGoogleLoginRunning = false } - fun setFirstTokenFetchTime() { + private fun setFirstTokenFetchTime() { if (firstAuthDataFetchTime == 0L) { firstAuthDataFetchTime = SystemClock.uptimeMillis() } } - fun isTimeEligibleForTokenRefresh(): Boolean { + private fun isTimeEligibleForTokenRefresh(): Boolean { return (SystemClock.uptimeMillis() - firstAuthDataFetchTime) <= timeoutDurationInMillis } @@ -194,11 +200,114 @@ class MainActivityViewModel @Inject constructor( } fun generateAuthData() { - val data = gson.fromJson(authDataJson.value, AuthData::class.java) + val data = jsonToAuthData() _authData.value = data + } + + private fun jsonToAuthData() = gson.fromJson(authDataJson.value, AuthData::class.java) + + fun validateAuthData() { + viewModelScope.launch { + jsonToAuthData()?.let { + val isAuthValid = isAuthValid(it) + authValidity.postValue(isAuthValid) + authRequestRunning = false + } + } + } + + fun handleAuthDataJson() { + val user = userType.value + val json = authDataJson.value + + if (user == null || json == null) { + return + } + + if (!isUserLoggedIn(user, json)) { + generateAuthDataBasedOnUserType(user) + } else if (isEligibleToValidateJson(json)) { + validateAuthData() + Log.d(TAG, ">>> Authentication data is available!") + } + } + + private fun isUserLoggedIn(user: String, json: String) = + user.isNotEmpty() && !user.contentEquals(User.UNAVAILABLE.name) && json.isNotEmpty() + + private fun isEligibleToValidateJson(authDataJson: String?) = + !authDataJson.isNullOrEmpty() && !userType.value.isNullOrEmpty() && !userType.value.contentEquals( + User.UNAVAILABLE.name + ) + + fun handleAuthValidity(isValid: Boolean, handleTimeoOut: () -> Unit) { + if (isGoogleLoginRunning) { + return + } + isTokenValidationCompletedOnce = true + if (isValid) { + Log.d(TAG, "Authentication data is valid!") + generateAuthData() + return + } + Log.d(TAG, ">>> Authentication data validation failed!") + destroyCredentials { user -> + if (isTimeEligibleForTokenRefresh()) { + generateAuthDataBasedOnUserType(user) + } else { + handleTimeoOut() + } + } + } + + private fun generateAuthDataBasedOnUserType(user: String) { + if (user.isEmpty() || tocStatus.value == false || isGoogleLoginRunning) { + return + } + when (User.valueOf(user)) { + User.ANONYMOUS -> { + if (authDataJson.value.isNullOrEmpty() && !authRequestRunning) { + Log.d(TAG, ">>> Fetching new authentication data") + setFirstTokenFetchTime() + getAuthData() + } + } + User.UNAVAILABLE -> { + destroyCredentials(null) + } + User.GOOGLE -> { + if (authData.value == null && !authRequestRunning) { + Log.d(TAG, ">>> Fetching new authentication data") + setFirstTokenFetchTime() + doFetchAuthData() + } + } + } + } + + private suspend fun doFetchAuthData(email: String, oauthToken: String) { + var responseMap: Map + withContext(Dispatchers.IO) { + val response = aC2DMTask.getAC2DMResponse(email, oauthToken) + responseMap = response + responseMap["Token"]?.let { + if (fusedAPIRepository.fetchAuthData(email, it) == null) { + dataStoreModule.clearUserType() + _errorMessageStringResource.value = R.string.unknown_error + } + } + } + } + + private fun doFetchAuthData() { viewModelScope.launch { - authValidity.postValue(isAuthValid(data)) - authRequestRunning = false + isGoogleLoginRunning = true + val email = dataStoreModule.getEmail() + val oauthToken = dataStoreModule.getAASToken() + if (email.isNotEmpty() && oauthToken.isNotEmpty()) { + doFetchAuthData(email, oauthToken) + } + isGoogleLoginRunning = false } } 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 e7a813bf647f7f4aaedc30520f40ed777da6b979..409dc93ebed6f2acff4b28c44b77f416ffbc7db2 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 @@ -368,7 +368,7 @@ class FusedAPIImpl @Inject constructor( return gPlayAPIRepository.fetchAuthData() } - suspend fun fetchAuthData(email: String, aasToken: String): AuthData { + suspend fun fetchAuthData(email: String, aasToken: String): AuthData? { return gPlayAPIRepository.fetchAuthData(email, aasToken) } @@ -983,7 +983,6 @@ class FusedAPIImpl @Inject constructor( it.first.map { app -> app.transformToFusedApp() }, it.second ) - } } diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt index 5a6717d5d276b53fda49db400ef6dcfbbf832122..0cf5b73b7510ddf9f42aab2976d344a4e9ab6653 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIRepository.kt @@ -53,7 +53,9 @@ class FusedAPIRepository @Inject constructor( } suspend fun validateAuthData(authData: AuthData): Boolean { - return fusedAPIImpl.validateAuthData(authData) + return authData.authToken.isNotEmpty() && authData.deviceInfoProvider != null && fusedAPIImpl.validateAuthData( + authData + ) } suspend fun getApplicationDetails( @@ -96,7 +98,10 @@ class FusedAPIRepository @Inject constructor( ) } - suspend fun getCategoriesList(type: Category.Type, authData: AuthData): Triple, String, ResultStatus> { + suspend fun getCategoriesList( + type: Category.Type, + authData: AuthData + ): Triple, String, ResultStatus> { return fusedAPIImpl.getCategoriesList(type, authData) } @@ -108,7 +113,7 @@ class FusedAPIRepository @Inject constructor( return fusedAPIImpl.fetchAuthData() } - suspend fun fetchAuthData(email: String, aasToken: String): AuthData { + suspend fun fetchAuthData(email: String, aasToken: String): AuthData? { return fusedAPIImpl.fetchAuthData(email, aasToken) } diff --git a/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt index 904b8cc49d10a9292431d85a45e6f7fe1b2886da..f0b69d06cd18607cedc8407ee6e2fcfd76ccf25d 100644 --- a/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt @@ -73,8 +73,13 @@ class GPlayAPIImpl @Inject constructor( } } - fun fetchAuthData(email: String, aasToken: String): AuthData { - return tokenRepository.getAuthData(email, aasToken) + suspend fun fetchAuthData(email: String, aasToken: String): AuthData? { + val authData = tokenRepository.getAuthData(email, aasToken) + if (authData.authToken.isNotEmpty() && authData.deviceInfoProvider != null) { + dataStoreModule.saveCredentials(authData) + return authData + } + return null } suspend fun validateAuthData(authData: AuthData): Boolean { @@ -85,6 +90,7 @@ class GPlayAPIImpl @Inject constructor( authValidator.isValid() } catch (e: Exception) { e.printStackTrace() + throw e false } } diff --git a/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIRepository.kt b/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIRepository.kt index b6b098cbbe13798044da6d5e05e648eabecb8ec4..7517895d6edea0ba904a86ec73378966fff7b569 100644 --- a/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIRepository.kt +++ b/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIRepository.kt @@ -37,7 +37,7 @@ class GPlayAPIRepository @Inject constructor( return gPlayAPIImpl.fetchAuthData() } - suspend fun fetchAuthData(email: String, aasToken: String): AuthData { + suspend fun fetchAuthData(email: String, aasToken: String): AuthData? { return gPlayAPIImpl.fetchAuthData(email, aasToken) } diff --git a/app/src/main/java/foundation/e/apps/api/gplay/token/TokenImpl.kt b/app/src/main/java/foundation/e/apps/api/gplay/token/TokenImpl.kt index d392aaff51699e0186a96d79e2cabf3e0f84c217..e9578de027f924f163300590843b87ceea2c0845 100644 --- a/app/src/main/java/foundation/e/apps/api/gplay/token/TokenImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/gplay/token/TokenImpl.kt @@ -38,7 +38,11 @@ class TokenImpl @Inject constructor( fun getAuthData(): AuthData? { val playResponse = gPlayHttpClient.postAuth(BASE_URL, gson.toJson(nativeDeviceProperty).toByteArray()) - return gson.fromJson(String(playResponse.responseBytes), AuthData::class.java) + return if (playResponse.isSuccessful) { + gson.fromJson(String(playResponse.responseBytes), AuthData::class.java) + } else { + null + } } fun getAuthData(email: String, aasToken: String): AuthData { diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt b/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt index 1ec727682aa174a81adf7a6a46f65f76233a29c6..c275790e806223fbfb43704b10cbed25b635f7aa 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt @@ -27,7 +27,6 @@ import android.util.Log import androidx.annotation.RequiresApi import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.manager.fused.FusedManagerRepository -import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import javax.inject.Inject diff --git a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt index 2c3c305e3084c3feda030aee7f74f8ee63709363..9089b59d4d8b994a459120b45dc5757ee534e2ff 100644 --- a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt @@ -52,7 +52,6 @@ import foundation.e.apps.applicationlist.model.ApplicationListRVAdapter import foundation.e.apps.databinding.FragmentSearchBinding import foundation.e.apps.manager.download.data.DownloadProgress import foundation.e.apps.manager.pkg.PkgManagerModule -import foundation.e.apps.utils.enums.ResultStatus import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.User import foundation.e.apps.utils.modules.PWAManagerModule diff --git a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt index 562ec459bc6f0d5f220483bffb124bdc0a52b6ce..5db6b8b7689f26c0a9062f75c6a5642c5e04b9ab 100644 --- a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt +++ b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt @@ -20,10 +20,14 @@ package foundation.e.apps.settings import android.content.Intent import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.util.Log import android.view.View +import android.widget.Toast import androidx.fragment.app.viewModels import androidx.navigation.findNavController +import androidx.navigation.fragment.findNavController import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.work.ExistingPeriodicWorkPolicy @@ -67,7 +71,13 @@ class SettingsFragment : PreferenceFragmentCompat() { preferenceManager.findPreference(getString(R.string.update_check_intervals)) updateCheckInterval?.setOnPreferenceChangeListener { _, newValue -> Log.d(TAG, "onCreatePreferences: updated Value: $newValue") - context?.let { UpdatesWorkManager.enqueueWork(it, newValue.toString().toLong(), ExistingPeriodicWorkPolicy.REPLACE) } + context?.let { + UpdatesWorkManager.enqueueWork( + it, + newValue.toString().toLong(), + ExistingPeriodicWorkPolicy.REPLACE + ) + } true } @@ -123,7 +133,10 @@ class SettingsFragment : PreferenceFragmentCompat() { binding.logout.setOnClickListener { viewModel.saveUserType(User.UNAVAILABLE) - backToMainActivity() + Toast.makeText(requireContext(), "Signing out...", Toast.LENGTH_LONG).show() + Handler(Looper.getMainLooper()).postDelayed({ + backToMainActivity() + }, 1500) } } diff --git a/app/src/main/java/foundation/e/apps/setup/signin/SignInViewModel.kt b/app/src/main/java/foundation/e/apps/setup/signin/SignInViewModel.kt index 8385b519e6cca57f85d9cbfea2e5893fad261db1..ee0e1ea91b61e7d756a1106dfb176915ca9244ff 100644 --- a/app/src/main/java/foundation/e/apps/setup/signin/SignInViewModel.kt +++ b/app/src/main/java/foundation/e/apps/setup/signin/SignInViewModel.kt @@ -7,20 +7,14 @@ import androidx.lifecycle.asLiveData import androidx.lifecycle.viewModelScope import com.aurora.gplayapi.data.models.AuthData import dagger.hilt.android.lifecycle.HiltViewModel -import foundation.e.apps.api.fused.FusedAPIRepository -import foundation.e.apps.api.gplay.utils.AC2DMTask import foundation.e.apps.utils.enums.User import foundation.e.apps.utils.modules.DataStoreModule -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import javax.inject.Inject @HiltViewModel class SignInViewModel @Inject constructor( private val dataStoreModule: DataStoreModule, - private val aC2DMTask: AC2DMTask, - private val fusedAPIRepository: FusedAPIRepository ) : ViewModel() { val userType: LiveData = dataStoreModule.userType.asLiveData() @@ -30,6 +24,9 @@ class SignInViewModel @Inject constructor( fun saveUserType(user: User) { viewModelScope.launch { dataStoreModule.saveUserType(user) + if (user == User.UNAVAILABLE) { + dataStoreModule.destroyCredentials() + } } } @@ -38,27 +35,4 @@ class SignInViewModel @Inject constructor( dataStoreModule.saveEmail(email, token) } } - - private suspend fun fetchAuthData(email: String, oauthToken: String) { - var responseMap: Map - withContext(Dispatchers.IO) { - val response = aC2DMTask.getAC2DMResponse(email, oauthToken) - responseMap = response - responseMap["Token"]?.let { - val value = fusedAPIRepository.fetchAuthData(email, it) - _authLiveData.postValue(value) - dataStoreModule.saveCredentials(value) - } - } - } - - fun fetchAuthData() { - viewModelScope.launch { - val email = dataStoreModule.getEmail() - val oauthToken = dataStoreModule.getAASToken() - if (email.isNotEmpty() && oauthToken.isNotEmpty()) { - fetchAuthData(email, oauthToken) - } - } - } } diff --git a/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt b/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt index 60d513d2aa0d2eee6f54c8270e85100c267115d6..f630fda7ab3de39543cdb3fc26a1a713d3e3f752 100644 --- a/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt +++ b/app/src/main/java/foundation/e/apps/updates/UpdatesViewModel.kt @@ -18,7 +18,6 @@ package foundation.e.apps.updates -import android.util.Log import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -28,8 +27,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.api.fused.FusedAPIRepository import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.updates.manager.UpdatesManagerRepository -import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.ResultStatus +import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.launch import javax.inject.Inject diff --git a/app/src/main/java/foundation/e/apps/utils/modules/DataStoreModule.kt b/app/src/main/java/foundation/e/apps/utils/modules/DataStoreModule.kt index 5fa284abace01730e4b898f082a72a9690d6ddbc..a85d033654d3d08234b9b8e72583bc9f236b3b6f 100644 --- a/app/src/main/java/foundation/e/apps/utils/modules/DataStoreModule.kt +++ b/app/src/main/java/foundation/e/apps/utils/modules/DataStoreModule.kt @@ -112,6 +112,12 @@ class DataStoreModule @Inject constructor( } } + suspend fun saveUserTypeSync(user: User) { + context.dataStore.edit { + it[USERTYPE] = user.name + } + } + fun getAuthDataSync(): String { return runBlocking { authData.first() diff --git a/app/src/main/java/foundation/e/apps/utils/parentFragment/TimeoutFragment.kt b/app/src/main/java/foundation/e/apps/utils/parentFragment/TimeoutFragment.kt index 7900b23809b5d612cda1a23bf06a87cc3aadfb9b..959dc2efbb7a8fb6983b3fff00f32c0fd5500325 100644 --- a/app/src/main/java/foundation/e/apps/utils/parentFragment/TimeoutFragment.kt +++ b/app/src/main/java/foundation/e/apps/utils/parentFragment/TimeoutFragment.kt @@ -82,7 +82,9 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { dismissTimeoutDialog() refreshData(authData) } ?: run { - mainActivityViewModel.retryFetchingTokenAfterTimeout() + if (mainActivityViewModel.authValidity.value != null) { // checking at least authvalidity is checked for once + mainActivityViewModel.retryFetchingTokenAfterTimeout() + } } } } diff --git a/app/src/main/res/navigation/navigation_resource.xml b/app/src/main/res/navigation/navigation_resource.xml index addf4ef046878b6e894c9f0b1b71799b9c87e87e..a258c3c773d7d826be5a383b4667954f9b3f4dd9 100644 --- a/app/src/main/res/navigation/navigation_resource.xml +++ b/app/src/main/res/navigation/navigation_resource.xml @@ -240,5 +240,4 @@ android:id="@+id/action_global_appPurchaseFragment" app:destination="@id/appPurchaseFragment" /> -