Loading app/src/main/java/foundation/e/apps/MainActivity.kt +20 −26 Original line number Diff line number Diff line Loading @@ -67,8 +67,6 @@ class MainActivity : AppCompatActivity() { private val TAG = MainActivity::class.java.simpleName private lateinit var viewModel: MainActivityViewModel private var isShowingDialog = false @Inject lateinit var preferenceManagerModule: PreferenceManagerModule Loading Loading @@ -137,6 +135,12 @@ class MainActivity : AppCompatActivity() { email, SystemInfoProvider.getAppBuildInfo() ) } else if (exception != null) { 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) } } } Loading Loading @@ -288,36 +292,26 @@ class MainActivity : AppCompatActivity() { }.distinctUntilChanged { old, new -> ((old.data is String) && (new.data is String) && old.data == new.data) }.collectLatest { val data = it.data as String validatedAuthObject(it) } } private fun validatedAuthObject(appEvent: AppEvent) { val data = appEvent.data as String if (data.isNotBlank()) { loginViewModel.markInvalidAuthObject(data) } } } private suspend fun observeTooManyRequests() { EventBus.events.filter { appEvent -> appEvent is AppEvent.TooManyRequests }.collectLatest { if (isShowingDialog) return@collectLatest ApplicationDialogFragment( title = getString(R.string.too_many_requests), message = getString(R.string.too_many_requests_desc), positiveButtonText = getString(R.string.ok), positiveButtonAction = { preferenceManagerModule.disableGplay() loginViewModel.startLoginFlow() }, cancelButtonText = getString(R.string.logout), cancelButtonAction = { loginViewModel.logout() }, cancellable = false, onDismissListener = { isShowingDialog = false }, ).show(supportFragmentManager, TAG) isShowingDialog = true }.collectLatest { appEvent -> binding.sessionErrorLayout.visibility = View.VISIBLE binding.retrySessionButton.setOnClickListener { binding.sessionErrorLayout.visibility = View.GONE validatedAuthObject(appEvent = appEvent) } } } Loading app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +1 −2 Original line number Diff line number Diff line Loading @@ -280,7 +280,6 @@ class FusedApiImpl @Inject constructor( packageSpecificResults ) } return finalSearchResult } Loading Loading @@ -427,7 +426,7 @@ class FusedApiImpl @Inject constructor( ): FusedApp? { try { getApplicationDetails(query, query, authData, Origin.GPLAY).let { if (it.second == ResultStatus.OK) { if (it.second == ResultStatus.OK && it.first.package_name.isNotEmpty()) { return it.first } } Loading app/src/main/java/foundation/e/apps/data/gplay/utils/GPlayHttpClient.kt +6 −2 Original line number Diff line number Diff line Loading @@ -155,9 +155,11 @@ class GPlayHttpClient @Inject constructor( } private fun processRequest(request: Request): PlayResponse { var response: Response? = null return try { val call = okHttpClient.newCall(request) buildPlayResponse(call.execute()) response = call.execute() buildPlayResponse(response) } catch (e: Exception) { // TODO: exception will be thrown for all apis when all gplay api implementation // will handle the exceptions. this will be done in following issue. Loading @@ -171,6 +173,8 @@ class GPlayHttpClient @Inject constructor( is SocketTimeoutException -> handleExceptionOnGooglePlayRequest(e) else -> handleExceptionOnGooglePlayRequest(e) } } finally { response?.close() } } Loading Loading @@ -204,7 +208,7 @@ class GPlayHttpClient @Inject constructor( 429 -> MainScope().launch { EventBus.invokeEvent( AppEvent.TooManyRequests() AppEvent.TooManyRequests(AuthObject.GPlayAuth::class.java.simpleName) ) } } Loading app/src/main/java/foundation/e/apps/data/login/LoginViewModel.kt +3 −0 Original line number Diff line number Diff line Loading @@ -17,10 +17,12 @@ package foundation.e.apps.data.login import android.content.Context import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.enums.User import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch Loading Loading @@ -122,6 +124,7 @@ class LoginViewModel @Inject constructor( } authObjects.postValue(authObjectsLocal) cache.evictAll() } /** Loading app/src/main/java/foundation/e/apps/ui/parentFragment/LoadingViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ abstract class LoadingViewModel : ViewModel() { it is GPlayValidationException }?.run { if (!autoRetried && retryBlock(failedAuthList)) { autoRetried = true autoRetried = false exceptionsList.clear() return } Loading Loading
app/src/main/java/foundation/e/apps/MainActivity.kt +20 −26 Original line number Diff line number Diff line Loading @@ -67,8 +67,6 @@ class MainActivity : AppCompatActivity() { private val TAG = MainActivity::class.java.simpleName private lateinit var viewModel: MainActivityViewModel private var isShowingDialog = false @Inject lateinit var preferenceManagerModule: PreferenceManagerModule Loading Loading @@ -137,6 +135,12 @@ class MainActivity : AppCompatActivity() { email, SystemInfoProvider.getAppBuildInfo() ) } else if (exception != null) { 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) } } } Loading Loading @@ -288,36 +292,26 @@ class MainActivity : AppCompatActivity() { }.distinctUntilChanged { old, new -> ((old.data is String) && (new.data is String) && old.data == new.data) }.collectLatest { val data = it.data as String validatedAuthObject(it) } } private fun validatedAuthObject(appEvent: AppEvent) { val data = appEvent.data as String if (data.isNotBlank()) { loginViewModel.markInvalidAuthObject(data) } } } private suspend fun observeTooManyRequests() { EventBus.events.filter { appEvent -> appEvent is AppEvent.TooManyRequests }.collectLatest { if (isShowingDialog) return@collectLatest ApplicationDialogFragment( title = getString(R.string.too_many_requests), message = getString(R.string.too_many_requests_desc), positiveButtonText = getString(R.string.ok), positiveButtonAction = { preferenceManagerModule.disableGplay() loginViewModel.startLoginFlow() }, cancelButtonText = getString(R.string.logout), cancelButtonAction = { loginViewModel.logout() }, cancellable = false, onDismissListener = { isShowingDialog = false }, ).show(supportFragmentManager, TAG) isShowingDialog = true }.collectLatest { appEvent -> binding.sessionErrorLayout.visibility = View.VISIBLE binding.retrySessionButton.setOnClickListener { binding.sessionErrorLayout.visibility = View.GONE validatedAuthObject(appEvent = appEvent) } } } Loading
app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +1 −2 Original line number Diff line number Diff line Loading @@ -280,7 +280,6 @@ class FusedApiImpl @Inject constructor( packageSpecificResults ) } return finalSearchResult } Loading Loading @@ -427,7 +426,7 @@ class FusedApiImpl @Inject constructor( ): FusedApp? { try { getApplicationDetails(query, query, authData, Origin.GPLAY).let { if (it.second == ResultStatus.OK) { if (it.second == ResultStatus.OK && it.first.package_name.isNotEmpty()) { return it.first } } Loading
app/src/main/java/foundation/e/apps/data/gplay/utils/GPlayHttpClient.kt +6 −2 Original line number Diff line number Diff line Loading @@ -155,9 +155,11 @@ class GPlayHttpClient @Inject constructor( } private fun processRequest(request: Request): PlayResponse { var response: Response? = null return try { val call = okHttpClient.newCall(request) buildPlayResponse(call.execute()) response = call.execute() buildPlayResponse(response) } catch (e: Exception) { // TODO: exception will be thrown for all apis when all gplay api implementation // will handle the exceptions. this will be done in following issue. Loading @@ -171,6 +173,8 @@ class GPlayHttpClient @Inject constructor( is SocketTimeoutException -> handleExceptionOnGooglePlayRequest(e) else -> handleExceptionOnGooglePlayRequest(e) } } finally { response?.close() } } Loading Loading @@ -204,7 +208,7 @@ class GPlayHttpClient @Inject constructor( 429 -> MainScope().launch { EventBus.invokeEvent( AppEvent.TooManyRequests() AppEvent.TooManyRequests(AuthObject.GPlayAuth::class.java.simpleName) ) } } Loading
app/src/main/java/foundation/e/apps/data/login/LoginViewModel.kt +3 −0 Original line number Diff line number Diff line Loading @@ -17,10 +17,12 @@ package foundation.e.apps.data.login import android.content.Context import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.enums.User import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch Loading Loading @@ -122,6 +124,7 @@ class LoginViewModel @Inject constructor( } authObjects.postValue(authObjectsLocal) cache.evictAll() } /** Loading
app/src/main/java/foundation/e/apps/ui/parentFragment/LoadingViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ abstract class LoadingViewModel : ViewModel() { it is GPlayValidationException }?.run { if (!autoRetried && retryBlock(failedAuthList)) { autoRetried = true autoRetried = false exceptionsList.clear() return } Loading