summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt6
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt9
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt58
3 files changed, 73 insertions, 0 deletions
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()
+ }
+ }
+}