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 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app') 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 -> {} } } -- cgit v1.2.1