1
0
Fork 0

For #5141 Changed "learn more" link to be accessible to Talkback users

master
mihai-adrian 2019-09-16 15:48:42 +03:00 committed by Emily Kager
parent 172a9cf06c
commit 47064a68e0
4 changed files with 47 additions and 35 deletions

View File

@ -6,8 +6,7 @@ package org.mozilla.fenix.exceptions
import android.text.SpannableString import android.text.SpannableString
import android.text.method.LinkMovementMethod import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan import android.text.style.UnderlineSpan
import android.text.style.ForegroundColorSpan
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -58,25 +57,15 @@ class ExceptionsView(
adapter = ExceptionsAdapter(interactor) adapter = ExceptionsAdapter(interactor)
layoutManager = LinearLayoutManager(container.context) layoutManager = LinearLayoutManager(container.context)
} }
val descriptionText = String val learnMoreText = view.exceptions_learn_more.text.toString()
.format( val textWithLink = SpannableString(learnMoreText).apply {
view.exceptions_empty_view.text.toString(), setSpan(UnderlineSpan(), 0, learnMoreText.length, 0)
System.getProperty("line.separator")
)
val linkStartIndex = descriptionText.indexOf("\n\n") + 2
val linkAction = object : ClickableSpan() {
override fun onClick(widget: View?) {
interactor.onLearnMore()
}
} }
val textWithLink = SpannableString(descriptionText).apply { with(view.exceptions_learn_more) {
setSpan(linkAction, linkStartIndex, descriptionText.length, 0) movementMethod = LinkMovementMethod.getInstance()
val colorSpan = ForegroundColorSpan(view.exceptions_empty_view.currentTextColor) text = textWithLink
setSpan(colorSpan, linkStartIndex, descriptionText.length, 0) setOnClickListener { interactor.onLearnMore() }
} }
view.exceptions_empty_view.movementMethod = LinkMovementMethod.getInstance()
view.exceptions_empty_view.text = textWithLink
} }
fun update(state: ExceptionsFragmentState) { fun update(state: ExceptionsFragmentState) {

View File

@ -3,26 +3,45 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/exceptions_wrapper" android:id="@+id/exceptions_wrapper"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView <androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
android:id="@+id/exceptions_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/exception_item" />
<TextView
android:id="@+id/exceptions_empty_view" android:id="@+id/exceptions_empty_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="top" android:layout_margin="@dimen/exceptions_description_margin">
android:layout_margin="12dp"
android:text="@string/exceptions_empty_message" <TextView
android:textColor="?secondaryText" android:id="@+id/exceptions_empty_message"
android:textSize="16sp" android:layout_width="match_parent"
android:visibility="visible" /> android:layout_height="wrap_content"
android:padding="4dp"
android:text="@string/exceptions_empty_message_description"
android:textColor="?secondaryText"
android:textSize="16sp"
android:visibility="visible"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/exceptions_learn_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="@string/exceptions_empty_message_learn_more_link"
android:textColor="?secondaryText"
android:textSize="16sp"
android:visibility="visible"
app:layout_constraintTop_toBottomOf="@id/exceptions_empty_message" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/exceptions_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
tools:listitem="@layout/exception_item" />
</FrameLayout> </FrameLayout>

View File

@ -31,6 +31,7 @@
<dimen name="site_permissions_exceptions_item_text_size">18sp</dimen> <dimen name="site_permissions_exceptions_item_text_size">18sp</dimen>
<dimen name="site_permissions_exceptions_item_height">56dp</dimen> <dimen name="site_permissions_exceptions_item_height">56dp</dimen>
<dimen name="component_collection_creation_list_margin">16dp</dimen> <dimen name="component_collection_creation_list_margin">16dp</dimen>
<dimen name="exceptions_description_margin">12dp</dimen>
<dimen name="context_menu_height">48dp</dimen> <dimen name="context_menu_height">48dp</dimen>
<dimen name="context_menu_x_offset">8dp</dimen> <dimen name="context_menu_x_offset">8dp</dimen>

View File

@ -238,8 +238,11 @@
<string name="preferences_tracking_protection_exceptions_description">Tracking Protection is off for these websites</string> <string name="preferences_tracking_protection_exceptions_description">Tracking Protection is off for these websites</string>
<!-- Button in Exceptions Preference to turn on tracking protection for all sites (remove all exceptions) --> <!-- Button in Exceptions Preference to turn on tracking protection for all sites (remove all exceptions) -->
<string name="preferences_tracking_protection_exceptions_turn_on_for_all">Turn on for all sites</string> <string name="preferences_tracking_protection_exceptions_turn_on_for_all">Turn on for all sites</string>
<!-- Text displayed when there are no exceptions, includes a learn more link that brings users to a tracking protection SUMO page --> <!-- Text displayed when there are no exceptions -->
<string name="exceptions_empty_message">Exceptions let you disable tracking protection for selected sites.\n\nLearn more</string> <string name="exceptions_empty_message_description">Exceptions let you disable tracking protection for selected sites.</string>
<!-- Text displayed when there are no exceptions, with learn more link that brings users to a tracking protection SUMO page -->
<string name="exceptions_empty_message_learn_more_link">Learn more</string>
<!-- Description in Quick Settings that tells user tracking protection is off globally for all sites, and links to Settings to turn it on --> <!-- Description in Quick Settings that tells user tracking protection is off globally for all sites, and links to Settings to turn it on -->
<string name="preferences_tracking_protection_turned_off_globally">Turned off globally, go to Settings to turn it on.</string> <string name="preferences_tracking_protection_turned_off_globally">Turned off globally, go to Settings to turn it on.</string>