From ffbb686bd571185217c0e9e0fef0f164be9a07f7 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Tue, 1 Jun 2021 23:49:41 +0530 Subject: Add dummy tracker feature to trigger blocker system service --- app/build.gradle | 1 + app/libs/classes.jar | Bin 0 -> 429238 bytes app/src/main/AndroidManifest.xml | 1 + .../features/dashboard/DashboardFeature.kt | 6 +++ .../features/dashboard/DashboardFragment.kt | 9 ++++ .../features/trackers/TrackersFragment.kt | 58 +++++++++++++++++++++ app/src/main/res/layout/fragment_trackers.xml | 46 ++++++++++++++++ 7 files changed, 121 insertions(+) create mode 100644 app/libs/classes.jar create mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt create mode 100644 app/src/main/res/layout/fragment_trackers.xml (limited to 'app') diff --git a/app/build.gradle b/app/build.gradle index 24ec426..fe9e4d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -84,6 +84,7 @@ android { dependencies { compileOnly files('libs/e-ui-sdk-1.0.1-q.jar') + implementation files('libs/classes.jar') implementation project(":privacymodulesapi") // include the google specific version of the modules, just for the google flavor diff --git a/app/libs/classes.jar b/app/libs/classes.jar new file mode 100644 index 0000000..74032a0 Binary files /dev/null and b/app/libs/classes.jar differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7145af9..4babd46 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ + state Effect.OpenAppsPermissionsEffect -> state Effect.OpenInternetActivityPrivacyEffect -> state + Effect.OpenTrackersEffect -> state } }, actor = { _: State, action: Action -> @@ -185,6 +188,7 @@ class DashboardFeature( Action.ShowInternetActivityPrivacyAction -> flowOf( Effect.OpenInternetActivityPrivacyEffect ) + Action.ShowTrackers -> flowOf(Effect.OpenTrackersEffect) } }, singleEventProducer = { state, _, effect -> @@ -197,6 +201,8 @@ class DashboardFeature( SingleEvent.NavigateToInternetActivityPrivacySingleEvent else if (state is State.DashboardState && effect is Effect.OpenAppsPermissionsEffect) SingleEvent.NavigateToPermissionsSingleEvent + else if (state is State.DashboardState && effect is Effect.OpenTrackersEffect) + SingleEvent.NavigateToTrackersSingleEvent else null } ) 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 c57e6cc..e7ce353 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 @@ -38,6 +38,7 @@ import foundation.e.privacycentralapp.dummy.mapToString import foundation.e.privacycentralapp.features.internetprivacy.InternetPrivacyFragment import foundation.e.privacycentralapp.features.location.FakeLocationFragment import foundation.e.privacycentralapp.features.permissions.PermissionsFragment +import foundation.e.privacycentralapp.features.trackers.TrackersFragment import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect @@ -84,6 +85,11 @@ class DashboardFragment : } } DashboardFeature.SingleEvent.NavigateToTrackersSingleEvent -> { + requireActivity().supportFragmentManager.commit { + add(R.id.container) + setReorderingAllowed(true) + addToBackStack("dashboard") + } } } } @@ -110,6 +116,9 @@ class DashboardFragment : it.findViewById(R.id.apps_permissions).setOnClickListener { viewModel.submitAction(DashboardFeature.Action.ShowAppsPermissions) } + it.findViewById(R.id.am_i_tracked).setOnClickListener { + viewModel.submitAction(DashboardFeature.Action.ShowTrackers) + } } } 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 new file mode 100644 index 0000000..d4085b4 --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2021 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package foundation.e.privacycentralapp.features.trackers + +import android.content.Context +import android.os.Bundle +import android.view.View +import android.widget.Button +import android.widget.Toast +import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.NavToolbarFragment +import lineageos.blockers.BlockerInterface + +class TrackersFragment : + NavToolbarFragment(R.layout.fragment_trackers) { + + private lateinit var blockerService: BlockerInterface + + override fun onAttach(context: Context) { + super.onAttach(context) + blockerService = BlockerInterface.getInstance(context) + } + + private fun displayToast(message: String) { + Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT) + .show() + } + + override fun getTitle(): String { + return "Trackers" + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + bindClickListeners(view) + } + + private fun bindClickListeners(view: View) { + view.findViewById