Fix accessibility button footer preference did not announced correct by TalkBack

Root Cause: Description would be altered after displayPreference(), but getSummary() would be called after it.

Solution: Update title before displayPreference(), then it could be set correctly.

Fix: 192738520
Test: atest AccessibilityButtonFooterPreferenceControllerTest
Change-Id: I068994fca8202b166fedf43f9d9657b0c1a64c4e
This commit is contained in:
jasonwshsu
2021-07-05 10:07:49 +08:00
committed by Jason Hsu
parent 27c928856e
commit 3cb889fc78
3 changed files with 29 additions and 19 deletions

View File

@@ -18,6 +18,8 @@ package com.android.settings.accessibility;
import android.content.Context;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
/**
@@ -36,9 +38,16 @@ public class AccessibilityButtonFooterPreferenceController extends
}
@Override
public CharSequence getSummary() {
return AccessibilityUtil.isGestureNavigateEnabled(mContext)
? mContext.getString(R.string.accessibility_button_gesture_description)
: mContext.getString(R.string.accessibility_button_description);
public void displayPreference(PreferenceScreen screen) {
// Need to update footerPreference's data before super.displayPreference(), then it will use
// data to update related property of footerPreference.
if (AccessibilityUtil.isGestureNavigateEnabled(mContext)) {
final AccessibilityFooterPreference footerPreference =
screen.findPreference(getPreferenceKey());
footerPreference.setTitle(
mContext.getString(R.string.accessibility_button_gesture_description));
}
super.displayPreference(screen);
}
}