diff options
Diffstat (limited to 'app/src/main/java')
14 files changed, 159 insertions, 60 deletions
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) {} |