diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt index 40951778ec96d63c0161ad8347e3f9defa86dac9..c88ae84aac86a4732678079d9f6b36788b797b30 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt @@ -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 -> { diff --git a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt index fc68ab0b2bd4936dec0f16ae028026f1e04d0f12..f22b69256ffa5ce458140afddbec29ea6ff5f2d2 100644 --- a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt @@ -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) }