From e11e00a0e519bd629eff4fb5fa9fa7d2da95f51a Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 15 Jul 2024 22:22:59 +0530 Subject: [PATCH 1/3] UI changes for app list adapter --- .../ApplicationListRVAdapter.kt | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 40951778e..c88ae84aa 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 -> { -- GitLab From 910ccb1c7a35c8fbd22a403c68c16c597f416dcb Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 15 Jul 2024 22:23:28 +0530 Subject: [PATCH 2/3] UI changes for UpdatesFragment --- .../e/apps/ui/updates/UpdatesFragment.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 fc68ab0b2..158205d7b 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,20 @@ 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 updateList = result.first + val resultStatus = result.second + + val systemAppsUpdates = updateList.filter { it.isSystemApp } + val userAppsUpdates = updateList.filter { !it.isSystemApp } + + // Put system apps on top + val appsToDisplay = systemAppsUpdates + userAppsUpdates + + listAdapter?.setData(appsToDisplay) if (!isDownloadObserverAdded) { - handleStateNoUpdates(it.first) + handleStateNoUpdates(updateList) observeDownloadList() isDownloadObserverAdded = true } @@ -143,8 +153,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) } -- GitLab From 67cd229d79112e3c7c117a6093a458969034d3b5 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 18 Jul 2024 06:34:00 +0530 Subject: [PATCH 3/3] use sortedByDescending --- .../java/foundation/e/apps/ui/updates/UpdatesFragment.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 158205d7b..f22b69256 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 @@ -134,18 +134,15 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI private fun observeUpdateList(listAdapter: ApplicationListRVAdapter?) { updatesViewModel.updatesList.observe(viewLifecycleOwner) { result -> - val updateList = result.first + val appsUpdateList = result.first val resultStatus = result.second - val systemAppsUpdates = updateList.filter { it.isSystemApp } - val userAppsUpdates = updateList.filter { !it.isSystemApp } - // Put system apps on top - val appsToDisplay = systemAppsUpdates + userAppsUpdates + val appsToDisplay = appsUpdateList.sortedByDescending { it.isSystemApp } listAdapter?.setData(appsToDisplay) if (!isDownloadObserverAdded) { - handleStateNoUpdates(updateList) + handleStateNoUpdates(appsUpdateList) observeDownloadList() isDownloadObserverAdded = true } -- GitLab