Fix Talkback say twice in MainSwitch

- Remove the duplicated setting in the ContentDescription.

Bug: 191735947
Test: manual test
Test: make RunSettingsLibRoboTests -j ROBOTEST_FILTER=com.android.settingslib.widget
Change-Id: If28d0002dd1087173623b654c67bc7597d721a85
This commit is contained in:
Sunny Shao
2021-06-30 19:22:33 +08:00
parent f56767128c
commit 429d7624fb
2 changed files with 3 additions and 5 deletions

View File

@@ -152,9 +152,6 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec
public void setTitle(CharSequence text) {
if (mTextView != null) {
mTextView.setText(text);
if (mSwitch != null) {
mSwitch.setContentDescription(mTextView.getText());
}
}
}

View File

@@ -19,6 +19,7 @@ package com.android.settingslib.widget;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Switch;
import android.widget.TextView;
@@ -59,13 +60,13 @@ public class MainSwitchBarTest {
}
@Test
public void setTitle_switchShouldHasContentDescription() {
public void setTitle_switchShouldNotHasContentDescription() {
final String title = "title";
mBar.setTitle(title);
final Switch switchObj = mBar.getSwitch();
assertThat(switchObj.getContentDescription()).isEqualTo(title);
assertThat(TextUtils.isEmpty(switchObj.getContentDescription())).isTrue();
}
@Test