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 8adf2560f13b252725004e180cb6a681cc5a85c2..83359e18fb94406bad349914d49cb0125301737c 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 07828f8754949db4d667d9c3dfc04d2f70cb1d9f..2cdfabcd2886b466f207d7d3932042c27063ac0f 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 6aeac8ee124f8c5d1b0342517be5972329b57fa9..f15119e8a6ca380d13f0103ca02eeb9306235405 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 4d6e1f941c9fe91d7d4116e39df152df72f2c0a3..17f5e3b061b82b388c59ddb25ff11dc6082b35e1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,6 +11,10 @@
Blocked leaks
Allowed leaks
Tap on the bars for more information.
+
+ No application to see webpages
+
+
@string/app_name
Your online privacy is protected
@@ -70,6 +74,7 @@
Manage apps\' trackers
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.
+ Learn more
%d trackers
24 hours
past month
diff --git a/build.gradle b/build.gradle
index 2abc73d2116ab02df9aadf0170ca052b40700733..e1359973c1b5ae0245c0bcffc1dcc1f9450ea003 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,7 +26,7 @@ buildscript {
'targetSdk' : 31,
'version' : [
'major': 1,
- 'minor': 4,
+ 'minor': 7,
'patch': 0,
],
]