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

Commit 4be4c252 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

Merge branch '8124-update_system_apps_p4' into '8124-update_system_apps_p3'

feat: (Issue 8124) UI to show system apps in the update list

See merge request !478
parents ee14c4d3 75fb4782
Loading
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ package foundation.e.apps.ui.applicationlist
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.core.view.children
import androidx.core.view.isVisible
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
@@ -176,12 +178,24 @@ class ApplicationListRVAdapter(
                }
            }
            Origin.GITLAB_RELEASES -> {
                // TODO
                setSystemAppIcon(appIcon, searchApp)
            }
            else -> Timber.wtf("${searchApp.package_name} is from an unknown origin")
        }
    }

    private fun setSystemAppIcon(imageView: ImageView, app: Application) {
        if (!app.isSystemApp) return
        try {
            imageView.run {
                setImageDrawable(context.packageManager.getApplicationIcon(app.package_name))
            }
        } catch (e: Exception) {
            Timber.w("Icon could not be set for system app - ${app.package_name} - ${e.message}")
            e.printStackTrace()
        }
    }

    private fun ApplicationListItemBinding.updateAppInfo(searchApp: Application) {
        appTitle.text = searchApp.name
        appInfoFetchViewModel.getAuthorName(searchApp).observe(lifecycleOwner!!) {
@@ -190,6 +204,11 @@ class ApplicationListRVAdapter(
    }

    private fun ApplicationListItemBinding.updateRating(searchApp: Application) {
        if (searchApp.isSystemApp) {
            iconStar.isVisible = false
            appRating.isVisible = false
            return
        }
        if (searchApp.ratings.usageQualityScore != -1.0) {
            appRating.text = searchApp.ratings.usageQualityScore.toString()
        } else {
@@ -201,6 +220,10 @@ class ApplicationListRVAdapter(
        searchApp: Application,
        view: View
    ) {
        if (searchApp.isSystemApp) {
            appPrivacyScoreLayout.isVisible = false
            return
        }
        if (searchApp.ratings.privacyScore != -1.0) {
            appPrivacyScore.text = view.context.getString(
                R.string.privacy_rating_out_of,
@@ -222,6 +245,9 @@ class ApplicationListRVAdapter(
        searchApp: Application,
        view: View
    ) {
        if (searchApp.isSystemApp) {
            return
        }
        val catText = searchApp.category.ifBlank { optionalCategory }
        val action = when (currentDestinationId) {
            R.id.applicationListFragment -> {
+12 −5
Original line number Diff line number Diff line
@@ -132,10 +132,17 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI
    }

    private fun observeUpdateList(listAdapter: ApplicationListRVAdapter?) {
        updatesViewModel.updatesList.observe(viewLifecycleOwner) {
            listAdapter?.setData(it.first)
        updatesViewModel.updatesList.observe(viewLifecycleOwner) { result ->

            val appsUpdateList = result.first
            val resultStatus = result.second

            // Put system apps on top
            val appsToDisplay = appsUpdateList.sortedByDescending { it.isSystemApp }

            listAdapter?.setData(appsToDisplay)
            if (!isDownloadObserverAdded) {
                handleStateNoUpdates(it.first)
                handleStateNoUpdates(appsUpdateList)
                observeDownloadList()
                isDownloadObserverAdded = true
            }
@@ -143,8 +150,8 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI
            stopLoadingUI()

            Timber.d("===>> observeupdate list called")
            if (it.second != ResultStatus.OK) {
                val exception = GPlayException(it.second == ResultStatus.TIMEOUT)
            if (resultStatus != ResultStatus.OK) {
                val exception = GPlayException(resultStatus == ResultStatus.TIMEOUT)
                val alertDialogBuilder = AlertDialog.Builder(requireContext())
                onTimeout(exception, alertDialogBuilder)
            }