From 464d596efd5668baef0563127984dd43482c9235 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Wed, 19 Jan 2022 08:48:45 +0100 Subject: Ipscramble apps by default, remove tor service notification --- .../domain/usecases/IpScramblingStateUseCase.kt | 14 +++++++++- .../internetprivacy/InternetPrivacyFeature.kt | 31 +++++++--------------- .../features/trackers/TrackersFeature.kt | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'app/src/main/java/foundation/e') 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 3caab63..9e83eb1 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 @@ -80,6 +80,18 @@ class IpScramblingStateUseCase( applySettings(true, hideIp) } + val bypassTorApps: Set get() = ipScramblerModule.appList + + fun toggleBypassTor(packageName: String) { + val currentList = bypassTorApps.toMutableSet() + if (currentList.contains(packageName)) { + currentList.remove(packageName) + } else { + currentList.add(packageName) + } + ipScramblerModule.appList = currentList + } + private fun applySettings(isQuickPrivacyEnabled: Boolean, isIpScramblingEnabled: Boolean) { when { isQuickPrivacyEnabled && isIpScramblingEnabled -> when (internetPrivacyMode.value) { @@ -88,7 +100,7 @@ class IpScramblingStateUseCase( if (intent != null) { permissionsPrivacyModule.setVpnPackageAuthorization(appDesc.packageName) } - ipScramblerModule.start() + ipScramblerModule.start(enableNotification = false) } else -> { Log.d("testQPFlow", "Not starting tor, already in started state") diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt index 767ac7a..26370cf 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt @@ -57,13 +57,13 @@ class InternetPrivacyFeature( data class State( val mode: InternetPrivacyMode, val availableApps: List, - val ipScrambledApps: Collection, + val bypassTorApps: Collection, val selectedLocation: String, val availableLocationIds: List, val forceRedraw: Boolean = false ) { fun getApps(): List> { - return availableApps.map { it to (it.packageName in ipScrambledApps) } + return availableApps.map { it to (it.packageName !in bypassTorApps) } } val selectedLocationPosition get() = availableLocationIds.indexOf(selectedLocation) @@ -89,10 +89,10 @@ class InternetPrivacyFeature( data class QuickPrivacyUpdatedEffect(val enabled: Boolean) : Effect() object QuickPrivacyDisabledWarningEffect : Effect() data class ShowAndroidVpnDisclaimerEffect(val intent: Intent) : Effect() - data class IpScrambledAppsUpdatedEffect(val ipScrambledApps: Collection) : Effect() + data class IpScrambledAppsUpdatedEffect(val bypassTorApps: Collection) : Effect() data class AvailableAppsListEffect( val apps: List, - val ipScrambledApps: Collection + val bypassTorApps: Collection ) : Effect() data class LocationSelectedEffect(val locationId: String) : Effect() data class ErrorEffect(val message: String) : Effect() @@ -109,7 +109,7 @@ class InternetPrivacyFeature( initialState: State = State( mode = InternetPrivacyMode.REAL_IP, availableApps = emptyList(), - ipScrambledApps = emptyList(), + bypassTorApps = emptyList(), availableLocationIds = availablesLocationsIds, selectedLocation = "" ) @@ -118,10 +118,10 @@ class InternetPrivacyFeature( reducer = { state, effect -> when (effect) { is Effect.ModeUpdatedEffect -> state.copy(mode = effect.mode) - is Effect.IpScrambledAppsUpdatedEffect -> state.copy(ipScrambledApps = effect.ipScrambledApps) + is Effect.IpScrambledAppsUpdatedEffect -> state.copy(bypassTorApps = effect.bypassTorApps) is Effect.AvailableAppsListEffect -> state.copy( availableApps = effect.apps, - ipScrambledApps = effect.ipScrambledApps + bypassTorApps = effect.bypassTorApps ) is Effect.LocationSelectedEffect -> state.copy(selectedLocation = effect.locationId) Effect.QuickPrivacyDisabledWarningEffect -> state.copy(forceRedraw = !state.forceRedraw) @@ -134,13 +134,9 @@ class InternetPrivacyFeature( getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map { Effect.QuickPrivacyUpdatedEffect(it) }, ipScramblingStateUseCase.internetPrivacyMode.map { Effect.ModeUpdatedEffect(it) }.shareIn(scope = coroutineScope, started = SharingStarted.Lazily, replay = 0), appListUseCase.getAppsUsingInternet().map { apps -> - if (ipScramblerModule.appList.isEmpty()) { - ipScramblerModule.appList = - apps.map { it.packageName }.toMutableSet() - } Effect.AvailableAppsListEffect( apps, - ipScramblerModule.appList + ipScramblingStateUseCase.bypassTorApps ) }, flowOf(Effect.LocationSelectedEffect(ipScramblerModule.exitCountry)) @@ -187,15 +183,8 @@ class InternetPrivacyFeature( } action is Action.ToggleAppIpScrambled -> { - val ipScrambledApps = mutableSetOf() - ipScrambledApps.addAll(ipScramblerModule.appList) - if (ipScrambledApps.contains(action.packageName)) { - ipScrambledApps.remove(action.packageName) - } else { - ipScrambledApps.add(action.packageName) - } - ipScramblerModule.appList = ipScrambledApps - flowOf(Effect.IpScrambledAppsUpdatedEffect(ipScrambledApps = ipScrambledApps)) + ipScramblingStateUseCase.toggleBypassTor(action.packageName) + flowOf(Effect.IpScrambledAppsUpdatedEffect(bypassTorApps = ipScramblingStateUseCase.bypassTorApps)) } action is Action.SelectLocationAction -> { val locationId = state.availableLocationIds[action.position] 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 4728158..64cc71e 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 @@ -115,7 +115,7 @@ class TrackersFeature( }, actor = { state, action -> when (action) { - Action.InitAction -> merge( + Action.InitAction -> merge( flow { val statistics = trackersStatisticsUseCase.getDayMonthYearStatistics() val counts = trackersStatisticsUseCase.getDayMonthYearCounts() -- cgit v1.2.1 From d289ac7d62b4bb0311f145618347b2b81449664d Mon Sep 17 00:00:00 2001 From: jacquarg Date: Fri, 21 Jan 2022 09:28:41 +0100 Subject: Fix radio btn auto-toggle on My Internet Privacy open. --- .../features/internetprivacy/InternetPrivacyFeature.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/foundation/e') diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt index 26370cf..6ff3d27 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt @@ -107,7 +107,7 @@ class InternetPrivacyFeature( appListUseCase: AppListUseCase, availablesLocationsIds: List, initialState: State = State( - mode = InternetPrivacyMode.REAL_IP, + mode = ipScramblingStateUseCase.internetPrivacyMode.value, availableApps = emptyList(), bypassTorApps = emptyList(), availableLocationIds = availablesLocationsIds, -- cgit v1.2.1 From 16a3188ef42a6ae2ed0df707a6b6fcc53b530c37 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Sun, 23 Jan 2022 19:43:17 +0100 Subject: Grey list of apps on my internet activity while tor disabled. --- .../e/privacycentralapp/common/ToggleAppsAdapter.kt | 12 ++++++++++-- .../features/internetprivacy/InternetPrivacyFragment.kt | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/foundation/e') diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt b/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt index 82f8d43..9d62381 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt @@ -38,9 +38,10 @@ class ToggleAppsAdapter( val togglePermission: CheckBox = view.findViewById(R.id.toggle) - fun bind(item: Pair) { + fun bind(item: Pair, isEnabled: Boolean) { appName.text = item.first.label togglePermission.isChecked = item.second + togglePermission.isEnabled = isEnabled itemView.findViewById(R.id.icon).setImageDrawable(item.first.icon) } @@ -52,6 +53,13 @@ class ToggleAppsAdapter( notifyDataSetChanged() } + var isEnabled: Boolean = true + + fun setData(list: List>, isEnabled: Boolean = true) { + this.isEnabled = isEnabled + dataSet = list + } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(parent.context) .inflate(itemsLayout, parent, false) @@ -64,7 +72,7 @@ class ToggleAppsAdapter( override fun onBindViewHolder(holder: ViewHolder, position: Int) { val permission = dataSet[position] - holder.bind(permission) + holder.bind(permission, isEnabled) } override fun getItemCount(): Int = dataSet.size diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt index 3e0b549..f288320 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt @@ -155,7 +155,10 @@ class InternetPrivacyFragment : // TODO: this should not be mandatory. binding.apps.post { - (binding.apps.adapter as ToggleAppsAdapter?)?.dataSet = state.getApps() + (binding.apps.adapter as ToggleAppsAdapter?)?.setData( + list = state.getApps(), + isEnabled = state.mode == InternetPrivacyMode.HIDE_IP + ) } val viewIdsToHide = listOf( -- cgit v1.2.1 From 15e40cdd3b4a9d45f3508195083d4e73b5deed1a Mon Sep 17 00:00:00 2001 From: jacquarg Date: Sun, 23 Jan 2022 19:59:02 +0100 Subject: Deactivate geolocation options while big btn is off --- .../features/location/FakeLocationFragment.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/foundation/e') diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt index 60b9bd9..76c586c 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt @@ -222,10 +222,20 @@ class FakeLocationFragment : @SuppressLint("MissingPermission") override fun render(state: FakeLocationFeature.State) { - binding.radioUseRandomLocation.isChecked = (state.mode == LocationMode.RANDOM_LOCATION) - binding.radioUseSpecificLocation.isChecked = - (state.mode == LocationMode.SPECIFIC_LOCATION) - binding.radioUseRealLocation.isChecked = (state.mode == LocationMode.REAL_LOCATION) + binding.radioUseRandomLocation.apply { + isChecked = state.mode == LocationMode.RANDOM_LOCATION + isEnabled = state.isEnabled + } + + binding.radioUseSpecificLocation.apply { + isChecked = state.mode == LocationMode.SPECIFIC_LOCATION + isEnabled = state.isEnabled + } + + binding.radioUseRealLocation.apply { + isChecked = state.mode == LocationMode.REAL_LOCATION + isEnabled = state.isEnabled + } binding.mapView.isEnabled = (state.mode == LocationMode.SPECIFIC_LOCATION) -- cgit v1.2.1