diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4b93d8ced17..3999ab693cf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3974,6 +3974,8 @@
Talkback
Screen reader primarily for people with blindness and low vision
+
+ Tap items on your screen to hear them read aloud
System
diff --git a/res/xml/accessibility_settings_for_setup_wizard.xml b/res/xml/accessibility_settings_for_setup_wizard.xml
index c938f240cd3..42b137bf090 100644
--- a/res/xml/accessibility_settings_for_setup_wizard.xml
+++ b/res/xml/accessibility_settings_for_setup_wizard.xml
@@ -44,6 +44,13 @@
android:title="@string/screen_zoom_title"
android:summary="@string/screen_zoom_short_summary" />
+
+
accessibilityServices =
manager.getInstalledAccessibilityServiceList();
for (AccessibilityServiceInfo info : accessibilityServices) {
- if ((info.feedbackType & AccessibilityServiceInfo.FEEDBACK_SPOKEN) != 0) {
+ ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
+ if (packageName.equals(serviceInfo.packageName)
+ && serviceName.equals(serviceInfo.name)) {
return info;
}
}
@@ -108,28 +124,25 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
return null;
}
- private void updateScreenReaderPreference() {
- // Find a screen reader.
- AccessibilityServiceInfo info = findFirstServiceWithSpokenFeedback();
+ private void updateAccessibilityServicePreference(Preference preference,
+ AccessibilityServiceInfo info) {
if (info == null) {
- mScreenReaderPreference.setEnabled(false);
- } else {
- mScreenReaderPreference.setEnabled(true);
+ getPreferenceScreen().removePreference(preference);
+ return;
}
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
- mScreenReaderPreference.setTitle(title);
-
+ preference.setTitle(title);
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
- mScreenReaderPreference.setKey(componentName.flattenToString());
+ preference.setKey(componentName.flattenToString());
// Update the extras.
- Bundle extras = mScreenReaderPreference.getExtras();
+ Bundle extras = preference.getExtras();
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
- mScreenReaderPreference.getKey());
+ preference.getKey());
extras.putString(AccessibilitySettings.EXTRA_TITLE, title);
String description = info.loadDescription(getPackageManager());
diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
new file mode 100644
index 00000000000..2c9b58c6625
--- /dev/null
+++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 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.os.Bundle;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+
+public class ToggleSelectToSpeakPreferenceFragmentForSetupWizard
+ extends ToggleAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
+ mToggleSwitch.isChecked());
+ }
+
+ super.onStop();
+ }
+}
+
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index d7747792ba8..33484d109f1 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -50,6 +50,7 @@ com.android.settings.notification.NotificationStation
com.android.settings.print.PrintJobSettingsFragment
com.android.settings.applications.SpecialAccessSettings
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
+com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard
com.android.settings.accounts.AccountSyncSettings
com.android.settings.notification.RedactionInterstitial$RedactionInterstitialFragment
com.android.settings.inputmethod.InputMethodAndSubtypeEnabler