aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/foundation/e/privacycentralapp/domain
diff options
context:
space:
mode:
authorjacquarg <guillaume.jacquart@hoodbrains.com>2021-10-29 16:44:39 +0200
committerjacquarg <guillaume.jacquart@hoodbrains.com>2021-10-29 18:00:47 +0200
commit366e4ffa04e8d301794e613b89ed918df0b59517 (patch)
treee956d7f30128ef6f5bdd2494be288ee1cb41ce20 /app/src/main/java/foundation/e/privacycentralapp/domain
parent74fb672978043886e261eb66c47658caf05812bb (diff)
downloadadvanced-privacy-366e4ffa04e8d301794e613b89ed918df0b59517.tar.gz
Update IPScrambling UI
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/domain')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt
new file mode 100644
index 0000000..8ce08a3
--- /dev/null
+++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 E FOUNDATION
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package foundation.e.privacycentralapp.domain.usecases
+
+import android.Manifest
+import foundation.e.privacymodules.permissions.PermissionsPrivacyModule
+import foundation.e.privacymodules.permissions.data.ApplicationDescription
+
+class AppListUseCase(
+ private val permissionsModule: PermissionsPrivacyModule
+) {
+
+ fun getAppsUsingInternet(): List<ApplicationDescription> {
+ return permissionsModule.getInstalledApplications()
+ .filter {
+ permissionsModule.getPermissions(it.packageName)
+ .contains(Manifest.permission.INTERNET)
+ }.map {
+ it.icon = permissionsModule.getApplicationIcon(it.packageName)
+ it
+ }.sortedWith(object : Comparator<ApplicationDescription> {
+ override fun compare(
+ p0: ApplicationDescription?,
+ p1: ApplicationDescription?
+ ): Int {
+ return if (p0?.icon != null && p1?.icon != null) {
+ p0.label.toString().compareTo(p1.label.toString())
+ } else if (p0?.icon == null) {
+ 1
+ } else {
+ -1
+ }
+ }
+ })
+ }
+}