summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacquarg <guillaume.jacquart@hoodbrains.com>2021-11-12 11:34:57 +0100
committerjacquarg <guillaume.jacquart@hoodbrains.com>2021-11-12 11:51:59 +0100
commit2ea0e99f1bcec61e1a94bb7c35605fca49c53d1c (patch)
treecb4acda9ccb676dd60eb7ab95d3769ff7796622c
parent95f0c8fb06bd1aa57702f56f2c736e9718597080 (diff)
Integrate trackers module, small UI fixes
-rw-r--r--app/src/e/res/values/strings.xml2
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt8
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt23
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/IpScramblingStateUseCase.kt2
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt37
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt8
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt33
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt27
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt12
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFeature.kt15
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFeature.kt5
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt2
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt17
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt23
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt7
-rw-r--r--app/src/main/res/drawable/ic_disk.xml2
-rw-r--r--app/src/main/res/layout/apptrackers_fragment.xml19
-rw-r--r--app/src/main/res/layout/apptrackers_item_tracker_toggle.xml4
-rw-r--r--app/src/main/res/layout/fragment_dashboard.xml2
-rw-r--r--app/src/main/res/values/colors.xml3
-rw-r--r--app/src/main/res/values/strings.xml11
-rw-r--r--privapp-permissions-foundation.e.privacycentralapp.xml1
22 files changed, 186 insertions, 77 deletions
diff --git a/app/src/e/res/values/strings.xml b/app/src/e/res/values/strings.xml
index 73affbc..4c902eb 100644
--- a/app/src/e/res/values/strings.xml
+++ b/app/src/e/res/values/strings.xml
@@ -1,3 +1,3 @@
<resources>
- <string name="app_name">e - PrivacyModulesDemo</string>
+ <string name="app_name">PrivacyCentral</string>
</resources>
diff --git a/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt b/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt
index f36405d..b73a79d 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt
@@ -86,19 +86,19 @@ class DependencyContainer constructor(val app: Application) {
IpScramblingStateUseCase(ipScramblerModule, localStateRepository, GlobalScope)
}
private val appListUseCase by lazy {
- AppListUseCase(permissionsModule)
+ AppListUseCase(permissionsModule, GlobalScope)
}
private val trackersStatisticsUseCase by lazy {
- TrackersStatisticsUseCase(trackersPrivacyMock)
+ TrackersStatisticsUseCase(trackTrackersPrivacyModule)
}
private val trackersStateUseCase by lazy {
- TrackersStateUseCase(trackersPrivacyMock, trackersPrivacyMock, permissionsModule)
+ TrackersStateUseCase(blockTrackersPrivacyModule, trackTrackersPrivacyModule, permissionsModule, localStateRepository, GlobalScope)
}
// ViewModelFactories
val dashBoardViewModelFactory by lazy {
- DashBoardViewModelFactory(getQuickPrivacyStateUseCase, ipScramblingStateUseCase, trackersStatisticsUseCase)
+ DashBoardViewModelFactory(getQuickPrivacyStateUseCase, ipScramblingStateUseCase, trackersStatisticsUseCase, trackersStateUseCase)
}
val fakeLocationViewModelFactory by lazy {
diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt
index 8ce08a3..4d0ece2 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/AppListUseCase.kt
@@ -20,12 +20,31 @@ package foundation.e.privacycentralapp.domain.usecases
import android.Manifest
import foundation.e.privacymodules.permissions.PermissionsPrivacyModule
import foundation.e.privacymodules.permissions.data.ApplicationDescription
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.launch
class AppListUseCase(
- private val permissionsModule: PermissionsPrivacyModule
+ private val permissionsModule: PermissionsPrivacyModule,
+ private val corouteineScope: CoroutineScope
) {
- fun getAppsUsingInternet(): List<ApplicationDescription> {
+ private val _appsUsingInternet = MutableStateFlow<List<ApplicationDescription>>(emptyList())
+ init {
+ corouteineScope.launch {
+ _appsUsingInternet.value = getAppsUsingInternetList()
+ }
+ }
+
+ fun getAppsUsingInternet(): Flow<List<ApplicationDescription>> {
+ corouteineScope.launch {
+ _appsUsingInternet.value = getAppsUsingInternetList()
+ }
+ return _appsUsingInternet
+ }
+
+ private fun getAppsUsingInternetList(): List<ApplicationDescription> {
return permissionsModule.getInstalledApplications()
.filter {
permissionsModule.getPermissions(it.packageName)
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 3db5674..f8badcf 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
@@ -34,7 +34,7 @@ import kotlinx.coroutines.launch
class IpScramblingStateUseCase(
private val ipScramblerModule: IIpScramblerModule,
private val localStateRepository: LocalStateRepository,
- private val coroutineScope: CoroutineScope
+ coroutineScope: CoroutineScope
) {
// private val internetPrivacyModeMutableFlow = MutableStateFlow(InternetPrivacyMode.REAL_IP)
diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt
index cabe6a1..51bdc35 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt
@@ -17,17 +17,50 @@
package foundation.e.privacycentralapp.domain.usecases
+import foundation.e.privacycentralapp.data.repositories.LocalStateRepository
import foundation.e.privacymodules.permissions.PermissionsPrivacyModule
import foundation.e.privacymodules.permissions.data.ApplicationDescription
import foundation.e.privacymodules.trackers.IBlockTrackersPrivacyModule
import foundation.e.privacymodules.trackers.ITrackTrackersPrivacyModule
import foundation.e.privacymodules.trackers.Tracker
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.launch
class TrackersStateUseCase(
private val blockTrackersPrivacyModule: IBlockTrackersPrivacyModule,
private val trackersPrivacyModule: ITrackTrackersPrivacyModule,
- private val permissionsPrivacyModule: PermissionsPrivacyModule
+ private val permissionsPrivacyModule: PermissionsPrivacyModule,
+ private val localStateRepository: LocalStateRepository,
+ coroutineScope: CoroutineScope
) {
+
+ private val _areAllTrackersBlocked = MutableStateFlow(
+ blockTrackersPrivacyModule.isBlockingEnabled() &&
+ blockTrackersPrivacyModule.isWhiteListEmpty()
+ )
+ val areAllTrackersBlocked: StateFlow<Boolean> = _areAllTrackersBlocked
+
+ init {
+ coroutineScope.launch {
+ localStateRepository.quickPrivacyEnabledFlow.collect { enabled ->
+ if (enabled) {
+ blockTrackersPrivacyModule.enableBlocking()
+ } else {
+ blockTrackersPrivacyModule.disableBlocking()
+ }
+ updateAllTrackersBlockedState()
+ }
+ }
+ }
+
+ private fun updateAllTrackersBlockedState() {
+ _areAllTrackersBlocked.value = blockTrackersPrivacyModule.isBlockingEnabled() &&
+ blockTrackersPrivacyModule.isWhiteListEmpty()
+ }
+
fun getApplicationPermission(packageName: String): ApplicationDescription {
return permissionsPrivacyModule.getApplicationDescription(packageName)
}
@@ -46,9 +79,11 @@ class TrackersStateUseCase(
fun toggleAppWhitelist(appUid: Int, isWhitelisted: Boolean) {
blockTrackersPrivacyModule.setWhiteListed(appUid, isWhitelisted)
+ updateAllTrackersBlockedState()
}
fun blockTracker(appUid: Int, tracker: Tracker, isBlocked: Boolean) {
blockTrackersPrivacyModule.setWhiteListed(tracker, appUid, !isBlocked)
+ updateAllTrackersBlockedState()
}
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt
index dc0b92b..ae820f1 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt
@@ -42,4 +42,12 @@ class TrackersStatisticsUseCase(
trackTrackersPrivacyModule.getPastYearTrackersCount()
)
}
+
+ fun getPastDayTrackersCount(): Int {
+ return trackTrackersPrivacyModule.getPastDayTrackersCount()
+ }
+
+ fun getTrackersCount(): Int {
+ return trackTrackersPrivacyModule.getTrackersCount()
+ }
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt
index a6ac87a..5185737 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt
@@ -26,6 +26,7 @@ import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode
import foundation.e.privacycentralapp.domain.entities.LocationMode
import foundation.e.privacycentralapp.domain.usecases.GetQuickPrivacyStateUseCase
import foundation.e.privacycentralapp.domain.usecases.IpScramblingStateUseCase
+import foundation.e.privacycentralapp.domain.usecases.TrackersStateUseCase
import foundation.e.privacycentralapp.domain.usecases.TrackersStatisticsUseCase
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.flow
@@ -55,7 +56,7 @@ class DashboardFeature(
val totalGraph: Int? = null,
// val graphData
val trackersCount: Int? = null,
- val activeTrackersCount: Int? = null,
+ val dayTrackersCount: Int? = null,
val dayStatistics: List<Int>? = null
)
@@ -84,7 +85,12 @@ class DashboardFeature(
object NoEffect : Effect()
data class UpdateStateEffect(val isEnabled: Boolean) : Effect()
data class IpScramblingModeUpdatedEffect(val mode: InternetPrivacyMode) : Effect()
- data class TrackersStatisticsUpdatedEffect(val dayStatistics: List<Int>) : Effect()
+ data class TrackersStatisticsUpdatedEffect(
+ val dayStatistics: List<Int>,
+ val dayTrackersCount: Int,
+ val trackersCount: Int
+ ) : Effect()
+ data class TrackersBlockedUpdatedEffect(val areAllTrackersBlocked: Boolean) : Effect()
object OpenQuickPrivacyProtectionEffect : Effect()
data class OpenDashboardEffect(
@@ -115,7 +121,8 @@ class DashboardFeature(
coroutineScope: CoroutineScope,
getPrivacyStateUseCase: GetQuickPrivacyStateUseCase,
ipScramblingStateUseCase: IpScramblingStateUseCase,
- trackersStatisticsUseCase: TrackersStatisticsUseCase
+ trackersStatisticsUseCase: TrackersStatisticsUseCase,
+ trackersStateUseCase: TrackersStateUseCase
): DashboardFeature =
DashboardFeature(
initialState = State(),
@@ -124,8 +131,15 @@ class DashboardFeature(
when (effect) {
is Effect.UpdateStateEffect -> state.copy(isQuickPrivacyEnabled = effect.isEnabled)
is Effect.IpScramblingModeUpdatedEffect -> state.copy(internetPrivacyMode = effect.mode)
- is Effect.TrackersStatisticsUpdatedEffect -> state.copy(dayStatistics = effect.dayStatistics)
+ is Effect.TrackersStatisticsUpdatedEffect -> state.copy(
+ dayStatistics = effect.dayStatistics,
+ dayTrackersCount = effect.dayTrackersCount,
+ trackersCount = effect.trackersCount
+ )
+ is Effect.TrackersBlockedUpdatedEffect -> state.copy(
+ isAllTrackersBlocked = effect.areAllTrackersBlocked
+ )
/*is Effect.OpenDashboardEffect -> State.DashboardState(
effect.trackersCount,
effect.activeTrackersCount,
@@ -190,7 +204,16 @@ class DashboardFeature(
Effect.IpScramblingModeUpdatedEffect(it)
},
flow {
- emit(Effect.TrackersStatisticsUpdatedEffect(trackersStatisticsUseCase.getPastDayTrackersCalls()))
+ emit(
+ Effect.TrackersStatisticsUpdatedEffect(
+ dayStatistics = trackersStatisticsUseCase.getPastDayTrackersCalls(),
+ dayTrackersCount = trackersStatisticsUseCase.getPastDayTrackersCount(),
+ trackersCount = trackersStatisticsUseCase.getTrackersCount()
+ )
+ )
+ },
+ trackersStateUseCase.areAllTrackersBlocked.map {
+ Effect.TrackersBlockedUpdatedEffect(it)
}
)
/*
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 1b4ad39..248e358 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
@@ -209,7 +209,7 @@ class DashboardFragment :
it.mapIndexed { index, value -> BarEntry(index.toFloat(), value.toFloat()) },
getString(R.string.dashboard_graph_trackers_legend)
).apply {
- color = getColor(requireContext(), R.color.purple_chart)
+ color = getColor(requireContext(), R.color.e_blue2)
setDrawValues(false)
}
@@ -217,24 +217,15 @@ class DashboardFragment :
binding.graph.invalidate()
}
- state.trackersCount?.let {
- binding.graphLegend.text = getString(R.string.dashboard_graph_trackers_legend, it)
- }
+ binding.graphLegend.text = getString(R.string.dashboard_graph_trackers_legend, state.trackersCount?.toString() ?: "No")
- // binding.graphTotal.text = if (state == DashboardFeature.State.LoadingState) {
- // ""
- // } else {
- // val value = if (state is DashboardFeature.State.EnabledState) state.totalGraph
- // else if (state is DashboardFeature.State.DisabledState) state.totalGraph
- // else 0 // dummy
- // getString(R.string.dashboard_graph_total, value)
- // }
-
- state.activeTrackersCount?.let {
- binding.amITracked.subtitle.text = getString(R.string.dashboard_am_i_tracked_subtitle, 77, it)
+ if (state.dayTrackersCount != null && state.trackersCount != null) {
+ binding.amITracked.subTitle = getString(R.string.dashboard_am_i_tracked_subtitle, state.trackersCount, state.dayTrackersCount)
+ } else {
+ binding.amITracked.subTitle = getString(R.string.trackers_title)
}
- binding.myLocation.subtitle.text = getString(
+ binding.myLocation.subTitle = getString(
if (state.isQuickPrivacyEnabled &&
state.locationMode != LocationMode.REAL_LOCATION
)
@@ -242,13 +233,15 @@ class DashboardFragment :
else R.string.dashboard_location_subtitle_off
)
- binding.internetActivityPrivacy.subtitle.text = getString(
+ binding.internetActivityPrivacy.subTitle = getString(
if (state.isQuickPrivacyEnabled &&
state.internetPrivacyMode != InternetPrivacyMode.REAL_IP
)
R.string.dashboard_internet_activity_privacy_subtitle_on
else R.string.dashboard_internet_activity_privacy_subtitle_off
)
+
+ binding.executePendingBindings()
}
override fun actions(): Flow<DashboardFeature.Action> = viewModel.actions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt
index fa24b1d..4bf01d7 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt
@@ -22,6 +22,7 @@ import androidx.lifecycle.viewModelScope
import foundation.e.privacycentralapp.common.Factory
import foundation.e.privacycentralapp.domain.usecases.GetQuickPrivacyStateUseCase
import foundation.e.privacycentralapp.domain.usecases.IpScramblingStateUseCase
+import foundation.e.privacycentralapp.domain.usecases.TrackersStateUseCase
import foundation.e.privacycentralapp.domain.usecases.TrackersStatisticsUseCase
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
@@ -30,7 +31,8 @@ import kotlinx.coroutines.launch
class DashboardViewModel(
private val getPrivacyStateUseCase: GetQuickPrivacyStateUseCase,
private val ipScramblingStateUseCase: IpScramblingStateUseCase,
- private val trackersStatisticsUseCase: TrackersStatisticsUseCase
+ private val trackersStatisticsUseCase: TrackersStatisticsUseCase,
+ private val trackersStateUseCase: TrackersStateUseCase
) : ViewModel() {
private val _actions = MutableSharedFlow<DashboardFeature.Action>()
@@ -41,7 +43,8 @@ class DashboardViewModel(
coroutineScope = viewModelScope,
getPrivacyStateUseCase = getPrivacyStateUseCase,
ipScramblingStateUseCase = ipScramblingStateUseCase,
- trackersStatisticsUseCase = trackersStatisticsUseCase
+ trackersStatisticsUseCase = trackersStatisticsUseCase,
+ trackersStateUseCase = trackersStateUseCase
)
}
@@ -55,9 +58,10 @@ class DashboardViewModel(
class DashBoardViewModelFactory(
private val getPrivacyStateUseCase: GetQuickPrivacyStateUseCase,
private val ipScramblingStateUseCase: IpScramblingStateUseCase,
- private val trackersStatisticsUseCase: TrackersStatisticsUseCase
+ private val trackersStatisticsUseCase: TrackersStatisticsUseCase,
+ private val trackersStateUseCase: TrackersStateUseCase
) : Factory<DashboardViewModel> {
override fun create(): DashboardViewModel {
- return DashboardViewModel(getPrivacyStateUseCase, ipScramblingStateUseCase, trackersStatisticsUseCase)
+ return DashboardViewModel(getPrivacyStateUseCase, ipScramblingStateUseCase, trackersStatisticsUseCase, trackersStateUseCase)
}
}
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 f7145d1..e0eb12c 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
@@ -136,19 +136,16 @@ class InternetPrivacyFeature(
when {
action is Action.LoadInternetModeAction -> merge(
getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map { Effect.QuickPrivacyUpdatedEffect(it) },
- flowOf(Effect.QuickPrivacyUpdatedEffect(true)),
ipScramblingStateUseCase.internetPrivacyMode.map { Effect.ModeUpdatedEffect(it) }.shareIn(scope = coroutineScope, started = SharingStarted.Lazily, replay = 0),
flowOf(Effect.ModeUpdatedEffect(InternetPrivacyMode.REAL_IP)),
- flow {
- val apps = appListUseCase.getAppsUsingInternet()
+ appListUseCase.getAppsUsingInternet().map { apps ->
if (ipScramblerModule.appList.isEmpty()) {
- ipScramblerModule.appList = apps.map { it.packageName }.toMutableSet()
+ ipScramblerModule.appList =
+ apps.map { it.packageName }.toMutableSet()
}
- emit(
- Effect.AvailableAppsListEffect(
- apps,
- ipScramblerModule.appList
- )
+ Effect.AvailableAppsListEffect(
+ apps,
+ ipScramblerModule.appList
)
},
flow {
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 0120fae..5d20e7c 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
@@ -152,9 +152,8 @@ class TrackersFeature(
)
)
},
- flow {
- val apps = appListUseCase.getAppsUsingInternet()
- emit(Effect.AvailableAppsListEffect(apps))
+ appListUseCase.getAppsUsingInternet().map { apps ->
+ Effect.AvailableAppsListEffect(apps)
}
)
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
index a259f0b..25f6d59 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
@@ -144,7 +144,7 @@ class TrackersFragment :
data.mapIndexed { index, value -> BarEntry(index.toFloat(), value.toFloat()) },
getString(R.string.trackers_count_label)
).apply {
- color = ContextCompat.getColor(requireContext(), R.color.purple_chart)
+ color = ContextCompat.getColor(requireContext(), R.color.e_blue2)
setDrawValues(false)
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt
index 508aa5a..1c3144d 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt
@@ -110,15 +110,24 @@ class AppTrackersFragment :
}
}
- override fun render(state: AppTrackersFeature.State) {
- // binding.blockAllToggle.isChecked = state.isBlockingActivated
+ override fun render(state: State) {
+ binding.blockAllToggle.isChecked = state.isBlockingActivated
- state.getTrackersStatus()?.let {
+ val trackersStatus = state.getTrackersStatus()
+ if (!trackersStatus.isNullOrEmpty()) {
binding.trackers.isVisible = true
binding.trackers.post {
- (binding.trackers.adapter as ToggleTrackersAdapter?)?.dataSet = it
+ (binding.trackers.adapter as ToggleTrackersAdapter?)?.updateDataSet(trackersStatus, state.isBlockingActivated)
}
binding.noTrackersYet.isVisible = false
+ } else {
+ binding.trackers.isVisible = false
+ binding.noTrackersYet.isVisible = true
+ binding.noTrackersYet.text = getString(
+ if (state.isBlockingActivated)
+ R.string.apptrackers_no_trackers_yet_block_on
+ else R.string.apptrackers_no_trackers_yet_block_off
+ )
}
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt
index f23ebf5..b1b3ed6 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt
@@ -20,8 +20,8 @@ package foundation.e.privacycentralapp.features.trackers.apptrackers
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Switch
import android.widget.TextView
-import androidx.appcompat.widget.SwitchCompat
import androidx.recyclerview.widget.RecyclerView
import foundation.e.privacycentralapp.R
import foundation.e.privacymodules.trackers.Tracker
@@ -32,22 +32,27 @@ class ToggleTrackersAdapter(
) :
RecyclerView.Adapter<ToggleTrackersAdapter.ViewHolder>() {
+ var isEnabled = true
+
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val title: TextView = view.findViewById(R.id.title)
- val toggle: SwitchCompat = view.findViewById(R.id.toggle)
+ val toggle: Switch = view.findViewById(R.id.toggle)
- fun bind(item: Pair<Tracker, Boolean>) {
+ fun bind(item: Pair<Tracker, Boolean>, isEnabled: Boolean) {
title.text = item.first.label
toggle.isChecked = item.second
+ toggle.isEnabled = isEnabled
}
}
- var dataSet: List<Pair<Tracker, Boolean>> = emptyList()
- set(value) {
- field = value
- notifyDataSetChanged()
- }
+ private var dataSet: List<Pair<Tracker, Boolean>> = emptyList()
+
+ fun updateDataSet(new: List<Pair<Tracker, Boolean>>, isEnabled: Boolean) {
+ this.isEnabled = isEnabled
+ dataSet = new
+ notifyDataSetChanged()
+ }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
@@ -61,7 +66,7 @@ class ToggleTrackersAdapter(
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/main/MainActivity.kt b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
index 1b92cb2..03784a0 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
@@ -23,8 +23,11 @@ import android.os.Bundle
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.add
import androidx.fragment.app.commit
+import dnsfilter.android.AndroidEnvironment
import foundation.e.privacycentralapp.R
import foundation.e.privacycentralapp.features.dashboard.DashboardFragment
+import foundation.e.trackerfilter.DNSBlockerService
+import foundation.e.trackerfilter.StatsIntentService
open class MainActivity : FragmentActivity(R.layout.activity_main) {
@@ -46,6 +49,10 @@ open class MainActivity : FragmentActivity(R.layout.activity_main) {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
+
+ AndroidEnvironment.initEnvironment(this)
+ startService(Intent(this, DNSBlockerService::class.java))
+ startService(Intent(this, StatsIntentService::class.java))
}
open fun handleIntent(intent: Intent) {}
diff --git a/app/src/main/res/drawable/ic_disk.xml b/app/src/main/res/drawable/ic_disk.xml
index 92200b1..2600601 100644
--- a/app/src/main/res/drawable/ic_disk.xml
+++ b/app/src/main/res/drawable/ic_disk.xml
@@ -17,5 +17,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
- <solid android:color="@color/purple_chart" />
+ <solid android:color="@color/e_blue2" />
</shape> \ No newline at end of file
diff --git a/app/src/main/res/layout/apptrackers_fragment.xml b/app/src/main/res/layout/apptrackers_fragment.xml
index 1f3063d..f037beb 100644
--- a/app/src/main/res/layout/apptrackers_fragment.xml
+++ b/app/src/main/res/layout/apptrackers_fragment.xml
@@ -32,6 +32,7 @@
<androidx.core.widget.NestedScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
+ android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
@@ -40,10 +41,11 @@
android:layout_width="match_parent"
android:orientation="vertical"
>
- <!--LinearLayout
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
+ android:padding="16dp"
android:gravity="center_vertical">
<TextView
android:layout_width="0dp"
@@ -51,14 +53,19 @@
android:layout_weight="1"
android:text="@string/apptrackers_block_all_toggle"
/>
- <androidx.appcompat.widget.SwitchCompat
+ <Switch
android:id="@+id/block_all_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
- </LinearLayout-->
+ </LinearLayout>
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@color/grey_divider"
+ />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/trackers"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginBottom="32dp"
tools:listitem="@layout/apptrackers_item_tracker_toggle"
@@ -66,9 +73,11 @@
/>
<TextView
android:id="@+id/no_trackers_yet"
+ android:padding="32dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:text="@string/apptrackers_no_trackers_yet"
+ android:gravity="center"
+ tools:text="@string/apptrackers_no_trackers_yet_block_off"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
diff --git a/app/src/main/res/layout/apptrackers_item_tracker_toggle.xml b/app/src/main/res/layout/apptrackers_item_tracker_toggle.xml
index 22678ce..baab3d9 100644
--- a/app/src/main/res/layout/apptrackers_item_tracker_toggle.xml
+++ b/app/src/main/res/layout/apptrackers_item_tracker_toggle.xml
@@ -17,16 +17,14 @@
android:layout_weight="1"
android:maxLines="1"
android:ellipsize="end"
- android:layout_marginStart="16dp"
android:textSize="14sp"
tools:text="Body sensor"
/>
- <androidx.appcompat.widget.SwitchCompat
+ <Switch
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="24dp"
- android:layoutDirection="rtl"
android:checked="true"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml
index 6976948..c93b985 100644
--- a/app/src/main/res/layout/fragment_dashboard.xml
+++ b/app/src/main/res/layout/fragment_dashboard.xml
@@ -213,7 +213,7 @@ android:text="@string/dashboard_state_ipaddress_off"
android:layout_height="88dp"
app:icon="@{@drawable/ic_tracked}"
app:title="@{@string/dashboard_am_i_tracked_title}"
- app:subTitle='@{""}'
+ app:subTitle='@{@string/trackers_title}'
/>
<View
android:layout_width="match_parent"
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 935d0a7..85f0c70 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -21,5 +21,6 @@
<color name="green_on">#169659</color>
<color name="green_valid">#2CC766</color>
- <color name="purple_chart">#855CF8</color>
+
+ <color name="e_blue2">@lineageos.platform:color/color_default_blue2</color>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 17d5e12..cce1107 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -17,7 +17,7 @@
<string name="dashboard_state_ipaddress_on">Hidden</string>
<string name="dashboard_graph_label">Personal data leakage</string>
<string name="dashboard_graph_period">Last 24 hours</string>
- <string name="dashboard_graph_trackers_legend">%d Trackers</string>
+ <string name="dashboard_graph_trackers_legend">%s Trackers</string>
<string name="dashboard_am_i_tracked_title">Am I tracked?</string>
<string name="dashboard_am_i_tracked_subtitle">%1$d app trackers, %2$d active trackers</string>
@@ -53,17 +53,18 @@
<string name="location_input_error">Invalid coordinates</string>
<!-- Trackers -->
- <string name="trackers_title">Manage and block</string>
+ <string name="trackers_title">Manage trackers</string>
<string name="trackers_info">See tracker usage and which trackers are present in your apps.</string>
<string name="trackers_count_label">%d trackers</string>
<string name="trackers_period_day">24 hours</string>
<string name="trackers_period_month">past month</string>
<string name="trackers_period_year">past year</string>
- <string name="trackers_applist_title">Block trackers on each app</string>
+ <string name="trackers_applist_title">Allow or deny trackers in apps</string>
<!-- App Trackers -->
- <!--string name="apptrackers_block_all_toggle">Activate trackers blocking : </string-->
- <string name="apptrackers_no_trackers_yet">Trackers will appear as they are they start tracking you.</string>
+ <string name="apptrackers_block_all_toggle">Block trackers</string>
+ <string name="apptrackers_no_trackers_yet_block_off">No trackers were detected yet. If new trackers are detected they will be updated here.</string>
+ <string name="apptrackers_no_trackers_yet_block_on">No trackers were detected yet. All future trackers will be blocked.</string>
<!-- -->
<string name="quick_protection_info">Quick protection enables these settings when turned on</string>
diff --git a/privapp-permissions-foundation.e.privacycentralapp.xml b/privapp-permissions-foundation.e.privacycentralapp.xml
index 1b3e760..48c934b 100644
--- a/privapp-permissions-foundation.e.privacycentralapp.xml
+++ b/privapp-permissions-foundation.e.privacycentralapp.xml
@@ -5,5 +5,6 @@
<permission name="android.permission.WATCH_APPOPS" />
<permission name="android.permission.GET_APP_OPS_STATS" />
<permission name="android.permission.WRITE_SECURE_SETTINGS" />
+ <permission name="android.permission.CONTROL_VPN" />
</privapp-permissions>
</permissions> \ No newline at end of file