From 366e4ffa04e8d301794e613b89ed918df0b59517 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Fri, 29 Oct 2021 16:44:39 +0200 Subject: Update IPScrambling UI --- .../domain/usecases/AppListUseCase.kt | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt (limited to 'app/src/main/java/foundation/e/privacycentralapp/domain') 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 . + */ + +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 { + return permissionsModule.getInstalledApplications() + .filter { + permissionsModule.getPermissions(it.packageName) + .contains(Manifest.permission.INTERNET) + }.map { + it.icon = permissionsModule.getApplicationIcon(it.packageName) + it + }.sortedWith(object : Comparator { + 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 + } + } + }) + } +} -- cgit v1.2.3