chore(brightness suw): adjust auto brightness detail page footer content description

Ref to the bug, s2s and talkback pages' footer content descriptions are
prefixed with "About XXX" for talkbalk info announcement. Therefore, for
auto brightness detail page in SUW, we also prefix "About adaptive
brightness" to the footer preference content description, to improve
the consistency with other accessiblity feature suw pages.

Bug: 347859318
Flag: com.android.settings.accessibility.add_brightness_settings_in_suw
Test: manually
      atest AutoBrightnessPreferenceFragmentForSetupWizardTest
Change-Id: Ieda4bcffb4f4e11ea68c961beee5c2fff1b29f2c
This commit is contained in:
Roy Chou
2024-06-19 05:05:05 +00:00
parent 9bd19f4604
commit e8288512ee
3 changed files with 84 additions and 40 deletions

View File

@@ -27,11 +27,13 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
import com.android.settings.display.AutoBrightnessSettings;
import com.android.settingslib.Utils;
import com.android.settingslib.widget.FooterPreference;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupdesign.GlifPreferenceLayout;
@@ -41,10 +43,14 @@ import com.google.android.setupdesign.GlifPreferenceLayout;
*/
public class AutoBrightnessPreferenceFragmentForSetupWizard extends AutoBrightnessSettings {
private static final String FOOTER_PREFERENCE_KEY = "auto_brightness_footer";
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateFooterContentDescription();
if (view instanceof GlifPreferenceLayout) {
final GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
final String title = getContext().getString(
@@ -78,4 +84,15 @@ public class AutoBrightnessPreferenceFragmentForSetupWizard extends AutoBrightne
public int getMetricsCategory() {
return SettingsEnums.SUW_ACCESSIBILITY_AUTO_BRIGHTNESS;
}
private void updateFooterContentDescription() {
final PreferenceScreen screen = getPreferenceScreen();
final FooterPreference footerPreference = screen.findPreference(FOOTER_PREFERENCE_KEY);
if (footerPreference != null) {
String title = getString(R.string.auto_brightness_content_description_title);
final StringBuilder sb = new StringBuilder();
sb.append(title).append("\n\n").append(footerPreference.getTitle());
footerPreference.setContentDescription(sb);
}
}
}