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

Commit 1f6cce63 authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch 'crash_install_button_#5021' into background_install_#4986

parents f89d5cf9 f481a2e4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ dependencies {
    def retrofit_version = "2.9.0"
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
    implementation "com.squareup.moshi:moshi-kotlin:1.13.0"
//    implementation "com.squareup.moshi:moshi-adapters:1.5.0"
    implementation "com.squareup.okhttp3:okhttp:4.9.2"

    // Navigation Components
+13 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavOptions
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.aurora.gplayapi.exceptions.ApiException
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import foundation.e.apps.databinding.ActivityMainBinding
import foundation.e.apps.manager.workmanager.InstallWorkManager
@@ -167,11 +169,22 @@ class MainActivity : AppCompatActivity() {
            }
        }

        viewModel.errorMessage.observe(this) {
            when (it) {
                is ApiException.AppNotPurchased -> showSnackbarMessage(getString(R.string.message_app_available_later))
                else -> showSnackbarMessage(it.localizedMessage ?: getString(R.string.unknown_error))
            }
        }

        if (!CommonUtilsModule.isNetworkAvailable(this)) {
            showNoInternet()
        }
    }

    private fun showSnackbarMessage(message: String) {
        Snackbar.make(binding.root, message, Snackbar.LENGTH_SHORT).show()
    }

    private fun showNoInternet() {
        binding.noInternet.visibility = View.VISIBLE
        binding.fragment.visibility = View.GONE
+25 −16
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ class MainActivityViewModel @Inject constructor(
    // Downloads
    val downloadList = fusedManagerRepository.getDownloadLiveList()
    var installInProgress = false

    private val _errorMessage = MutableLiveData<Exception>()
    val errorMessage: LiveData<Exception> = _errorMessage
    /*
     * Authentication related functions
     */
@@ -120,10 +121,13 @@ class MainActivityViewModel @Inject constructor(

    fun getApplication(app: FusedApp, imageView: ImageView?) {
        viewModelScope.launch {
            val fusedDownload: FusedDownload
            try {
                val appIcon = imageView?.let { getImageBase64(it) } ?: ""
            val downloadList = getAppDownloadLink(app).toMutableList()
                val downloadList: List<String>
                downloadList = getAppDownloadLink(app).toMutableList()

            val fusedDownload = FusedDownload(
                fusedDownload = FusedDownload(
                    app._id,
                    app.origin,
                    app.status,
@@ -135,6 +139,11 @@ class MainActivityViewModel @Inject constructor(
                    app.type,
                    appIcon
                )
            } catch (e: Exception) {
                _errorMessage.value = e
                return@launch
            }

            if (fusedDownload.status == Status.INSTALLATION_ISSUE) {
                fusedManagerRepository.clearInstallationIssue(fusedDownload)
            }
+14 −4
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ package foundation.e.apps.api.cleanapk

import android.os.Build
import android.util.Log
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
@@ -47,26 +49,34 @@ object RetrofitModule {
     */
    @Singleton
    @Provides
    fun provideCleanAPKInterface(okHttpClient: OkHttpClient): CleanAPKInterface {
    fun provideCleanAPKInterface(okHttpClient: OkHttpClient, moshi: Moshi): CleanAPKInterface {
        return Retrofit.Builder()
            .baseUrl(CleanAPKInterface.BASE_URL)
            .client(okHttpClient)
            .addConverterFactory(MoshiConverterFactory.create())
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build()
            .create(CleanAPKInterface::class.java)
    }

    @Singleton
    @Provides
    fun provideExodusApi(okHttpClient: OkHttpClient): ExodusTrackerApi {
    fun provideExodusApi(okHttpClient: OkHttpClient, moshi: Moshi): ExodusTrackerApi {
        return Retrofit.Builder()
            .baseUrl(ExodusTrackerApi.BASE_URL)
            .client(okHttpClient)
            .addConverterFactory(MoshiConverterFactory.create())
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build()
            .create(ExodusTrackerApi::class.java)
    }

    @Singleton
    @Provides
    fun getMoshi(): Moshi {
        return Moshi.Builder()
            .add(KotlinJsonAdapterFactory())
            .build()
    }

    @Singleton
    @Provides
    fun provideInterceptor(): Interceptor {
+2 −2
Original line number Diff line number Diff line
@@ -14,6 +14,6 @@ interface ExodusTrackerApi {
    @GET("trackers?v=$VERSION")
    suspend fun getTrackerList(): Response<Trackers>

    @GET("search/{appHandle}")
    suspend fun getTrackerInfoOfApp(@Path("appHandle") appHandle: String): Response<Map<String, TrackerInfo>>
    @GET("search/{appHandle}/details?v=$VERSION")
    suspend fun getTrackerInfoOfApp(@Path("appHandle") appHandle: String): Response<List<Report>>
}
Loading