summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation
diff options
context:
space:
mode:
authorjacquarg <guillaume.jacquart@hoodbrains.com>2022-01-19 08:48:45 +0100
committerjacquarg <guillaume.jacquart@hoodbrains.com>2022-01-26 18:43:08 +0100
commit464d596efd5668baef0563127984dd43482c9235 (patch)
tree664f76dccbff60534bbfe59e7baf3219d90b354c /app/src/main/java/foundation
parente1c393d9d69c3ae1be3f9e600b29c8edf12635a1 (diff)
Ipscramble apps by default, remove tor service notification
Diffstat (limited to 'app/src/main/java/foundation')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/IpScramblingStateUseCase.kt14
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt31
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFeature.kt2
3 files changed, 24 insertions, 23 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 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<String> 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<ApplicationDescription>,
- val ipScrambledApps: Collection<String>,
+ val bypassTorApps: Collection<String>,
val selectedLocation: String,
val availableLocationIds: List<String>,
val forceRedraw: Boolean = false
) {
fun getApps(): List<Pair<ApplicationDescription, Boolean>> {
- 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<String>) : Effect()
+ data class IpScrambledAppsUpdatedEffect(val bypassTorApps: Collection<String>) : Effect()
data class AvailableAppsListEffect(
val apps: List<ApplicationDescription>,
- val ipScrambledApps: Collection<String>
+ val bypassTorApps: Collection<String>
) : 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<String>()
- 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<TrackersFeature.Effect>(
flow {
val statistics = trackersStatisticsUseCase.getDayMonthYearStatistics()
val counts = trackersStatisticsUseCase.getDayMonthYearCounts()