diff options
author | jacquarg <guillaume.jacquart@hoodbrains.com> | 2022-02-27 12:00:20 +0100 |
---|---|---|
committer | jacquarg <guillaume.jacquart@hoodbrains.com> | 2022-03-01 10:06:22 +0100 |
commit | e6ba99e31da49df559da60e8d012e40813ee14f0 (patch) | |
tree | 2b85b58d5e92c25a98df1fcd0dde255a8f2f42a1 /app/src | |
parent | aaab068ecf81c862a6adcc06ba442bca82a9d938 (diff) |
Add trackers summary count on apptrackers, #4597
Diffstat (limited to 'app/src')
5 files changed, 35 insertions, 16 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt index e43e5aa..b35fbca 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt @@ -64,19 +64,24 @@ class AppTrackersFeature( return null } } + + fun getTrackersCount() = trackers?.size ?: 0 + fun getBlockedTrackersCount(): Int = if (isBlockingActivated) + getTrackersCount() - (whitelist?.size ?: 0) + else 0 } sealed class SingleEvent { data class ErrorEvent(val error: Any) : SingleEvent() object NewStatisticsAvailableSingleEvent : SingleEvent() - data class OpenUrlEvent(val url: Uri): SingleEvent() + data class OpenUrlEvent(val url: Uri) : SingleEvent() } sealed class Action { data class InitAction(val packageName: String) : Action() data class BlockAllToggleAction(val isBlocked: Boolean) : Action() data class ToggleTrackerAction(val tracker: Tracker, val isBlocked: Boolean) : Action() - data class ClickTracker(val tracker: Tracker): Action() + data class ClickTracker(val tracker: Tracker) : Action() object FetchStatistics : Action() } @@ -90,7 +95,7 @@ class AppTrackersFeature( object NewStatisticsAvailablesEffect : Effect() data class QuickPrivacyUpdatedEffect(val enabled: Boolean) : Effect() object QuickPrivacyDisabledWarningEffect : Effect() - data class OpenUrlEffect(val url: Uri): Effect() + data class OpenUrlEffect(val url: Uri) : Effect() } companion object { @@ -186,13 +191,15 @@ class AppTrackersFeature( } else flowOf(Effect.NoEffect) } is Action.ClickTracker -> { - flowOf(action.tracker.getExodusId()?.let { - try { - Effect.OpenUrlEffect(Uri.parse(exodusBaseUrl + it)) - } catch (e: Exception) { - Effect.ErrorEffect("Invalid Url") - } - } ?: Effect.NoEffect) + flowOf( + action.tracker.getExodusId()?.let { + try { + Effect.OpenUrlEffect(Uri.parse(exodusBaseUrl + it)) + } catch (e: Exception) { + Effect.ErrorEffect("Invalid Url") + } + } ?: Effect.NoEffect + ) } is Action.FetchStatistics -> flowOf( state.appDesc?.uid?.let { diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt index a823df3..8e2dc3b 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt @@ -128,6 +128,14 @@ class AppTrackersFragment : } override fun render(state: State) { + + binding.trackersCountSummary.text = if (state.getTrackersCount() == 0) "" + else getString( + R.string.apptrackers_trackers_count_summary, + state.getBlockedTrackersCount(), + state.getTrackersCount() + ) + binding.blockAllToggle.isChecked = state.isBlockingActivated binding.trackersListTitle.isVisible = state.isBlockingActivated diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt index 134ff4f..82f2d2c 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt @@ -17,6 +17,8 @@ package foundation.e.privacycentralapp.features.trackers.apptrackers +import android.text.SpannableString +import android.text.style.UnderlineSpan import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -27,12 +29,6 @@ import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import foundation.e.privacycentralapp.R import foundation.e.privacymodules.trackers.Tracker -import android.text.style.UnderlineSpan - -import android.text.SpannableString - - - class ToggleTrackersAdapter( private val itemsLayout: Int, diff --git a/app/src/main/res/layout/apptrackers_fragment.xml b/app/src/main/res/layout/apptrackers_fragment.xml index 13f58e3..17d992e 100644 --- a/app/src/main/res/layout/apptrackers_fragment.xml +++ b/app/src/main/res/layout/apptrackers_fragment.xml @@ -41,6 +41,13 @@ android:layout_width="match_parent" android:orientation="vertical" > + <TextView + android:id="@+id/trackers_count_summary" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="16sp" + android:padding="16dp" + /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 397bd51..822244b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -74,6 +74,7 @@ <string name="apptrackers_no_trackers_yet_block_off">No trackers were detected yet. If new trackers are detected they will be updated here.</string> <string name="apptrackers_no_trackers_yet_block_on">No trackers were detected yet. All future trackers will be blocked.</string> <string name="apptrackers_error_quickprivacy_disabled">Enable Quick Privacy to be able to activate/deactivate trackers.</string> + <string name="apptrackers_trackers_count_summary">%1$d blocked trackers out of %2$d detected trackers</string> <!-- --> <string name="quick_protection_info">Quick protection enables these settings when turned on</string> |