Merge "Fix null pointer issue of accesibility learn more button click event" into sc-v2-dev am: e8582f9c31 am: 355ae871b5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15678258

Change-Id: I199e6d1b3f30cacfac3a15010242f9f5a4dc3239
This commit is contained in:
Menghan Li
2021-09-01 06:56:27 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 8 deletions

View File

@@ -104,11 +104,17 @@ public class AccessibilityFooterPreferenceController extends BasePreferenceContr
sb.append(getIntroductionTitle()).append("\n\n").append(footerPreference.getTitle()); sb.append(getIntroductionTitle()).append("\n\n").append(footerPreference.getTitle());
footerPreference.setContentDescription(sb); footerPreference.setContentDescription(sb);
final Intent helpIntent;
if (getHelpResource() != 0) { if (getHelpResource() != 0) {
footerPreference.setLearnMoreAction(view -> { // Returns may be null if content is wrong or empty.
final Intent helpIntent = HelpUtils.getHelpIntent( helpIntent = HelpUtils.getHelpIntent(mContext, mContext.getString(getHelpResource()),
mContext, mContext.getString(getHelpResource()),
mContext.getClass().getName()); mContext.getClass().getName());
} else {
helpIntent = null;
}
if (helpIntent != null) {
footerPreference.setLearnMoreAction(view -> {
view.startActivityForResult(helpIntent, 0); view.startActivityForResult(helpIntent, 0);
}); });
footerPreference.setLearnMoreContentDescription(getLearnMoreContentDescription()); footerPreference.setLearnMoreContentDescription(getLearnMoreContentDescription());

View File

@@ -109,16 +109,16 @@ public class AccessibilityFooterPreferenceControllerTest {
} }
@Test @Test
public void onBindViewHolder_setupHelpLink_setCorrectHelpLinkAndContentDescription() { public void onBindViewHolder_setHelpResource_emptyString_notVisible() {
mController.setupHelpLink(TEST_HELP_ID, TEST_CONTENT_DESCRIPTION); mController.setupHelpLink(R.string.help_url_timeout, TEST_CONTENT_DESCRIPTION);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
mPreference.onBindViewHolder(mPreferenceViewHolder); mPreference.onBindViewHolder(mPreferenceViewHolder);
final TextView learnMoreView = (TextView) mPreferenceViewHolder final TextView learnMoreView = (TextView) mPreferenceViewHolder
.findViewById(com.android.settingslib.R.id.settingslib_learn_more); .findViewById(com.android.settingslib.R.id.settingslib_learn_more);
assertThat(learnMoreView.getContentDescription().toString()) assertThat(learnMoreView.getContentDescription()).isNull();
.contains(TEST_CONTENT_DESCRIPTION); assertThat(learnMoreView.getVisibility()).isEqualTo(View.GONE);
assertThat(mPreference.isLinkEnabled()).isTrue(); assertThat(mPreference.isLinkEnabled()).isFalse();
} }
} }