summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation
diff options
context:
space:
mode:
authorGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2022-03-03 18:39:23 +0000
committerGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2022-03-03 18:39:23 +0000
commitf151a29d166ef7339fef50d9843cac0b352670b2 (patch)
tree64f3b8265b1e65c087586ab9cd062878b0bccddf /app/src/main/java/foundation
parentf1b8450b8ebcdfe44ccdcc843d1b2d83d0401655 (diff)
parent1ded1d534ca867daf0896e6419cb7de9a37bb446 (diff)
Merge branch 'wording_updates' into 'main'
Wording updates See merge request e/privacy-central/privacycentralapp!22
Diffstat (limited to 'app/src/main/java/foundation')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt4
-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
5 files changed, 27 insertions, 6 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..db9dcce 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> {
@@ -213,7 +215,7 @@ class DashboardFragment :
if (state.activeTrackersCount != null && state.trackersCount != null) {
binding.amITracked.subTitle = getString(R.string.dashboard_am_i_tracked_subtitle, state.trackersCount, state.activeTrackersCount)
} else {
- binding.amITracked.subTitle = getString(R.string.trackers_title)
+ binding.amITracked.subTitle = ""
}
binding.myLocation.subTitle = getString(
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?) {