diff options
4 files changed, 37 insertions, 4 deletions
diff --git a/app/build.gradle b/app/build.gradle index ff11a81..a453160 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,8 +98,8 @@ dependencies { //googleImplementation project(":privacymodulesgoogle") // include the e specific version of the modules, just for the e flavor - implementation 'foundation.e:privacymodule.trackerfilter:0.1.2' - implementation 'foundation.e:privacymodule.api:0.4.1' + implementation 'foundation.e:privacymodule.trackerfilter:0.1.3' + implementation 'foundation.e:privacymodule.api:0.4.3' implementation 'foundation.e:privacymodule.e-29:0.4.1' implementation 'foundation.e:privacymodule.tor:0.1.1' diff --git a/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt b/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt index 1553b52..102d970 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt @@ -80,7 +80,7 @@ class DependencyContainer constructor(val app: Application) { private val ipScramblingStateUseCase by lazy { IpScramblingStateUseCase(ipScramblerModule, permissionsModule, appDesc, localStateRepository, GlobalScope) } - private val appListUseCase = AppListUseCase(permissionsModule, GlobalScope) + private val appListUseCase = AppListUseCase(permissionsModule, blockTrackersPrivacyModule, GlobalScope) private val trackersStatisticsUseCase by lazy { TrackersStatisticsUseCase(trackTrackersPrivacyModule) 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 index 57168c5..a72360e 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt @@ -20,6 +20,7 @@ package foundation.e.privacycentralapp.domain.usecases import android.Manifest import foundation.e.privacymodules.permissions.PermissionsPrivacyModule import foundation.e.privacymodules.permissions.data.ApplicationDescription +import foundation.e.trackerfilter.api.BlockTrackersPrivacyModule import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -27,6 +28,7 @@ import kotlinx.coroutines.launch class AppListUseCase( private val permissionsModule: PermissionsPrivacyModule, + private val blockTrackersPrivacyModule: BlockTrackersPrivacyModule, private val corouteineScope: CoroutineScope ) { @@ -45,6 +47,37 @@ class AppListUseCase( return _installedAppsUsingInternet } + fun getBlockableApps(): Flow<List<ApplicationDescription>> { + corouteineScope.launch { + _installedAppsUsingInternet.value = getBlockableAppsList() + } + return _installedAppsUsingInternet + } + + private fun getBlockableAppsList(): List<ApplicationDescription> { + return blockTrackersPrivacyModule.getBlockableApps() + .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 + } + } + }) + } + private fun getInstalledAppsUsingInternetList(): List<ApplicationDescription> { return permissionsModule.getInstalledApplications() .filter { diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFeature.kt index 9bd2c7a..4728158 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFeature.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFeature.kt @@ -130,7 +130,7 @@ class TrackersFeature( ) ) }, - appListUseCase.getInstalledAppsUsingInternet().map { apps -> + appListUseCase.getBlockableApps().map { apps -> Effect.AvailableAppsListEffect(apps) } ) |