Loading app/src/main/java/foundation/e/advancedprivacy/features/debug/DebugWeeklyReportFragment.kt +147 −1 Original line number Diff line number Diff line Loading @@ -30,21 +30,29 @@ import androidx.recyclerview.widget.RecyclerView import foundation.e.advancedprivacy.R import foundation.e.advancedprivacy.common.BindingListAdapter import foundation.e.advancedprivacy.common.BindingViewHolder import foundation.e.advancedprivacy.data.repositories.AppListRepository import foundation.e.advancedprivacy.databinding.DebugWeeklyReportFragmentBinding import foundation.e.advancedprivacy.databinding.DebugWeeklyReportItemBinding import foundation.e.advancedprivacy.domain.entities.weeklyreport.DisplayableReport import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReport import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReportScore import foundation.e.advancedprivacy.domain.usecases.WeeklyReportUseCase import foundation.e.advancedprivacy.features.weeklyreport.WeeklyReportViewFactory import foundation.e.advancedprivacy.trackers.data.TrackersRepository import java.time.Instant import kotlin.random.Random import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.koin.android.ext.android.inject class DebugWeeklyReportFragment : Fragment(R.layout.debug_weekly_report_fragment) { private val weeklyReportUseCase: WeeklyReportUseCase by inject() private val appListRepository: AppListRepository by inject() private val trackersRepository: TrackersRepository by inject() private val reportsFactory: WeeklyReportViewFactory by inject() private lateinit var binding: DebugWeeklyReportFragmentBinding private val reportsFactory: WeeklyReportViewFactory by inject() private val weeklyReportsAdapter = object : BindingListAdapter< DebugWeeklyReportItemBinding, Pair<DisplayableReport?, List<WeeklyReportScore>> Loading Loading @@ -109,6 +117,12 @@ class DebugWeeklyReportFragment : Fragment(R.layout.debug_weekly_report_fragment } } } binding.showAllReportsViews.setOnClickListener { weeklyReportsAdapter.dataSet = buildFakeReports().map { it to emptyList() } } } private fun setupRecyclerView(recyclerView: RecyclerView) { Loading @@ -118,4 +132,136 @@ class DebugWeeklyReportFragment : Fragment(R.layout.debug_weekly_report_fragment isNestedScrollingEnabled = false } } private fun buildFakeReports(): List<DisplayableReport> { val reports = mutableListOf<DisplayableReport>() val timestamp = Instant.now() // Call Per App val anyApp = appListRepository.displayableApps.value.first() val callsPerWeek = Random.nextInt(10000) val hoursInWeek = 7 * 24 reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_PER_APP, WeeklyReport.LabelId.CALLS_PER_APP_1, anyApp.id, listOf((callsPerWeek / hoursInWeek).toString()) ), anyApp ) ) reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_PER_APP, WeeklyReport.LabelId.CALLS_PER_APP_2, anyApp.id, listOf((callsPerWeek / hoursInWeek).toString()) ), anyApp ) ) reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_PER_APP, WeeklyReport.LabelId.CALLS_PER_APP_3, anyApp.id, listOf((callsPerWeek / 7).toString()) ), anyApp ) ) // New Trackers val anyApp2 = appListRepository.displayableApps.value.first() reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.NEW_TRACKER, WeeklyReport.LabelId.NEW_TRACKER_1, anyApp2.id, emptyList() ), anyApp2 ) ) reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.NEW_TRACKER, WeeklyReport.LabelId.NEW_TRACKER_2, "", listOf(Random.nextInt(4).toString()) ) ) ) reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.NEW_TRACKER, WeeklyReport.LabelId.NEW_TRACKER_3, "", listOf(Random.nextInt(4).toString()) ) ) ) // Calls and Leaks val blockedRate = Random.nextInt(100).toString() val leaks = Random.nextInt(1000).toString() reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_AND_LEAKS, WeeklyReport.LabelId.CALLS_AND_LEAKS_1, blockedRate, listOf(leaks) ) ) ) reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_AND_LEAKS, WeeklyReport.LabelId.CALLS_AND_LEAKS_2, blockedRate, listOf(leaks) ) ) ) // Tracker With Most Apps trackersRepository.getTracker("wtm_yahoo")?.let { tracker -> reports.add( DisplayableReport.ReportWithTracker( WeeklyReport( timestamp, WeeklyReport.StatType.TRACKER_WITH_MOST_APPS, WeeklyReport.LabelId.TRACKER_WITH_MOST_APPS_1, tracker.id, listOf(Random.nextInt(20).toString()) ), tracker ) ) } return reports } } app/src/main/res/layout/debug_weekly_report_fragment.xml +7 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,13 @@ android:text="10" /> </LinearLayout> <androidx.appcompat.widget.AppCompatButton android:id="@+id/show_all_reports_views" android:layout_width="wrap_content" android:layout_height="48dp" android:layout_margin="4dp" android:text="@string/debug_weeklyreport_show_reports_views" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/reports" Loading app/src/main/res/values/debug_strings.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright (C) 2025 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/>. --> <resources> <string name="debug_activity_title" translatable="false">AdvancedPrivacy debug tools</string> <string name="debug_weekly_report_title" translatable="false">Weekly Report debug tools</string> <string name="debug_weekly_report_update_report" translatable="false">Update report</string> <string name="debug_weekly_report_generate_reports" translatable="false">Generate report of week ago:</string> <string name="debug_weekly_report_item_share" translatable="false">Share</string> <string name="debug_weekly_report_item_details" translatable="false">Details</string> <string name="debug_weekly_report_item_notification" translatable="false">Notification</string> <string name="debug_weeklyreport_show_reports_views" translatable="false">Show all reports views</string> </resources> No newline at end of file app/src/main/res/values/strings.xml +0 −11 Original line number Diff line number Diff line Loading @@ -217,15 +217,4 @@ <string name="notifications_tracker_channel_description">Highlight that the trackers are actually logged and blocked by Advanced Privacy</string> <string name="notifications_tracker_title">Tracker control is on</string> <string name="notifications_tracker_content">This could impact the functioning of some applications.</string> <!-- DEBUG --> <string name="debug_activity_title" translatable="false">AdvancedPrivacy debug tools</string> <string name="debug_weekly_report_title" translatable="false">Weekly Report debug tools</string> <string name="debug_weekly_report_update_report" translatable="false">Update report</string> <string name="debug_weekly_report_generate_reports" translatable="false">Generate report of week ago:</string> <string name="debug_weekly_report_item_share" translatable="false">Share</string> <string name="debug_weekly_report_item_details" translatable="false">Details</string> <string name="debug_weekly_report_item_notification" translatable="false">Notification</string> </resources> Loading
app/src/main/java/foundation/e/advancedprivacy/features/debug/DebugWeeklyReportFragment.kt +147 −1 Original line number Diff line number Diff line Loading @@ -30,21 +30,29 @@ import androidx.recyclerview.widget.RecyclerView import foundation.e.advancedprivacy.R import foundation.e.advancedprivacy.common.BindingListAdapter import foundation.e.advancedprivacy.common.BindingViewHolder import foundation.e.advancedprivacy.data.repositories.AppListRepository import foundation.e.advancedprivacy.databinding.DebugWeeklyReportFragmentBinding import foundation.e.advancedprivacy.databinding.DebugWeeklyReportItemBinding import foundation.e.advancedprivacy.domain.entities.weeklyreport.DisplayableReport import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReport import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReportScore import foundation.e.advancedprivacy.domain.usecases.WeeklyReportUseCase import foundation.e.advancedprivacy.features.weeklyreport.WeeklyReportViewFactory import foundation.e.advancedprivacy.trackers.data.TrackersRepository import java.time.Instant import kotlin.random.Random import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.koin.android.ext.android.inject class DebugWeeklyReportFragment : Fragment(R.layout.debug_weekly_report_fragment) { private val weeklyReportUseCase: WeeklyReportUseCase by inject() private val appListRepository: AppListRepository by inject() private val trackersRepository: TrackersRepository by inject() private val reportsFactory: WeeklyReportViewFactory by inject() private lateinit var binding: DebugWeeklyReportFragmentBinding private val reportsFactory: WeeklyReportViewFactory by inject() private val weeklyReportsAdapter = object : BindingListAdapter< DebugWeeklyReportItemBinding, Pair<DisplayableReport?, List<WeeklyReportScore>> Loading Loading @@ -109,6 +117,12 @@ class DebugWeeklyReportFragment : Fragment(R.layout.debug_weekly_report_fragment } } } binding.showAllReportsViews.setOnClickListener { weeklyReportsAdapter.dataSet = buildFakeReports().map { it to emptyList() } } } private fun setupRecyclerView(recyclerView: RecyclerView) { Loading @@ -118,4 +132,136 @@ class DebugWeeklyReportFragment : Fragment(R.layout.debug_weekly_report_fragment isNestedScrollingEnabled = false } } private fun buildFakeReports(): List<DisplayableReport> { val reports = mutableListOf<DisplayableReport>() val timestamp = Instant.now() // Call Per App val anyApp = appListRepository.displayableApps.value.first() val callsPerWeek = Random.nextInt(10000) val hoursInWeek = 7 * 24 reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_PER_APP, WeeklyReport.LabelId.CALLS_PER_APP_1, anyApp.id, listOf((callsPerWeek / hoursInWeek).toString()) ), anyApp ) ) reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_PER_APP, WeeklyReport.LabelId.CALLS_PER_APP_2, anyApp.id, listOf((callsPerWeek / hoursInWeek).toString()) ), anyApp ) ) reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_PER_APP, WeeklyReport.LabelId.CALLS_PER_APP_3, anyApp.id, listOf((callsPerWeek / 7).toString()) ), anyApp ) ) // New Trackers val anyApp2 = appListRepository.displayableApps.value.first() reports.add( DisplayableReport.ReportWithApp( WeeklyReport( timestamp, WeeklyReport.StatType.NEW_TRACKER, WeeklyReport.LabelId.NEW_TRACKER_1, anyApp2.id, emptyList() ), anyApp2 ) ) reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.NEW_TRACKER, WeeklyReport.LabelId.NEW_TRACKER_2, "", listOf(Random.nextInt(4).toString()) ) ) ) reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.NEW_TRACKER, WeeklyReport.LabelId.NEW_TRACKER_3, "", listOf(Random.nextInt(4).toString()) ) ) ) // Calls and Leaks val blockedRate = Random.nextInt(100).toString() val leaks = Random.nextInt(1000).toString() reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_AND_LEAKS, WeeklyReport.LabelId.CALLS_AND_LEAKS_1, blockedRate, listOf(leaks) ) ) ) reports.add( DisplayableReport.ReportText( WeeklyReport( timestamp, WeeklyReport.StatType.CALLS_AND_LEAKS, WeeklyReport.LabelId.CALLS_AND_LEAKS_2, blockedRate, listOf(leaks) ) ) ) // Tracker With Most Apps trackersRepository.getTracker("wtm_yahoo")?.let { tracker -> reports.add( DisplayableReport.ReportWithTracker( WeeklyReport( timestamp, WeeklyReport.StatType.TRACKER_WITH_MOST_APPS, WeeklyReport.LabelId.TRACKER_WITH_MOST_APPS_1, tracker.id, listOf(Random.nextInt(20).toString()) ), tracker ) ) } return reports } }
app/src/main/res/layout/debug_weekly_report_fragment.xml +7 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,13 @@ android:text="10" /> </LinearLayout> <androidx.appcompat.widget.AppCompatButton android:id="@+id/show_all_reports_views" android:layout_width="wrap_content" android:layout_height="48dp" android:layout_margin="4dp" android:text="@string/debug_weeklyreport_show_reports_views" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/reports" Loading
app/src/main/res/values/debug_strings.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?><!-- ~ Copyright (C) 2025 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/>. --> <resources> <string name="debug_activity_title" translatable="false">AdvancedPrivacy debug tools</string> <string name="debug_weekly_report_title" translatable="false">Weekly Report debug tools</string> <string name="debug_weekly_report_update_report" translatable="false">Update report</string> <string name="debug_weekly_report_generate_reports" translatable="false">Generate report of week ago:</string> <string name="debug_weekly_report_item_share" translatable="false">Share</string> <string name="debug_weekly_report_item_details" translatable="false">Details</string> <string name="debug_weekly_report_item_notification" translatable="false">Notification</string> <string name="debug_weeklyreport_show_reports_views" translatable="false">Show all reports views</string> </resources> No newline at end of file
app/src/main/res/values/strings.xml +0 −11 Original line number Diff line number Diff line Loading @@ -217,15 +217,4 @@ <string name="notifications_tracker_channel_description">Highlight that the trackers are actually logged and blocked by Advanced Privacy</string> <string name="notifications_tracker_title">Tracker control is on</string> <string name="notifications_tracker_content">This could impact the functioning of some applications.</string> <!-- DEBUG --> <string name="debug_activity_title" translatable="false">AdvancedPrivacy debug tools</string> <string name="debug_weekly_report_title" translatable="false">Weekly Report debug tools</string> <string name="debug_weekly_report_update_report" translatable="false">Update report</string> <string name="debug_weekly_report_generate_reports" translatable="false">Generate report of week ago:</string> <string name="debug_weekly_report_item_share" translatable="false">Share</string> <string name="debug_weekly_report_item_details" translatable="false">Details</string> <string name="debug_weekly_report_item_notification" translatable="false">Notification</string> </resources>