summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tsung-Mao Fang <tmfang@google.com> 2022-03-18 18:51:50 +0800
committer Tsung-Mao Fang <tmfang@google.com> 2022-03-21 12:05:03 +0800
commite708048beda4912fb90d31b9a3f0fadc0d6e2d08 (patch)
tree313a5c97d8720b3c67ffda7b9073a84948b769b1
parent372e99c6556d122edb12080b546ec4155965d5d4 (diff)
Fix can't focus on learn more link.
Prior to this cl, we set learn more text not focusable, it causes a11y services can't distinguish it as an action item. Also do some clean up, because we only allow clean plain text for title id, so we can simply make it as <TitleView> Also, we make footer preference can't be selectable, so it can group subcomponents to make more accessible. Test: Verify on battery saver / a11y related page with talkback service , switch access, voice access. Fix: 216516546 FIx: 215478454 Fix: 215476405 Fix: 215484382 Fix: 215483374 Change-Id: I15e82f871107115650c347aa32db5fb29ee446f7
-rw-r--r--packages/SettingsLib/FooterPreference/res/layout-v31/preference_footer.xml2
-rw-r--r--packages/SettingsLib/FooterPreference/res/layout/preference_footer.xml2
-rw-r--r--packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java7
-rw-r--r--packages/SettingsLib/tests/robotests/res/layout/preference_footer.xml36
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java12
5 files changed, 28 insertions, 31 deletions
diff --git a/packages/SettingsLib/FooterPreference/res/layout-v31/preference_footer.xml b/packages/SettingsLib/FooterPreference/res/layout-v31/preference_footer.xml
index b1276303b801..212ae528a6b9 100644
--- a/packages/SettingsLib/FooterPreference/res/layout-v31/preference_footer.xml
+++ b/packages/SettingsLib/FooterPreference/res/layout-v31/preference_footer.xml
@@ -46,7 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
- <com.android.settingslib.widget.LinkTextView
+ <TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/packages/SettingsLib/FooterPreference/res/layout/preference_footer.xml b/packages/SettingsLib/FooterPreference/res/layout/preference_footer.xml
index 23192b6ce138..d403f9ec8e45 100644
--- a/packages/SettingsLib/FooterPreference/res/layout/preference_footer.xml
+++ b/packages/SettingsLib/FooterPreference/res/layout/preference_footer.xml
@@ -45,7 +45,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
- <com.android.settingslib.widget.LinkTextView
+ <TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java b/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
index 3eb6ea98f118..ac306361386e 100644
--- a/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
+++ b/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
@@ -19,7 +19,6 @@ package com.android.settingslib.widget;
import android.content.Context;
import android.text.SpannableString;
import android.text.TextUtils;
-import android.text.method.LinkMovementMethod;
import android.text.style.URLSpan;
import android.util.AttributeSet;
import android.view.View;
@@ -59,10 +58,6 @@ public class FooterPreference extends Preference {
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
TextView title = holder.itemView.findViewById(android.R.id.title);
- title.setMovementMethod(new LinkMovementMethod());
- title.setClickable(false);
- title.setLongClickable(false);
- title.setFocusable(false);
if (!TextUtils.isEmpty(mContentDescription)) {
title.setContentDescription(mContentDescription);
}
@@ -86,7 +81,6 @@ public class FooterPreference extends Preference {
if (!TextUtils.isEmpty(mLearnMoreContentDescription)) {
learnMore.setContentDescription(mLearnMoreContentDescription);
}
- learnMore.setFocusable(false);
} else {
learnMore.setVisibility(View.GONE);
}
@@ -180,6 +174,7 @@ public class FooterPreference extends Preference {
if (TextUtils.isEmpty(getKey())) {
setKey(KEY_FOOTER);
}
+ setSelectable(false);
}
/**
diff --git a/packages/SettingsLib/tests/robotests/res/layout/preference_footer.xml b/packages/SettingsLib/tests/robotests/res/layout/preference_footer.xml
index c47bff7104ba..766efa829778 100644
--- a/packages/SettingsLib/tests/robotests/res/layout/preference_footer.xml
+++ b/packages/SettingsLib/tests/robotests/res/layout/preference_footer.xml
@@ -23,32 +23,46 @@
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
+ android:orientation="vertical"
android:clipToPadding="false">
<LinearLayout
- android:id="@+id/icon_container"
+ android:id="@+id/icon_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:minWidth="60dp"
+ android:minWidth="56dp"
android:gravity="start|top"
android:orientation="horizontal"
android:paddingEnd="12dp"
- android:paddingTop="20dp"
+ android:paddingTop="16dp"
android:paddingBottom="4dp">
<ImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"/>
</LinearLayout>
- <com.android.settingslib.widget.LinkTextView
- android:id="@android:id/title"
+ <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingBottom="16dp"
- android:paddingTop="16dp"
- android:maxLines="10"
- android:textColor="?android:attr/textColorSecondary"
- android:ellipsize="marquee" />
+ android:orientation="vertical">
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="16dp"
+ android:paddingBottom="8dp"
+ android:textColor="?android:attr/textColorSecondary"
+ android:ellipsize="marquee" />
+
+ <com.android.settingslib.widget.LinkTextView
+ android:id="@+id/settingslib_learn_more"
+ android:text="@string/settingslib_learn_more_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="true"
+ android:visibility="gone"
+ style="@style/TextAppearance.Footer.Title.SettingsLib"/>
+ </LinearLayout>
</LinearLayout>
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java
index 3b18c57e28fa..61a28aab061f 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java
@@ -19,7 +19,6 @@ package com.android.settingslib.widget;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
-import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.widget.TextView;
@@ -46,17 +45,6 @@ public class FooterPreferenceTest {
}
@Test
- public void bindPreference_shouldLinkifyContent() {
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- LayoutInflater.from(mContext).inflate(R.layout.preference_footer, null));
-
- mFooterPreference.onBindViewHolder(holder);
-
- assertThat(((TextView) holder.findViewById(android.R.id.title)).getMovementMethod())
- .isInstanceOf(LinkMovementMethod.class);
- }
-
- @Test
public void setSummary_summarySet_shouldSetAsTitle() {
mFooterPreference.setSummary("summary");