summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt2
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt22
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt2
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyViewModel.kt3
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt2
-rw-r--r--app/src/main/res/values/strings.xml1
6 files changed, 27 insertions, 5 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
index e60243d..89f0dd1 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
@@ -39,9 +39,11 @@ import foundation.e.privacycentralapp.features.dashboard.DashboardFeature.State
import foundation.e.privacycentralapp.features.internetprivacy.InternetPrivacyFragment
import foundation.e.privacycentralapp.features.location.FakeLocationFragment
import foundation.e.privacycentralapp.features.trackers.TrackersFragment
+import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
+@FlowPreview
class DashboardFragment :
NavToolbarFragment(R.layout.fragment_dashboard),
MVIView<DashboardFeature.State, DashboardFeature.Action> {
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 8d50980..eca1578 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
@@ -33,7 +33,9 @@ import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule
import foundation.e.privacymodules.permissions.data.ApplicationDescription
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
@@ -96,10 +98,13 @@ class InternetPrivacyFeature(
val bypassTorApps: Collection<String>
) : Effect()
data class LocationSelectedEffect(val locationId: String) : Effect()
+ object WarningStartingLongEffect : Effect()
data class ErrorEffect(val message: String) : Effect()
}
companion object {
+ private const val WARNING_LOADING_LONG_DELAY = 5 * 1000L
+ @FlowPreview
fun create(
coroutineScope: CoroutineScope,
ipScramblerModule: IIpScramblerModule,
@@ -132,15 +137,22 @@ class InternetPrivacyFeature(
actor = { state, action ->
when {
action is Action.LoadInternetModeAction -> merge(
- getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map { Effect.QuickPrivacyUpdatedEffect(it) },
- ipScramblingStateUseCase.internetPrivacyMode.map { Effect.ModeUpdatedEffect(it) }.shareIn(scope = coroutineScope, started = SharingStarted.Lazily, replay = 0),
+ getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow
+ .map { Effect.QuickPrivacyUpdatedEffect(it) },
+ ipScramblingStateUseCase.internetPrivacyMode
+ .map { Effect.ModeUpdatedEffect(it) }
+ .shareIn(scope = coroutineScope, started = SharingStarted.Lazily, replay = 0),
appListUseCase.getAppsUsingInternet().map { apps ->
Effect.AvailableAppsListEffect(
apps,
ipScramblingStateUseCase.bypassTorApps
)
},
- flowOf(Effect.LocationSelectedEffect(ipScramblerModule.exitCountry))
+ flowOf(Effect.LocationSelectedEffect(ipScramblerModule.exitCountry)),
+ ipScramblingStateUseCase.internetPrivacyMode
+ .map { it == InternetPrivacyMode.HIDE_IP_LOADING }
+ .debounce(WARNING_LOADING_LONG_DELAY)
+ .map { if (it) Effect.WarningStartingLongEffect else Effect.NoEffect }
).flowOn(Dispatchers.Default)
action is Action.AndroidVpnActivityResultAction ->
if (action.resultCode == Activity.RESULT_OK) {
@@ -202,7 +214,9 @@ class InternetPrivacyFeature(
singleEventProducer = { _, action, effect ->
when {
effect is Effect.ErrorEffect -> SingleEvent.ErrorEvent(effect.message)
- effect == Effect.QuickPrivacyDisabledWarningEffect -> SingleEvent.ErrorEvent(error = R.string.ipscrambling_error_quickprivacy_disabled)
+ effect is Effect.WarningStartingLongEffect ->
+ SingleEvent.ErrorEvent(R.string.ipscrambling_warning_starting_long)
+ effect is Effect.QuickPrivacyDisabledWarningEffect -> SingleEvent.ErrorEvent(error = R.string.ipscrambling_error_quickprivacy_disabled)
action is Action.UseHiddenIPAction
&& effect is Effect.ShowAndroidVpnDisclaimerEffect ->
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 07e0627..f49399f 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
@@ -36,10 +36,12 @@ import foundation.e.privacycentralapp.databinding.FragmentInternetActivityPolicy
import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode
import foundation.e.privacycentralapp.extensions.toText
import foundation.e.privacycentralapp.extensions.viewModelProviderFactoryOf
+import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import java.util.Locale
+@FlowPreview
class InternetPrivacyFragment :
NavToolbarFragment(R.layout.fragment_internet_activity_policy),
MVIView<InternetPrivacyFeature.State, InternetPrivacyFeature.Action> {
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyViewModel.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyViewModel.kt
index 08da69e..8bb7d9f 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyViewModel.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyViewModel.kt
@@ -24,6 +24,7 @@ import foundation.e.privacycentralapp.domain.usecases.AppListUseCase
import foundation.e.privacycentralapp.domain.usecases.GetQuickPrivacyStateUseCase
import foundation.e.privacycentralapp.domain.usecases.IpScramblingStateUseCase
import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule
+import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch
@@ -40,7 +41,7 @@ class InternetPrivacyViewModel(
val availablesLocationsIds = listOf("", *ipScramblerModule.getAvailablesLocations().sorted().toTypedArray())
- val internetPrivacyFeature: InternetPrivacyFeature by lazy {
+ @FlowPreview val internetPrivacyFeature: InternetPrivacyFeature by lazy {
InternetPrivacyFeature.create(
coroutineScope = viewModelScope,
ipScramblerModule = ipScramblerModule,
diff --git a/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
index 1b92cb2..c0bdcf0 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
@@ -25,7 +25,9 @@ import androidx.fragment.app.add
import androidx.fragment.app.commit
import foundation.e.privacycentralapp.R
import foundation.e.privacycentralapp.features.dashboard.DashboardFragment
+import kotlinx.coroutines.FlowPreview
+@FlowPreview
open class MainActivity : FragmentActivity(R.layout.activity_main) {
override fun onCreate(savedInstanceState: Bundle?) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 49b6c95..f63da8b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -44,6 +44,7 @@
<string name="ipscrambling_any_location">Random country</string>
<string name="ipscrambling_select_app">Apply this setting to all selected apps:</string>
<string name="ipscrambling_error_quickprivacy_disabled">Enabled Quick Privacy to use functionalities</string>
+ <string name="ipscrambling_warning_starting_long">Our scrambling IP service is taking time to launch. It can take a few minutes. Leaving the screen won\'t interrupt the process.</string>
<!-- Location -->