Change the string of Captions and reorder the feature in audio category

Bug: 128887817
Test: Visual
Change-Id: I4bcde9c52b4ed3484727e79758ef37f4b05a209d
Merged-In: I4bcde9c52b4ed3484727e79758ef37f4b05a209d
This commit is contained in:
Kevin Chang
2019-03-28 09:50:49 +08:00
parent d464f67e31
commit 70e9b59a51
3 changed files with 82 additions and 1 deletions

View File

@@ -660,6 +660,16 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
mServicePreferenceToPreferenceCategoryMap.put(preference, prefCategory);
}
// Update the order of all the category according to the order defined in xml file.
updateCategoryOrderFromArray(CATEGORY_SCREEN_READER,
R.array.config_order_screen_reader_services);
updateCategoryOrderFromArray(CATEGORY_AUDIO_AND_CAPTIONS,
R.array.config_order_audio_and_caption_services);
updateCategoryOrderFromArray(CATEGORY_INTERACTION_CONTROL,
R.array.config_order_interaction_control_services);
updateCategoryOrderFromArray(CATEGORY_DISPLAY,
R.array.config_order_display_services);
// If the user has not installed any additional services, hide the category.
if (downloadedServicesCategory.getPreferenceCount() == 0) {
final PreferenceScreen screen = getPreferenceScreen();
@@ -676,6 +686,29 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
}
}
/**
* Update the order of perferences in the category by matching their preference
* key with the string array of preference order which is defined in the xml.
*
* @param categoryKey The key of the category need to update the order
* @param key The key of the string array which defines the order of category
*/
private void updateCategoryOrderFromArray(String categoryKey, int key) {
String[] services = getResources().getStringArray(key);
PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
int preferenceCount = category.getPreferenceCount();
int serviceLength = services.length;
for (int preferenceIndex = 0; preferenceIndex < preferenceCount; preferenceIndex++) {
for (int serviceIndex = 0; serviceIndex < serviceLength; serviceIndex++) {
if (category.getPreference(preferenceIndex).getKey()
.equals(services[serviceIndex])) {
category.getPreference(preferenceIndex).setOrder(serviceIndex);
break;
}
}
}
}
protected void updateSystemPreferences() {
// Move color inversion and color correction preferences to Display category if device
// supports HWC hardware-accelerated color transform.