diff options
author | Amit Kumar <amitkma@e.email> | 2021-06-01 23:49:41 +0530 |
---|---|---|
committer | Amit Kumar <amitkma@e.email> | 2021-06-01 23:49:41 +0530 |
commit | ffbb686bd571185217c0e9e0fef0f164be9a07f7 (patch) | |
tree | 85136dd6890b682ea82205483fc3b40addadb6cd /app | |
parent | 97b51f18dcc2f87a9cdd7f482033e30a6282d853 (diff) |
Add dummy tracker feature to trigger blocker system service
Diffstat (limited to 'app')
-rw-r--r-- | app/build.gradle | 1 | ||||
-rw-r--r-- | app/libs/classes.jar | bin | 0 -> 429238 bytes | |||
-rw-r--r-- | app/src/main/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt | 6 | ||||
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt | 9 | ||||
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt | 58 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_trackers.xml | 46 |
7 files changed, 121 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..74032a0 --- /dev/null +++ b/app/libs/classes.jar 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 @@ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" tools:ignore="ProtectedPermissions" /> + <uses-permission android:name="lineageos.permission.ACCESS_BLOCKER" /> <application android:name=".PrivacyCentralApplication" 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 5a20489..dc02c91 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 @@ -76,6 +76,7 @@ class DashboardFeature( object ShowFakeMyLocationAction : Action() object ShowInternetActivityPrivacyAction : Action() object ShowAppsPermissions : Action() + object ShowTrackers : Action() } sealed class Effect { @@ -98,6 +99,7 @@ class DashboardFeature( object OpenFakeMyLocationEffect : Effect() object OpenInternetActivityPrivacyEffect : Effect() object OpenAppsPermissionsEffect : Effect() + object OpenTrackersEffect : Effect() } companion object { @@ -144,6 +146,7 @@ class DashboardFeature( Effect.OpenFakeMyLocationEffect -> 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<TrackersFragment>(R.id.container) + setReorderingAllowed(true) + addToBackStack("dashboard") + } } } } @@ -110,6 +116,9 @@ class DashboardFragment : it.findViewById<RelativeLayout>(R.id.apps_permissions).setOnClickListener { viewModel.submitAction(DashboardFeature.Action.ShowAppsPermissions) } + it.findViewById<RelativeLayout>(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 <https://www.gnu.org/licenses/>. + */ + +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<Button>(R.id.triggerBlockerService).setOnClickListener { + blockerService.runTest() + } + } +} diff --git a/app/src/main/res/layout/fragment_trackers.xml b/app/src/main/res/layout/fragment_trackers.xml new file mode 100644 index 0000000..e11f4cc --- /dev/null +++ b/app/src/main/res/layout/fragment_trackers.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/white" + > + + <include layout="@layout/topbar"/> + + <androidx.core.widget.NestedScrollView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginBottom="32dp" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:paddingLeft="32dp" + android:paddingRight="32dp" + tools:context=".main.MainActivity" + > + + <TextView + android:id="@+id/internet_activity_privacy_info" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:paddingTop="16dp" + android:text="@string/internet_activity_privacy_info" + android:textColor="@color/black" + android:textSize="14sp" + /> + + <Button android:id="@+id/triggerBlockerService" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:text="Trigger Blocker"/> + /> + </LinearLayout> + </androidx.core.widget.NestedScrollView> +</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file |