From fdeecefd34c00b225bd58f6cc7135a95e21728f1 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Fri, 14 Oct 2022 10:25:52 +0200 Subject: PR suggestions, make apply Hide Ip clearer --- .../domain/usecases/IpScramblingStateUseCase.kt | 14 ++++++++++---- .../e/privacymodules/trackers/DNSBlockerRunnable.kt | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/IpScramblingStateUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/IpScramblingStateUseCase.kt index 947e8e9..cb9fcd5 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/IpScramblingStateUseCase.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/IpScramblingStateUseCase.kt @@ -20,6 +20,10 @@ package foundation.e.privacycentralapp.domain.usecases import foundation.e.privacycentralapp.data.repositories.AppListsRepository import foundation.e.privacycentralapp.data.repositories.LocalStateRepository import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode +import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode.HIDE_IP +import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode.HIDE_IP_LOADING +import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode.REAL_IP +import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode.REAL_IP_LOADING import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule import foundation.e.privacymodules.permissions.IPermissionsPrivacyModule import foundation.e.privacymodules.permissions.data.ApplicationDescription @@ -126,14 +130,16 @@ class IpScramblingStateUseCase( } private fun applySettings(isQuickPrivacyEnabled: Boolean, isIpScramblingEnabled: Boolean) { - val mode = localStateRepository.internetPrivacyMode.value + val settingEnabled = isQuickPrivacyEnabled && isIpScramblingEnabled + val currentMode = localStateRepository.internetPrivacyMode.value + when { - isQuickPrivacyEnabled && isIpScramblingEnabled && - mode in setOf(InternetPrivacyMode.REAL_IP, InternetPrivacyMode.REAL_IP_LOADING) -> + settingEnabled && currentMode in setOf(REAL_IP, REAL_IP_LOADING) -> applyStartIpScrambling() - mode in setOf(InternetPrivacyMode.HIDE_IP, InternetPrivacyMode.HIDE_IP_LOADING) -> + !settingEnabled && currentMode in setOf(HIDE_IP, HIDE_IP_LOADING) -> ipScramblerModule.stop() + else -> {} } } diff --git a/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerRunnable.kt b/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerRunnable.kt index 42037e2..737aa4a 100644 --- a/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerRunnable.kt +++ b/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerRunnable.kt @@ -32,7 +32,7 @@ import java.io.InputStreamReader import java.io.PrintWriter class DNSBlockerRunnable( - ct: Context, + context: Context, private val trackersLogger: TrackersLogger, private val trackersRepository: TrackersRepository, private val whitelistRepository: WhitelistRepository @@ -48,7 +48,7 @@ class DNSBlockerRunnable( } init { - initEBrowserDoTFix(ct) + initEBrowserDoTFix(context) } @Synchronized -- cgit v1.2.1