Loading app/src/main/AndroidManifest.xml +13 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,19 @@ </intent-filter> </receiver> <receiver android:name=".receiver.PWAPlayerStatusReceiver" android:exported="true"> <intent-filter> <action android:name="foundation.e.pwaplayer.PWA_ADDED" /> </intent-filter> <intent-filter> <action android:name="foundation.e.pwaplayer.PWA_CHANGED" /> </intent-filter> <intent-filter> <action android:name="foundation.e.pwaplayer.PWA_REMOVED" /> </intent-filter> </receiver> <!-- If you want to disable android.startup completely. --> <provider android:name="androidx.startup.InitializationProvider" Loading app/src/main/java/foundation/e/apps/MainActivity.kt +27 −20 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import foundation.e.apps.utils.modules.CommonUtilsModule import kotlinx.coroutines.launch import java.io.File import java.util.UUID import javax.inject.Inject @AndroidEntryPoint class MainActivity : AppCompatActivity() { Loading Loading @@ -83,13 +84,7 @@ class MainActivity : AppCompatActivity() { } } viewModel.internetConnection.observe(this) { isInternetAvailable -> hasInternet = isInternetAvailable if (isInternetAvailable) { binding.noInternet.visibility = View.GONE binding.fragment.visibility = View.VISIBLE viewModel.userType.observe(this) { user -> fun generateAuthDataBasedOnUserType(user: String) { if (user.isNotBlank() && viewModel.tocStatus.value == true) { when (User.valueOf(user)) { User.ANONYMOUS -> { Loading @@ -99,7 +94,7 @@ class MainActivity : AppCompatActivity() { } } User.UNAVAILABLE -> { viewModel.destroyCredentials() viewModel.destroyCredentials(null) } User.GOOGLE -> { if (viewModel.authData.value == null && !viewModel.authRequestRunning) { Loading @@ -111,6 +106,16 @@ class MainActivity : AppCompatActivity() { } } viewModel.internetConnection.observe(this) { isInternetAvailable -> hasInternet = isInternetAvailable if (isInternetAvailable) { binding.noInternet.visibility = View.GONE binding.fragment.visibility = View.VISIBLE viewModel.userType.observe(this) { user -> generateAuthDataBasedOnUserType(user) } signInViewModel.authLiveData.observe(this) { viewModel.updateAuthData(it) } Loading @@ -128,7 +133,9 @@ class MainActivity : AppCompatActivity() { viewModel.authValidity.observe(this) { if (it != true) { Log.d(TAG, "Authentication data validation failed!") viewModel.destroyCredentials() viewModel.destroyCredentials { user -> generateAuthDataBasedOnUserType(user) } } else { Log.d(TAG, "Authentication data is valid!") } Loading app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +24 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.Type import foundation.e.apps.utils.enums.User import foundation.e.apps.utils.modules.DataStoreModule import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading Loading @@ -101,9 +102,31 @@ class MainActivityViewModel @Inject constructor( _authData.value = authData } fun destroyCredentials() { fun destroyCredentials(regenerateFunction: ((user: String) -> Unit)?) { viewModelScope.launch { /* * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5168 * * Now destroyCredentials() no longer removes the user type from data store. * (i.e. Google login or Anonymous). * - If the type is User.ANONYMOUS then we do not prompt the user to login again, * we directly generate new auth data; which is the main Gitlab issue described above. * - If not anonymous user, i.e. type is User.GOOGLE, in that case we clear * the USERTYPE value. This causes HomeFragment.onTosAccepted() to open * SignInFragment as we need fresh login from the user. */ dataStoreModule.destroyCredentials() if (regenerateFunction != null) { dataStoreModule.userType.collect { user -> if (!user.isBlank() && User.valueOf(user) == User.ANONYMOUS) { Log.d(TAG, "Regenerating auth data for Anonymous user") regenerateFunction(user) } else { Log.d(TAG, "Ask Google user to log in again") dataStoreModule.clearUserType() } } } } } Loading app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +7 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.Type import foundation.e.apps.utils.modules.PWAManagerModule import foundation.e.apps.utils.modules.PreferenceManagerModule import javax.inject.Inject import javax.inject.Singleton Loading @@ -53,6 +54,7 @@ class FusedAPIImpl @Inject constructor( private val cleanAPKRepository: CleanAPKRepository, private val gPlayAPIRepository: GPlayAPIRepository, private val pkgManagerModule: PkgManagerModule, private val pwaManagerModule: PWAManagerModule, private val preferenceManagerModule: PreferenceManagerModule, @ApplicationContext private val context: Context ) { Loading Loading @@ -643,10 +645,14 @@ class FusedAPIImpl @Inject constructor( private fun FusedApp.updateStatus() { if (this.status != Status.INSTALLATION_ISSUE) { this.status = this.status = if (this.is_pwa) { pwaManagerModule.getPwaStatus(this) } else { pkgManagerModule.getPackageStatus(this.package_name, this.latest_version_code) } } } private fun FusedApp.updateType() { this.type = if (this.is_pwa) Type.PWA else Type.NATIVE Loading app/src/main/java/foundation/e/apps/api/fused/data/FusedApp.kt +1 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ data class FusedApp( val price: String = String(), val isFree: Boolean = true, val is_pwa: Boolean = false, var pwaPlayerDbId: Long = -1, val url: String = String(), var type: Type = Type.NATIVE, var privacyScore: Int = -1 Loading Loading
app/src/main/AndroidManifest.xml +13 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,19 @@ </intent-filter> </receiver> <receiver android:name=".receiver.PWAPlayerStatusReceiver" android:exported="true"> <intent-filter> <action android:name="foundation.e.pwaplayer.PWA_ADDED" /> </intent-filter> <intent-filter> <action android:name="foundation.e.pwaplayer.PWA_CHANGED" /> </intent-filter> <intent-filter> <action android:name="foundation.e.pwaplayer.PWA_REMOVED" /> </intent-filter> </receiver> <!-- If you want to disable android.startup completely. --> <provider android:name="androidx.startup.InitializationProvider" Loading
app/src/main/java/foundation/e/apps/MainActivity.kt +27 −20 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import foundation.e.apps.utils.modules.CommonUtilsModule import kotlinx.coroutines.launch import java.io.File import java.util.UUID import javax.inject.Inject @AndroidEntryPoint class MainActivity : AppCompatActivity() { Loading Loading @@ -83,13 +84,7 @@ class MainActivity : AppCompatActivity() { } } viewModel.internetConnection.observe(this) { isInternetAvailable -> hasInternet = isInternetAvailable if (isInternetAvailable) { binding.noInternet.visibility = View.GONE binding.fragment.visibility = View.VISIBLE viewModel.userType.observe(this) { user -> fun generateAuthDataBasedOnUserType(user: String) { if (user.isNotBlank() && viewModel.tocStatus.value == true) { when (User.valueOf(user)) { User.ANONYMOUS -> { Loading @@ -99,7 +94,7 @@ class MainActivity : AppCompatActivity() { } } User.UNAVAILABLE -> { viewModel.destroyCredentials() viewModel.destroyCredentials(null) } User.GOOGLE -> { if (viewModel.authData.value == null && !viewModel.authRequestRunning) { Loading @@ -111,6 +106,16 @@ class MainActivity : AppCompatActivity() { } } viewModel.internetConnection.observe(this) { isInternetAvailable -> hasInternet = isInternetAvailable if (isInternetAvailable) { binding.noInternet.visibility = View.GONE binding.fragment.visibility = View.VISIBLE viewModel.userType.observe(this) { user -> generateAuthDataBasedOnUserType(user) } signInViewModel.authLiveData.observe(this) { viewModel.updateAuthData(it) } Loading @@ -128,7 +133,9 @@ class MainActivity : AppCompatActivity() { viewModel.authValidity.observe(this) { if (it != true) { Log.d(TAG, "Authentication data validation failed!") viewModel.destroyCredentials() viewModel.destroyCredentials { user -> generateAuthDataBasedOnUserType(user) } } else { Log.d(TAG, "Authentication data is valid!") } Loading
app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +24 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.Type import foundation.e.apps.utils.enums.User import foundation.e.apps.utils.modules.DataStoreModule import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading Loading @@ -101,9 +102,31 @@ class MainActivityViewModel @Inject constructor( _authData.value = authData } fun destroyCredentials() { fun destroyCredentials(regenerateFunction: ((user: String) -> Unit)?) { viewModelScope.launch { /* * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5168 * * Now destroyCredentials() no longer removes the user type from data store. * (i.e. Google login or Anonymous). * - If the type is User.ANONYMOUS then we do not prompt the user to login again, * we directly generate new auth data; which is the main Gitlab issue described above. * - If not anonymous user, i.e. type is User.GOOGLE, in that case we clear * the USERTYPE value. This causes HomeFragment.onTosAccepted() to open * SignInFragment as we need fresh login from the user. */ dataStoreModule.destroyCredentials() if (regenerateFunction != null) { dataStoreModule.userType.collect { user -> if (!user.isBlank() && User.valueOf(user) == User.ANONYMOUS) { Log.d(TAG, "Regenerating auth data for Anonymous user") regenerateFunction(user) } else { Log.d(TAG, "Ask Google user to log in again") dataStoreModule.clearUserType() } } } } } Loading
app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +7 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.Type import foundation.e.apps.utils.modules.PWAManagerModule import foundation.e.apps.utils.modules.PreferenceManagerModule import javax.inject.Inject import javax.inject.Singleton Loading @@ -53,6 +54,7 @@ class FusedAPIImpl @Inject constructor( private val cleanAPKRepository: CleanAPKRepository, private val gPlayAPIRepository: GPlayAPIRepository, private val pkgManagerModule: PkgManagerModule, private val pwaManagerModule: PWAManagerModule, private val preferenceManagerModule: PreferenceManagerModule, @ApplicationContext private val context: Context ) { Loading Loading @@ -643,10 +645,14 @@ class FusedAPIImpl @Inject constructor( private fun FusedApp.updateStatus() { if (this.status != Status.INSTALLATION_ISSUE) { this.status = this.status = if (this.is_pwa) { pwaManagerModule.getPwaStatus(this) } else { pkgManagerModule.getPackageStatus(this.package_name, this.latest_version_code) } } } private fun FusedApp.updateType() { this.type = if (this.is_pwa) Type.PWA else Type.NATIVE Loading
app/src/main/java/foundation/e/apps/api/fused/data/FusedApp.kt +1 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ data class FusedApp( val price: String = String(), val isFree: Boolean = true, val is_pwa: Boolean = false, var pwaPlayerDbId: Long = -1, val url: String = String(), var type: Type = Type.NATIVE, var privacyScore: Int = -1 Loading