Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0382dd80 authored by Hasib Prince's avatar Hasib Prince
Browse files

App Lounge: some debug log added

parent c1e1e1e5
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ dependencies {
    implementation "io.coil-kt:coil:1.4.0"
    implementation 'com.github.Baseflow:PhotoView:2.3.0'

    implementation 'com.jakewharton.timber:timber:5.0.1'

    //Protobuf and Gson
    implementation 'com.google.code.gson:gson:2.8.9'
    implementation "com.google.protobuf:protobuf-java:3.14.0"
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import foundation.e.apps.utils.modules.DataStoreModule
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import timber.log.Timber
import java.util.concurrent.Executors
import javax.inject.Inject

@@ -60,6 +61,9 @@ class AppLoungeApplication : Application(), Configuration.Provider {
                dataStoreModule.saveTOCStatus(false, "")
            }
        }
        if(BuildConfig.DEBUG) {
            Timber.plant(Timber.DebugTree())
        }
    }

    override fun getWorkManagerConfiguration() =
+6 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ 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
import timber.log.Timber
import java.io.File
import java.util.UUID

@@ -96,6 +97,7 @@ class MainActivity : AppCompatActivity() {
                        }
                    }
                    User.UNAVAILABLE -> {
                        Timber.d(">>> UNAVAILABLE > destorycredentials")
                        viewModel.destroyCredentials(null)
                    }
                    User.GOOGLE -> {
@@ -116,6 +118,7 @@ class MainActivity : AppCompatActivity() {
                binding.fragment.visibility = View.VISIBLE

                viewModel.userType.observe(this) { user ->
                    Timber.d(">>> auth: usertype")
                    generateAuthDataBasedOnUserType(user)
                }

@@ -125,8 +128,10 @@ class MainActivity : AppCompatActivity() {

                // Watch and refresh authentication data
                viewModel.authDataJson.observe(this) {
                    Timber.d(">>> auth: authDataJson: ")
                    if (!it.isNullOrEmpty()) {
                        viewModel.generateAuthData()
                        viewModel.validateAuthData()
                        Log.d(TAG, "Authentication data is available!")
                    }
                }
@@ -134,6 +139,7 @@ class MainActivity : AppCompatActivity() {
        }

        viewModel.authValidity.observe(this) {
            Timber.d(">>> auth: authvalidity: $it")
            if (it != true) {
                Log.d(TAG, "Authentication data validation failed!")
                viewModel.destroyCredentials { user ->
+16 −3
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import foundation.e.apps.utils.modules.DataStoreModule
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import ru.beryukhov.reactivenetwork.ReactiveNetwork
import timber.log.Timber
import java.io.ByteArrayOutputStream
import javax.inject.Inject

@@ -123,8 +124,12 @@ class MainActivityViewModel @Inject constructor(
     * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5404
     */
    fun retryFetchingTokenAfterTimeout() {
        if(userType.value?.contentEquals(User.UNAVAILABLE.name) == true) {
            return
        }
        firstAuthDataFetchTime = 0
        setFirstTokenFetchTime()
        Timber.d(">>> authvalidity postvalue > retryfetching")
        authValidity.postValue(false)
    }

@@ -155,6 +160,7 @@ class MainActivityViewModel @Inject constructor(
                 */
                if (!fusedAPIRepository.fetchAuthData()) {
                    authRequestRunning = false
                    Timber.d(">>> authvalidity postvalue > getAuthData")
                    authValidity.postValue(false)
                }
            }
@@ -186,6 +192,7 @@ class MainActivityViewModel @Inject constructor(
                        regenerateFunction(user)
                    } else {
                        Log.d(TAG, "Ask Google user to log in again")
                        Timber.d(">>> cleared user type")
                        dataStoreModule.clearUserType()
                    }
                }
@@ -196,11 +203,17 @@ class MainActivityViewModel @Inject constructor(
    fun generateAuthData() {
        val data = gson.fromJson(authDataJson.value, AuthData::class.java)
        _authData.value = data
    }

    fun validateAuthData() {
        _authData.value?.let {
            viewModelScope.launch {
            authValidity.postValue(isAuthValid(data))
                Timber.d(">>> authvalidity postvalue > validateAuthData")
                authValidity.postValue(isAuthValid(it))
                authRequestRunning = false
            }
        }
    }

    private suspend fun isAuthValid(authData: AuthData): Boolean {
        return fusedAPIRepository.validateAuthData(authData)
+11 −3
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@ class FusedAPIRepository @Inject constructor(
    }

    suspend fun validateAuthData(authData: AuthData): Boolean {
        return fusedAPIImpl.validateAuthData(authData)
        return authData.authToken.isEmpty() || authData.deviceInfoProvider == null || fusedAPIImpl.validateAuthData(
            authData
        )
    }

    suspend fun getApplicationDetails(
@@ -91,7 +93,10 @@ class FusedAPIRepository @Inject constructor(
        )
    }

    suspend fun getCategoriesList(type: Category.Type, authData: AuthData): Triple<List<FusedCategory>, String, ResultStatus> {
    suspend fun getCategoriesList(
        type: Category.Type,
        authData: AuthData
    ): Triple<List<FusedCategory>, String, ResultStatus> {
        return fusedAPIImpl.getCategoriesList(type, authData)
    }

@@ -107,7 +112,10 @@ class FusedAPIRepository @Inject constructor(
        return fusedAPIImpl.fetchAuthData(email, aasToken)
    }

    suspend fun getSearchResults(query: String, authData: AuthData): Pair<List<FusedApp>, ResultStatus> {
    suspend fun getSearchResults(
        query: String,
        authData: AuthData
    ): Pair<List<FusedApp>, ResultStatus> {
        return fusedAPIImpl.getSearchResults(query, authData)
    }

Loading