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

Commit 444831f6 authored by Hasib Prince's avatar Hasib Prince
Browse files

App Lounge: AppNotFound exception is handled

parent 3ac6654b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ class MainActivity : AppCompatActivity() {
        }
    }

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

+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textview.MaterialTextView
import dagger.hilt.android.AndroidEntryPoint
import foundation.e.apps.AppInfoFetchViewModel
import foundation.e.apps.MainActivity
import foundation.e.apps.MainActivityViewModel
import foundation.e.apps.PrivacyInfoViewModel
import foundation.e.apps.R
@@ -258,6 +259,10 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) {
            observeDownloadStatus(view)
            fetchAppTracker(it)
        }

        applicationViewModel.errorMessageLiveData.observe(viewLifecycleOwner) {
            (requireActivity() as MainActivity).showSnackbarMessage(getString(it))
        }
    }

    private fun observeDownloadStatus(view: View) {
+19 −8
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.exceptions.ApiException
import dagger.hilt.android.lifecycle.HiltViewModel
import foundation.e.apps.R
import foundation.e.apps.api.fused.FusedAPIRepository
import foundation.e.apps.api.fused.data.FusedApp
import foundation.e.apps.manager.database.fusedDownload.FusedDownload
@@ -47,9 +49,12 @@ class ApplicationViewModel @Inject constructor(
    val fusedApp: MutableLiveData<FusedApp> = MutableLiveData()
    val appStatus: MutableLiveData<Status?> = MutableLiveData()
    val downloadProgress = downloadProgressLD
    private val _errorMessageLiveData: MutableLiveData<Int> = MutableLiveData()
    val errorMessageLiveData: MutableLiveData<Int> = _errorMessageLiveData

    fun getApplicationDetails(id: String, packageName: String, authData: AuthData, origin: Origin) {
        viewModelScope.launch(Dispatchers.IO) {
            try {
                fusedApp.postValue(
                    fusedAPIRepository.getApplicationDetails(
                        id,
@@ -58,6 +63,11 @@ class ApplicationViewModel @Inject constructor(
                        origin
                    )
                )
            } catch (e: ApiException.AppNotFound) {
                _errorMessageLiveData.postValue(R.string.app_not_found)
            } catch (e: Exception) {
                _errorMessageLiveData.postValue(R.string.unknown_error)
            }
        }
    }

@@ -107,7 +117,8 @@ class ApplicationViewModel @Inject constructor(
        fusedApp.value?.let { app ->
            val downloadingItem =
                downloadList.find { it.origin == app.origin && (it.packageName == app.package_name || it.id == app.package_name) }
            appStatus.value = downloadingItem?.status ?: fusedAPIRepository.getFusedAppInstallationStatus(app)
            appStatus.value =
                downloadingItem?.status ?: fusedAPIRepository.getFusedAppInstallationStatus(app)
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@
    <string name="message_app_available_later">This app will be available later!</string>
    <string name="unknown_error">Unknown Error!</string>
    <string name="not_enough_storage">There is not enough space available to download this application!</string>
    <string name="app_not_found">Your application was not found.</string>

    <!-- Updates Fragment -->
    <string name="update_all">Update All</string>