summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt49
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersViewModel.kt10
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt6
-rw-r--r--app/src/main/res/values/strings.xml5
4 files changed, 69 insertions, 1 deletions
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
index 8adf256..83359e1 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
@@ -17,9 +17,18 @@
package foundation.e.privacycentralapp.features.trackers
+import android.content.ActivityNotFoundException
+import android.content.Intent
import android.os.Bundle
+import android.text.Spannable
+import android.text.SpannableString
+import android.text.method.LinkMovementMethod
+import android.text.style.ClickableSpan
+import android.text.style.ForegroundColorSpan
+import android.text.style.UnderlineSpan
import android.view.View
import android.widget.Toast
+import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.commit
import androidx.fragment.app.replace
@@ -76,6 +85,35 @@ class TrackersFragment :
}
}
+ val infoText = getString(R.string.trackers_info)
+ val moreText = getString(R.string.trackers_info_more)
+
+ val spannable = SpannableString("$infoText $moreText")
+ val startIndex = infoText.length + 1
+ val endIndex = spannable.length
+ spannable.setSpan(
+ ForegroundColorSpan(ContextCompat.getColor(requireContext(), R.color.accent)),
+ startIndex,
+ endIndex,
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ )
+ spannable.setSpan(UnderlineSpan(), startIndex, endIndex, Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
+ spannable.setSpan(
+ object : ClickableSpan() {
+ override fun onClick(p0: View) {
+ viewModel.submitAction(TrackersViewModel.Action.ClickLearnMore)
+ }
+ },
+ startIndex, endIndex, Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ )
+
+ with(binding.trackersInfo) {
+ linksClickable = true
+ isClickable = true
+ movementMethod = LinkMovementMethod.getInstance()
+ text = spannable
+ }
+
setToolTipForAsterisk(
textView = binding.trackersAppsListTitle,
textId = R.string.trackers_applist_title,
@@ -110,6 +148,17 @@ class TrackersFragment :
addToBackStack("apptrackers")
}
}
+ is TrackersViewModel.SingleEvent.OpenUrl -> {
+ try {
+ startActivity(Intent(Intent.ACTION_VIEW, event.url))
+ } catch (e: ActivityNotFoundException) {
+ Toast.makeText(
+ requireContext(),
+ R.string.error_no_activity_view_url,
+ Toast.LENGTH_SHORT
+ ).show()
+ }
+ }
}
}
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersViewModel.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersViewModel.kt
index 07828f8..2cdfabc 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersViewModel.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersViewModel.kt
@@ -17,6 +17,7 @@
package foundation.e.privacycentralapp.features.trackers
+import android.net.Uri
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import foundation.e.privacycentralapp.domain.entities.AppWithCounts
@@ -38,6 +39,11 @@ class TrackersViewModel(
private val trackersStatisticsUseCase: TrackersStatisticsUseCase
) : ViewModel() {
+ companion object {
+ private const val URL_LEARN_MORE_ABOUT_TRACKERS =
+ "https://doc.e.foundation/support-topics/advanced_privacy#trackers-blocker"
+ }
+
private val _state = MutableStateFlow(TrackersState())
val state = _state.asStateFlow()
@@ -67,6 +73,8 @@ class TrackersViewModel(
fun submitAction(action: Action) = viewModelScope.launch {
when (action) {
is Action.ClickAppAction -> actionClickApp(action)
+ is Action.ClickLearnMore ->
+ _singleEvents.emit(SingleEvent.OpenUrl(Uri.parse(URL_LEARN_MORE_ABOUT_TRACKERS)))
}
}
@@ -79,9 +87,11 @@ class TrackersViewModel(
sealed class SingleEvent {
data class ErrorEvent(val error: String) : SingleEvent()
data class OpenAppDetailsEvent(val appDesc: AppWithCounts) : SingleEvent()
+ data class OpenUrl(val url: Uri) : SingleEvent()
}
sealed class Action {
data class ClickAppAction(val packageName: String) : Action()
+ object ClickLearnMore : Action()
}
}
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 6aeac8e..f15119e 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
@@ -108,7 +108,11 @@ class AppTrackersFragment : NavToolbarFragment(R.layout.apptrackers_fragment) {
try {
startActivity(Intent(Intent.ACTION_VIEW, event.url))
} catch (e: ActivityNotFoundException) {
- displayToast("No application to see webpages")
+ Toast.makeText(
+ requireContext(),
+ R.string.error_no_activity_view_url,
+ Toast.LENGTH_SHORT
+ ).show()
}
is AppTrackersViewModel.SingleEvent.ToastTrackersControlDisabled ->
Snackbar.make(
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b29bbca..6cb0b5b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,6 +11,10 @@
<string name="graph_legend_blocked">Blocked leaks</string>
<string name="graph_legend_allowed">Allowed leaks</string>
<string name="graph_subtitle">Tap on the bars for more information.</string>
+
+ <string name="error_no_activity_view_url">No application to see webpages</string>
+
+
<!-- Dashboard -->
<string name="dashboard_title" translatable="false">@string/app_name</string>
<string name="dashboard_state_title_on">Your online privacy is protected</string>
@@ -70,6 +74,7 @@
<!-- Trackers -->
<string name="trackers_title">Manage apps\' trackers</string>
<string name="trackers_info">Trackers are pieces of code hidden in apps. They collect your data and follow your activity 24/7. See which trackers are active and block them all for best protection. As it could cause some applications to malfunction, you can choose specifically which trackers you want to block.</string>
+ <string name="trackers_info_more">Learn more</string>
<string name="trackers_count_label">%d trackers</string>
<string name="trackers_period_day">24 hours</string>
<string name="trackers_period_month">past month</string>