summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Edgar Wang <edgarwang@google.com> 2022-05-20 23:13:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-05-20 23:13:08 +0000
commit53cd248506df50d033b5443f6fb1ade00957b8c5 (patch)
treec951ac6e3aa9648dfac1e14cf5b75d070d9887bd
parent83962ee99cc540a5d4aa9d9791d0fe9e7d4ea2b7 (diff)
parent1ac99118ac8478b85870b995cf091335e6dcf047 (diff)
Merge "Ensure the learn more string meet Accessibility requirement." into tm-dev
-rw-r--r--packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java48
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java7
2 files changed, 11 insertions, 44 deletions
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 6766cdd0beb6..8cda37665035 100644
--- a/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
+++ b/packages/SettingsLib/FooterPreference/src/com/android/settingslib/widget/FooterPreference.java
@@ -44,7 +44,6 @@ public class FooterPreference extends Preference {
int mIconVisibility = View.VISIBLE;
private CharSequence mContentDescription;
private CharSequence mLearnMoreText;
- private CharSequence mLearnMoreContentDescription;
private FooterLearnMoreSpan mLearnMoreSpan;
public FooterPreference(Context context, AttributeSet attrs) {
@@ -80,9 +79,6 @@ public class FooterPreference extends Preference {
learnMoreText.setSpan(mLearnMoreSpan, 0,
learnMoreText.length(), 0);
learnMore.setText(learnMoreText);
- if (!TextUtils.isEmpty(mLearnMoreContentDescription)) {
- learnMore.setContentDescription(mLearnMoreContentDescription);
- }
} else {
learnMore.setVisibility(View.GONE);
}
@@ -140,27 +136,6 @@ public class FooterPreference extends Preference {
}
/**
- * To set content description of the learn more text. This can use for talkback
- * environment if developer wants to have a customization content.
- *
- * @param learnMoreContentDescription The resource id of the content description.
- */
- public void setLearnMoreContentDescription(CharSequence learnMoreContentDescription) {
- if (!TextUtils.equals(mContentDescription, learnMoreContentDescription)) {
- mLearnMoreContentDescription = learnMoreContentDescription;
- notifyChanged();
- }
- }
-
- /**
- * Return the content description of learn more link.
- */
- @VisibleForTesting
- CharSequence getLearnMoreContentDescription() {
- return mLearnMoreContentDescription;
- }
-
- /**
* Assign an action for the learn more link.
*/
public void setLearnMoreAction(View.OnClickListener listener) {
@@ -201,7 +176,7 @@ public class FooterPreference extends Preference {
private String mKey;
private CharSequence mTitle;
private CharSequence mContentDescription;
- private CharSequence mLearnMoreContentDescription;
+ private CharSequence mLearnMoreText;
public Builder(@NonNull Context context) {
mContext = context;
@@ -260,25 +235,24 @@ public class FooterPreference extends Preference {
}
/**
- * To set content description of the learn more text. This can use for talkback
+ * To set learn more string of the learn more text. This can use for talkback
* environment if developer wants to have a customization content.
*
- * @param learnMoreContentDescription The resource id of the content description.
+ * @param learnMoreText The resource id of the learn more string.
*/
- public Builder setLearnMoreContentDescription(CharSequence learnMoreContentDescription) {
- mLearnMoreContentDescription = learnMoreContentDescription;
+ public Builder setLearnMoreText(CharSequence learnMoreText) {
+ mLearnMoreText = learnMoreText;
return this;
}
/**
- * To set content description of the {@link FooterPreference}. This can use for talkback
+ * To set learn more string of the {@link FooterPreference}. This can use for talkback
* environment if developer wants to have a customization content.
*
- * @param learnMoreContentDescriptionResId The resource id of the content description.
+ * @param learnMoreTextResId The resource id of the learn more string.
*/
- public Builder setLearnMoreContentDescription(
- @StringRes int learnMoreContentDescriptionResId) {
- mLearnMoreContentDescription = mContext.getText(learnMoreContentDescriptionResId);
+ public Builder setLearnMoreText(@StringRes int learnMoreTextResId) {
+ mLearnMoreText = mContext.getText(learnMoreTextResId);
return this;
}
@@ -301,8 +275,8 @@ public class FooterPreference extends Preference {
footerPreference.setContentDescription(mContentDescription);
}
- if (!TextUtils.isEmpty(mLearnMoreContentDescription)) {
- footerPreference.setLearnMoreContentDescription(mLearnMoreContentDescription);
+ if (!TextUtils.isEmpty(mLearnMoreText)) {
+ footerPreference.setLearnMoreText(mLearnMoreText);
}
return footerPreference;
}
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 9abb27e68398..55125c53b4c9 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
@@ -74,13 +74,6 @@ public class FooterPreferenceTest {
}
@Test
- public void setLearnMoreContentDescription_contentSet_shouldGetSameContentDescription() {
- mFooterPreference.setLearnMoreContentDescription("test");
-
- assertThat(mFooterPreference.getLearnMoreContentDescription()).isEqualTo("test");
- }
-
- @Test
public void setLearnMoreAction_actionSet_shouldGetAction() {
mFooterPreference.setLearnMoreAction(v -> {
});