Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1677e11 authored by menghanli's avatar menghanli
Browse files

Make Accessibility Settings can support Relate project in Speech category

Goal: Make Accessibility Settings can dynamically show the Relate project in Speech category when existing

Bug: 265883460
Test: Manual testing
Change-Id: I28ac9bee6d1e946a793ed679829e326a178f1015
parent 25e8018d
Loading
Loading
Loading
Loading
+32 −10
Original line number Diff line number Diff line
@@ -101,6 +101,14 @@
        -->
    </string-array>

    <!-- List containing the component names of pre-installed speech services. -->
    <string-array name="config_preinstalled_speech_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        -->
    </string-array>

    <!-- List containing the component names of pre-installed interaction control services. -->
    <string-array name="config_preinstalled_interaction_control_services" translatable="false">
        <!--
@@ -109,8 +117,9 @@
        -->
    </string-array>

    <!-- List containing the order of services in screen reader category by componentname.
         All componentnames in a category need to be specified to guarantee correct behavior.-->
    <!-- List containing the order of services in screen reader category by {@link ComponentName}.
         All {@link ComponentName} in a category need to be specified to guarantee correct
         behavior.-->
    <string-array name="config_order_screen_reader_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
@@ -119,8 +128,8 @@
    </string-array>

    <!-- List containing the order of services in captions category by preference key or
         componentname. All preference keys in a category need to be specified to guarantee correct
         behavior.-->
         {@link ComponentName}. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_captions_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
@@ -131,8 +140,8 @@
        -->
    </string-array>

    <!-- List containing the order of services in audio and caption category by preference key
         or componentname. All preference keys in a category need to be specified to guarantee
    <!-- List containing the order of services in audio and caption category by preference key or
         {@link ComponentName}. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_audio_services" translatable="false">
        <!--
@@ -144,8 +153,8 @@
        -->
    </string-array>

    <!-- List containing the order of services in display category by preference key
         or componentname. All preference keys in a category need to be specified to guarantee
    <!-- List containing the order of services in display category by preference key or
         {@link ComponentName}. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_display_services" translatable="false">
        <!--
@@ -157,8 +166,21 @@
        -->
    </string-array>

    <!-- List containing the order of services in interaction control category by preference key
         or componentname. All preference keys in a category need to be specified to guarantee
    <!-- List containing the order of services in speech category by preference key or
         {@link ComponentName}. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_speech_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        <item>font_size_preference_screen</item>
        <item>dark_ui_mode_accessibility</item>
        <item>...</item>
        -->
    </string-array>

    <!-- List containing the order of services in interaction control category by preference key or
         {@link ComponentName}. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_interaction_control_services" translatable="false">
        <!--
+5 −0
Original line number Diff line number Diff line
@@ -169,6 +169,11 @@

    </PreferenceCategory>

    <PreferenceCategory
        android:key="speech_category"
        android:persistent="false"
        android:title="@string/speech_category_title"/>

    <PreferenceCategory
        android:persistent="false"
        android:title="@string/general_category_title">
+8 −2
Original line number Diff line number Diff line
@@ -63,13 +63,14 @@ public class AccessibilitySettings extends DashboardFragment {
    private static final String CATEGORY_SCREEN_READER = "screen_reader_category";
    private static final String CATEGORY_CAPTIONS = "captions_category";
    private static final String CATEGORY_AUDIO = "audio_category";
    private static final String CATEGORY_SPEECH = "speech_category";
    private static final String CATEGORY_DISPLAY = "display_category";
    private static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
    private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";

    private static final String[] CATEGORIES = new String[]{
            CATEGORY_SCREEN_READER, CATEGORY_CAPTIONS, CATEGORY_AUDIO, CATEGORY_DISPLAY,
            CATEGORY_INTERACTION_CONTROL, CATEGORY_DOWNLOADED_SERVICES
            CATEGORY_SPEECH, CATEGORY_INTERACTION_CONTROL, CATEGORY_DOWNLOADED_SERVICES
    };

    // Extras passed to sub-fragments.
@@ -349,6 +350,8 @@ public class AccessibilitySettings extends DashboardFragment {
                R.array.config_preinstalled_audio_services);
        initializePreBundledServicesMapFromArray(CATEGORY_DISPLAY,
                R.array.config_preinstalled_display_services);
        initializePreBundledServicesMapFromArray(CATEGORY_SPEECH,
                R.array.config_preinstalled_speech_services);
        initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL,
                R.array.config_preinstalled_interaction_control_services);

@@ -382,6 +385,8 @@ public class AccessibilitySettings extends DashboardFragment {
                R.array.config_order_interaction_control_services);
        updateCategoryOrderFromArray(CATEGORY_DISPLAY,
                R.array.config_order_display_services);
        updateCategoryOrderFromArray(CATEGORY_SPEECH,
                R.array.config_order_speech_services);

        // Need to check each time when updateServicePreferences() called.
        if (downloadedServicesCategory.getPreferenceCount() == 0) {
@@ -390,8 +395,9 @@ public class AccessibilitySettings extends DashboardFragment {
            getPreferenceScreen().addPreference(downloadedServicesCategory);
        }

        // Hide screen reader category if it is empty.
        // Hide category if it is empty.
        updatePreferenceCategoryVisibility(CATEGORY_SCREEN_READER);
        updatePreferenceCategoryVisibility(CATEGORY_SPEECH);
    }

    private List<RestrictedPreference> getInstalledAccessibilityList(Context context) {