Loading app/build.gradle +2 −2 Original line number Diff line number Diff line Loading @@ -112,8 +112,8 @@ dependencies { //googleImplementation project(":privacymodulesgoogle") // include the e specific version of the modules, just for the e flavor implementation 'foundation.e:privacymodule.trackerfilter:0.5.1' implementation 'foundation.e:privacymodule.api:0.6.0' implementation 'foundation.e:privacymodule.trackerfilter:0.6.0' implementation 'foundation.e:privacymodule.api:1.0.0' e29Implementation 'foundation.e:privacymodule.e-29:0.4.2' e30Implementation 'foundation.e:privacymodule.e-30:0.4.2' implementation 'foundation.e:privacymodule.tor:0.2.2' Loading app/src/main/java/foundation/e/privacycentralapp/common/GraphHolder.kt +55 −12 Original line number Diff line number Diff line Loading @@ -19,9 +19,14 @@ package foundation.e.privacycentralapp.common import android.content.Context import android.graphics.Canvas import android.text.Spannable import android.text.SpannableStringBuilder import android.text.style.DynamicDrawableSpan import android.text.style.ImageSpan import android.view.View import android.widget.TextView import androidx.core.content.ContextCompat import androidx.core.text.toSpannable import androidx.core.view.isVisible import com.github.mikephil.charting.charts.BarChart import com.github.mikephil.charting.components.MarkerView Loading @@ -37,7 +42,7 @@ import foundation.e.privacycentralapp.R import foundation.e.privacycentralapp.extensions.dpToPxF class GraphHolder(val barChart: BarChart, val context: Context, val isMarkerAbove: Boolean = true) { var data = emptyList<Int>() var data = emptyList<Pair<Int, Int>>() set(value) { field = value refreshDataSet() Loading Loading @@ -80,7 +85,17 @@ class GraphHolder(val barChart: BarChart, val context: Context, val isMarkerAbov setOnChartValueSelectedListener(object : OnChartValueSelectedListener { override fun onValueSelected(e: Entry?, h: Highlight?) { h?.let { periodMarker.setLabel(labels.getOrNull(it.x.toInt())) } h?.let { val index = it.x.toInt() if (index > 0 && index < labels.size && index < this@GraphHolder.data.size ) { val period = labels[index] val (blocked, leaked) = this@GraphHolder.data[index] periodMarker.setLabel(period, blocked, leaked) } } isHighlighted = true refreshDataSet() } Loading @@ -95,18 +110,31 @@ class GraphHolder(val barChart: BarChart, val context: Context, val isMarkerAbov private fun refreshDataSet() { val trackersDataSet = BarDataSet( data.mapIndexed { index, value -> BarEntry(index.toFloat(), value.toFloat()) }, data.mapIndexed { index, value -> BarEntry( index.toFloat(), floatArrayOf(value.first.toFloat(), value.second.toFloat()) ) }, "" ).apply { color = ContextCompat.getColor( context, if (isHighlighted) R.color.blue_unselected else R.color.accent val blockedColor = ContextCompat.getColor(context, R.color.accent) val leakedColor = ContextCompat.getColor(context, R.color.red_off) // ColorUtils.setAlphaComponent() colors = listOf( blockedColor, // if (isHighlighted) R.color.blue_unselected else R.color.accent leakedColor ) setDrawValues(false) highLightColor = ContextCompat.getColor( context, R.color.accent ) highLightAlpha = 255 // highLightColor = ContextCompat.getColor( // context, R.color.accent // ) // highLightAlpha = 255 } barChart.data = BarData(trackersDataSet) Loading Loading @@ -162,8 +190,23 @@ class PeriodMarkerView(context: Context, private val isMarkerAbove: Boolean = tr } } fun setLabel(label: String?) { findViewById<TextView>(R.id.label).text = label fun setLabel(period: String, blocked: Int, leaked: Int) { val span = SpannableStringBuilder(period) span.append(": $blocked ") span.setSpan( ImageSpan(context, R.drawable.ic_legend_blocked, DynamicDrawableSpan.ALIGN_BASELINE), span.length - 1, span.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) span.append(" $leaked ") span.setSpan( ImageSpan(context, R.drawable.ic_legend_leaked, DynamicDrawableSpan.ALIGN_BASELINE), span.length - 1, span.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) findViewById<TextView>(R.id.label).text = span.toSpannable() } override fun refreshContent(e: Entry?, highlight: Highlight?) { Loading app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package foundation.e.privacycentralapp.common import androidx.annotation.LayoutRes import com.google.android.material.appbar.MaterialToolbar import foundation.e.privacycentralapp.R abstract class NavToolbarFragment(@LayoutRes contentLayoutId: Int) : ToolbarFragment(contentLayoutId) { Loading app/src/main/java/foundation/e/privacycentralapp/domain/entities/TrackersPeriodicStatistics.kt +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package foundation.e.privacycentralapp.domain.entities data class TrackersPeriodicStatistics( val calls: List<Int>, val callsBlockedNLeaked: List<Pair<Int, Int>>, val periods: List<String>, val trackersCount: Int ) app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt +4 −4 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class TrackersStatisticsUseCase( fun getDayStatistics(): Pair<TrackersPeriodicStatistics, Int> { return TrackersPeriodicStatistics( calls = trackTrackersPrivacyModule.getPastDayTrackersCalls(), callsBlockedNLeaked = trackTrackersPrivacyModule.getPastDayTrackersCalls(), periods = buildDayLabels(), trackersCount = trackTrackersPrivacyModule.getPastDayTrackersCount() ) to trackTrackersPrivacyModule.getTrackersCount() Loading Loading @@ -107,17 +107,17 @@ class TrackersStatisticsUseCase( return with(trackTrackersPrivacyModule) { Triple( TrackersPeriodicStatistics( calls = getPastDayTrackersCalls(), callsBlockedNLeaked = getPastDayTrackersCalls(), periods = buildDayLabels(), trackersCount = getPastDayTrackersCount() ), TrackersPeriodicStatistics( calls = getPastMonthTrackersCalls(), callsBlockedNLeaked = getPastMonthTrackersCalls(), periods = buildMonthLabels(), trackersCount = getPastMonthTrackersCount() ), TrackersPeriodicStatistics( calls = getPastYearTrackersCalls(), callsBlockedNLeaked = getPastYearTrackersCalls(), periods = buildYearLabels(), trackersCount = getPastYearTrackersCount() ) Loading Loading
app/build.gradle +2 −2 Original line number Diff line number Diff line Loading @@ -112,8 +112,8 @@ dependencies { //googleImplementation project(":privacymodulesgoogle") // include the e specific version of the modules, just for the e flavor implementation 'foundation.e:privacymodule.trackerfilter:0.5.1' implementation 'foundation.e:privacymodule.api:0.6.0' implementation 'foundation.e:privacymodule.trackerfilter:0.6.0' implementation 'foundation.e:privacymodule.api:1.0.0' e29Implementation 'foundation.e:privacymodule.e-29:0.4.2' e30Implementation 'foundation.e:privacymodule.e-30:0.4.2' implementation 'foundation.e:privacymodule.tor:0.2.2' Loading
app/src/main/java/foundation/e/privacycentralapp/common/GraphHolder.kt +55 −12 Original line number Diff line number Diff line Loading @@ -19,9 +19,14 @@ package foundation.e.privacycentralapp.common import android.content.Context import android.graphics.Canvas import android.text.Spannable import android.text.SpannableStringBuilder import android.text.style.DynamicDrawableSpan import android.text.style.ImageSpan import android.view.View import android.widget.TextView import androidx.core.content.ContextCompat import androidx.core.text.toSpannable import androidx.core.view.isVisible import com.github.mikephil.charting.charts.BarChart import com.github.mikephil.charting.components.MarkerView Loading @@ -37,7 +42,7 @@ import foundation.e.privacycentralapp.R import foundation.e.privacycentralapp.extensions.dpToPxF class GraphHolder(val barChart: BarChart, val context: Context, val isMarkerAbove: Boolean = true) { var data = emptyList<Int>() var data = emptyList<Pair<Int, Int>>() set(value) { field = value refreshDataSet() Loading Loading @@ -80,7 +85,17 @@ class GraphHolder(val barChart: BarChart, val context: Context, val isMarkerAbov setOnChartValueSelectedListener(object : OnChartValueSelectedListener { override fun onValueSelected(e: Entry?, h: Highlight?) { h?.let { periodMarker.setLabel(labels.getOrNull(it.x.toInt())) } h?.let { val index = it.x.toInt() if (index > 0 && index < labels.size && index < this@GraphHolder.data.size ) { val period = labels[index] val (blocked, leaked) = this@GraphHolder.data[index] periodMarker.setLabel(period, blocked, leaked) } } isHighlighted = true refreshDataSet() } Loading @@ -95,18 +110,31 @@ class GraphHolder(val barChart: BarChart, val context: Context, val isMarkerAbov private fun refreshDataSet() { val trackersDataSet = BarDataSet( data.mapIndexed { index, value -> BarEntry(index.toFloat(), value.toFloat()) }, data.mapIndexed { index, value -> BarEntry( index.toFloat(), floatArrayOf(value.first.toFloat(), value.second.toFloat()) ) }, "" ).apply { color = ContextCompat.getColor( context, if (isHighlighted) R.color.blue_unselected else R.color.accent val blockedColor = ContextCompat.getColor(context, R.color.accent) val leakedColor = ContextCompat.getColor(context, R.color.red_off) // ColorUtils.setAlphaComponent() colors = listOf( blockedColor, // if (isHighlighted) R.color.blue_unselected else R.color.accent leakedColor ) setDrawValues(false) highLightColor = ContextCompat.getColor( context, R.color.accent ) highLightAlpha = 255 // highLightColor = ContextCompat.getColor( // context, R.color.accent // ) // highLightAlpha = 255 } barChart.data = BarData(trackersDataSet) Loading Loading @@ -162,8 +190,23 @@ class PeriodMarkerView(context: Context, private val isMarkerAbove: Boolean = tr } } fun setLabel(label: String?) { findViewById<TextView>(R.id.label).text = label fun setLabel(period: String, blocked: Int, leaked: Int) { val span = SpannableStringBuilder(period) span.append(": $blocked ") span.setSpan( ImageSpan(context, R.drawable.ic_legend_blocked, DynamicDrawableSpan.ALIGN_BASELINE), span.length - 1, span.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) span.append(" $leaked ") span.setSpan( ImageSpan(context, R.drawable.ic_legend_leaked, DynamicDrawableSpan.ALIGN_BASELINE), span.length - 1, span.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) findViewById<TextView>(R.id.label).text = span.toSpannable() } override fun refreshContent(e: Entry?, highlight: Highlight?) { Loading
app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package foundation.e.privacycentralapp.common import androidx.annotation.LayoutRes import com.google.android.material.appbar.MaterialToolbar import foundation.e.privacycentralapp.R abstract class NavToolbarFragment(@LayoutRes contentLayoutId: Int) : ToolbarFragment(contentLayoutId) { Loading
app/src/main/java/foundation/e/privacycentralapp/domain/entities/TrackersPeriodicStatistics.kt +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package foundation.e.privacycentralapp.domain.entities data class TrackersPeriodicStatistics( val calls: List<Int>, val callsBlockedNLeaked: List<Pair<Int, Int>>, val periods: List<String>, val trackersCount: Int )
app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStatisticsUseCase.kt +4 −4 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class TrackersStatisticsUseCase( fun getDayStatistics(): Pair<TrackersPeriodicStatistics, Int> { return TrackersPeriodicStatistics( calls = trackTrackersPrivacyModule.getPastDayTrackersCalls(), callsBlockedNLeaked = trackTrackersPrivacyModule.getPastDayTrackersCalls(), periods = buildDayLabels(), trackersCount = trackTrackersPrivacyModule.getPastDayTrackersCount() ) to trackTrackersPrivacyModule.getTrackersCount() Loading Loading @@ -107,17 +107,17 @@ class TrackersStatisticsUseCase( return with(trackTrackersPrivacyModule) { Triple( TrackersPeriodicStatistics( calls = getPastDayTrackersCalls(), callsBlockedNLeaked = getPastDayTrackersCalls(), periods = buildDayLabels(), trackersCount = getPastDayTrackersCount() ), TrackersPeriodicStatistics( calls = getPastMonthTrackersCalls(), callsBlockedNLeaked = getPastMonthTrackersCalls(), periods = buildMonthLabels(), trackersCount = getPastMonthTrackersCount() ), TrackersPeriodicStatistics( calls = getPastYearTrackersCalls(), callsBlockedNLeaked = getPastYearTrackersCalls(), periods = buildYearLabels(), trackersCount = getPastYearTrackersCount() ) Loading