Loading app/src/main/java/foundation/e/apps/MainActivity.kt +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.LoginSourceGPlay import foundation.e.apps.data.login.GooglePlayAuthenticator import foundation.e.apps.data.login.LoginViewModel import foundation.e.apps.data.login.exceptions.GPlayValidationException import foundation.e.apps.data.preference.PreferenceManagerModule Loading Loading @@ -308,7 +308,7 @@ class MainActivity : AppCompatActivity() { binding.sessionErrorLayout.visibility = View.VISIBLE binding.retrySessionButton.setOnClickListener { binding.sessionErrorLayout.visibility = View.GONE loginViewModel.startLoginFlow(listOf(LoginSourceGPlay::class.java.simpleName)) loginViewModel.startLoginFlow(listOf(GooglePlayAuthenticator::class.java.simpleName)) } } } Loading app/src/main/java/foundation/e/apps/data/login/LoginSourceCleanApk.kt→app/src/main/java/foundation/e/apps/data/login/CleanApkAuthenticator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -27,14 +27,14 @@ import javax.inject.Singleton * https://gitlab.e.foundation/e/backlog/-/issues/5680 */ @Singleton class LoginSourceCleanApk @Inject constructor( class CleanApkAuthenticator @Inject constructor( val loginDataStore: LoginDataStore, ) : LoginSourceInterface { ) : StoreAuthenticator { private val user: User get() = loginDataStore.getUserType() override fun isActive(): Boolean { override fun isStoreActive(): Boolean { if (user == User.UNAVAILABLE) { /* * UNAVAILABLE user means first login is not completed. Loading app/src/main/java/foundation/e/apps/data/login/LoginSourceGPlay.kt→app/src/main/java/foundation/e/apps/data/login/GooglePlayAuthenticator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -40,11 +40,11 @@ import javax.inject.Singleton * https://gitlab.e.foundation/e/backlog/-/issues/5680 */ @Singleton class LoginSourceGPlay @Inject constructor( class GooglePlayAuthenticator @Inject constructor( @ApplicationContext private val context: Context, private val gson: Gson, private val loginDataStore: LoginDataStore, ) : LoginSourceInterface, AuthDataValidator { ) : StoreAuthenticator, AuthDataValidator { @Inject lateinit var gPlayApiFactory: GPlayApiFactory Loading @@ -61,7 +61,7 @@ class LoginSourceGPlay @Inject constructor( private val locale: Locale get() = context.resources.configuration.locales[0] override fun isActive(): Boolean { override fun isStoreActive(): Boolean { if (user == User.UNAVAILABLE) { /* * UNAVAILABLE user means first login is not completed. Loading app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt +7 −7 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import javax.inject.Singleton @Singleton class LoginSourceRepository @Inject constructor( private val loginCommon: LoginCommon, private val sources: List<LoginSourceInterface>, private val authenticators: List<StoreAuthenticator>, ) { var gplayAuth: AuthData? = null Loading @@ -38,13 +38,13 @@ class LoginSourceRepository @Inject constructor( val authObjectsLocal = ArrayList<AuthObject>() for (source in sources) { if (!source.isActive()) continue if (source::class.java.simpleName in clearAuthTypes) { source.clearSavedAuth() for (authenticator in authenticators) { if (!authenticator.isStoreActive()) continue if (authenticator::class.java.simpleName in clearAuthTypes) { authenticator.clearSavedAuth() } val authObject = source.getAuthObject() val authObject = authenticator.getAuthObject() authObjectsLocal.add(authObject) if (authObject is AuthObject.GPlayAuth) { Loading Loading @@ -72,7 +72,7 @@ class LoginSourceRepository @Inject constructor( } suspend fun getValidatedAuthData(): ResultSupreme<AuthData?> { val authDataValidator = (sources.find { it is AuthDataValidator } as AuthDataValidator) val authDataValidator = (authenticators.find { it is AuthDataValidator } as AuthDataValidator) val validateAuthData = authDataValidator.validateAuthData() this.gplayAuth = validateAuthData.data return validateAuthData Loading app/src/main/java/foundation/e/apps/data/login/LoginSourceInterface.kt→app/src/main/java/foundation/e/apps/data/login/StoreAuthenticator.kt +3 −6 Original line number Diff line number Diff line Loading @@ -18,13 +18,10 @@ package foundation.e.apps.data.login /** * Interface that defines what methods a login source must define. * Login sources (can also be called - data sources): Google Play, CleanApk. * * https://gitlab.e.foundation/e/backlog/-/issues/5680 * Store (Google Play Store, Clean Apk) authenticator. */ interface LoginSourceInterface { interface StoreAuthenticator { suspend fun getAuthObject(): AuthObject suspend fun clearSavedAuth() fun isActive(): Boolean fun isStoreActive(): Boolean } Loading
app/src/main/java/foundation/e/apps/MainActivity.kt +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.LoginSourceGPlay import foundation.e.apps.data.login.GooglePlayAuthenticator import foundation.e.apps.data.login.LoginViewModel import foundation.e.apps.data.login.exceptions.GPlayValidationException import foundation.e.apps.data.preference.PreferenceManagerModule Loading Loading @@ -308,7 +308,7 @@ class MainActivity : AppCompatActivity() { binding.sessionErrorLayout.visibility = View.VISIBLE binding.retrySessionButton.setOnClickListener { binding.sessionErrorLayout.visibility = View.GONE loginViewModel.startLoginFlow(listOf(LoginSourceGPlay::class.java.simpleName)) loginViewModel.startLoginFlow(listOf(GooglePlayAuthenticator::class.java.simpleName)) } } } Loading
app/src/main/java/foundation/e/apps/data/login/LoginSourceCleanApk.kt→app/src/main/java/foundation/e/apps/data/login/CleanApkAuthenticator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -27,14 +27,14 @@ import javax.inject.Singleton * https://gitlab.e.foundation/e/backlog/-/issues/5680 */ @Singleton class LoginSourceCleanApk @Inject constructor( class CleanApkAuthenticator @Inject constructor( val loginDataStore: LoginDataStore, ) : LoginSourceInterface { ) : StoreAuthenticator { private val user: User get() = loginDataStore.getUserType() override fun isActive(): Boolean { override fun isStoreActive(): Boolean { if (user == User.UNAVAILABLE) { /* * UNAVAILABLE user means first login is not completed. Loading
app/src/main/java/foundation/e/apps/data/login/LoginSourceGPlay.kt→app/src/main/java/foundation/e/apps/data/login/GooglePlayAuthenticator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -40,11 +40,11 @@ import javax.inject.Singleton * https://gitlab.e.foundation/e/backlog/-/issues/5680 */ @Singleton class LoginSourceGPlay @Inject constructor( class GooglePlayAuthenticator @Inject constructor( @ApplicationContext private val context: Context, private val gson: Gson, private val loginDataStore: LoginDataStore, ) : LoginSourceInterface, AuthDataValidator { ) : StoreAuthenticator, AuthDataValidator { @Inject lateinit var gPlayApiFactory: GPlayApiFactory Loading @@ -61,7 +61,7 @@ class LoginSourceGPlay @Inject constructor( private val locale: Locale get() = context.resources.configuration.locales[0] override fun isActive(): Boolean { override fun isStoreActive(): Boolean { if (user == User.UNAVAILABLE) { /* * UNAVAILABLE user means first login is not completed. Loading
app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt +7 −7 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import javax.inject.Singleton @Singleton class LoginSourceRepository @Inject constructor( private val loginCommon: LoginCommon, private val sources: List<LoginSourceInterface>, private val authenticators: List<StoreAuthenticator>, ) { var gplayAuth: AuthData? = null Loading @@ -38,13 +38,13 @@ class LoginSourceRepository @Inject constructor( val authObjectsLocal = ArrayList<AuthObject>() for (source in sources) { if (!source.isActive()) continue if (source::class.java.simpleName in clearAuthTypes) { source.clearSavedAuth() for (authenticator in authenticators) { if (!authenticator.isStoreActive()) continue if (authenticator::class.java.simpleName in clearAuthTypes) { authenticator.clearSavedAuth() } val authObject = source.getAuthObject() val authObject = authenticator.getAuthObject() authObjectsLocal.add(authObject) if (authObject is AuthObject.GPlayAuth) { Loading Loading @@ -72,7 +72,7 @@ class LoginSourceRepository @Inject constructor( } suspend fun getValidatedAuthData(): ResultSupreme<AuthData?> { val authDataValidator = (sources.find { it is AuthDataValidator } as AuthDataValidator) val authDataValidator = (authenticators.find { it is AuthDataValidator } as AuthDataValidator) val validateAuthData = authDataValidator.validateAuthData() this.gplayAuth = validateAuthData.data return validateAuthData Loading
app/src/main/java/foundation/e/apps/data/login/LoginSourceInterface.kt→app/src/main/java/foundation/e/apps/data/login/StoreAuthenticator.kt +3 −6 Original line number Diff line number Diff line Loading @@ -18,13 +18,10 @@ package foundation.e.apps.data.login /** * Interface that defines what methods a login source must define. * Login sources (can also be called - data sources): Google Play, CleanApk. * * https://gitlab.e.foundation/e/backlog/-/issues/5680 * Store (Google Play Store, Clean Apk) authenticator. */ interface LoginSourceInterface { interface StoreAuthenticator { suspend fun getAuthObject(): AuthObject suspend fun clearSavedAuth() fun isActive(): Boolean fun isStoreActive(): Boolean }