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

Commit 4ad1fcc3 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

fix(appUsageStats): Sort apps properly and filter them

parent 9e014334
Loading
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -65,13 +65,16 @@ class AppUsageStats(private val mContext: Context) {
                    .filter {
                    .filter {
                        !mContext.resources
                        !mContext.resources
                            .getStringArray(R.array.blacklisted_apps)
                            .getStringArray(R.array.blacklisted_apps)
                            .contains(it.key)
                            .contains(it.key) &&
                            mContext.packageManager.getLaunchIntentForPackage(it.key) != null &&
                            it.value.totalTimeInForeground > 0
                    }
                    }
                    .apply {
                    .apply {
                        sortedWith(
                        sortedWith(
                                Comparator.comparingLong { (_, stat) -> stat.totalTimeInForeground }
                                Comparator.comparingLong { (_, stat) -> stat.totalTimeInForeground }
                            )
                            )
                        forEach { (_, stat) -> usageStats.add(stat) }
                            .reversed()
                            .forEach { (_, stat) -> usageStats.add(stat) }
                    }
                    }
            } else {
            } else {
                Logger.i(TAG, "The aggregatedStats are empty can't do much")
                Logger.i(TAG, "The aggregatedStats are empty can't do much")