diff --git a/res/values/strings.xml b/res/values/strings.xml
index b4e4549b651..92fa414612f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5254,6 +5254,8 @@
Not working. Tap for info.
This service is malfunctioning.
+
+ Accessibility shortcuts
Show in Quick Settings
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 36125b34cc1..eff9e1d975c 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -29,15 +29,7 @@
-
-
-
+ android:title="@string/screen_reader_category_title"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 4709c66d81c..582111f0abb 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -372,6 +372,9 @@ public class AccessibilitySettings extends DashboardFragment {
} else {
getPreferenceScreen().addPreference(downloadedServicesCategory);
}
+
+ // Hide screen reader category if it is empty.
+ updatePreferenceCategoryVisibility(CATEGORY_SCREEN_READER);
}
private List getInstalledAccessibilityList(Context context) {
@@ -452,6 +455,16 @@ public class AccessibilitySettings extends DashboardFragment {
}
}
+ /**
+ * Updates the visibility of a category according to its child preference count.
+ *
+ * @param categoryKey The key of the category which needs to check
+ */
+ private void updatePreferenceCategoryVisibility(String categoryKey) {
+ final PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
+ category.setVisible(category.getPreferenceCount() != 0);
+ }
+
/**
* Updates preferences related to system configurations.
*/
diff --git a/src/com/android/settings/accessibility/ShortcutsSettingsFragment.java b/src/com/android/settings/accessibility/ShortcutsSettingsFragment.java
new file mode 100644
index 00000000000..91e16f623f3
--- /dev/null
+++ b/src/com/android/settings/accessibility/ShortcutsSettingsFragment.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+
+/** Accessibility settings for accessibility shortcuts. */
+public class ShortcutsSettingsFragment extends DashboardFragment {
+
+ private static final String TAG = "ShortcutsSettingsFragment";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.ACCESSIBILITY_SHORTCUTS_SETTINGS;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.accessibility_shortcuts_settings;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.accessibility_shortcuts_settings);
+
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ShortcutsSettingsFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ShortcutsSettingsFragmentTest.java
new file mode 100644
index 00000000000..12b568fe6b6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ShortcutsSettingsFragmentTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settings.testutils.XmlTestUtils;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.List;
+
+/** Tests for {@link ShortcutsSettingsFragment}. */
+@RunWith(RobolectricTestRunner.class)
+public class ShortcutsSettingsFragmentTest {
+
+ private Context mContext = ApplicationProvider.getApplicationContext();
+
+ @Test
+ public void getNonIndexableKeys_existInXmlLayout() {
+ final List niks = ShortcutsSettingsFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(mContext);
+ final List keys =
+ XmlTestUtils.getKeysFromPreferenceXml(mContext,
+ R.xml.accessibility_shortcuts_settings);
+
+ assertThat(keys).containsAtLeastElementsIn(niks);
+ }
+}