Merge "Integrate Select-To-Speak in Vision Settings."
This commit is contained in:
@@ -3974,6 +3974,8 @@
|
|||||||
<string name="talkback_title">Talkback</string>
|
<string name="talkback_title">Talkback</string>
|
||||||
<!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
|
<!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
|
||||||
<string name="talkback_summary">Screen reader primarily for people with blindness and low vision</string>
|
<string name="talkback_summary">Screen reader primarily for people with blindness and low vision</string>
|
||||||
|
<!-- Summary for the Select to Speak Accessibility Service. [CHAR_LIMIT=none] -->
|
||||||
|
<string name="select_to_speak_summary">Tap items on your screen to hear them read aloud</string>
|
||||||
<!-- Title for the accessibility preference category of system related preferences. [CHAR LIMIT=25] -->
|
<!-- Title for the accessibility preference category of system related preferences. [CHAR LIMIT=25] -->
|
||||||
<string name="accessibility_system_title">System</string>
|
<string name="accessibility_system_title">System</string>
|
||||||
<!-- Title for the accessibility preference category of display related preferences. [CHAR LIMIT=25] -->
|
<!-- Title for the accessibility preference category of display related preferences. [CHAR LIMIT=25] -->
|
||||||
|
@@ -44,6 +44,13 @@
|
|||||||
android:title="@string/screen_zoom_title"
|
android:title="@string/screen_zoom_title"
|
||||||
android:summary="@string/screen_zoom_short_summary" />
|
android:summary="@string/screen_zoom_short_summary" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:fragment=
|
||||||
|
"com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard"
|
||||||
|
android:key="select_to_speak_preference"
|
||||||
|
android:summary="@string/select_to_speak_summary"
|
||||||
|
android:persistent="true" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment=
|
android:fragment=
|
||||||
"com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard"
|
"com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard"
|
||||||
|
@@ -41,11 +41,21 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
|||||||
private static final String DISPLAY_MAGNIFICATION_PREFERENCE =
|
private static final String DISPLAY_MAGNIFICATION_PREFERENCE =
|
||||||
"screen_magnification_preference";
|
"screen_magnification_preference";
|
||||||
private static final String SCREEN_READER_PREFERENCE = "screen_reader_preference";
|
private static final String SCREEN_READER_PREFERENCE = "screen_reader_preference";
|
||||||
|
private static final String SELECT_TO_SPEAK_PREFERENCE = "select_to_speak_preference";
|
||||||
private static final String FONT_SIZE_PREFERENCE = "font_size_preference";
|
private static final String FONT_SIZE_PREFERENCE = "font_size_preference";
|
||||||
|
|
||||||
|
// Package names and service names used to identify screen reader and SelectToSpeak services.
|
||||||
|
private static final String SCREEN_READER_PACKAGE_NAME = "com.google.android.marvin.talkback";
|
||||||
|
private static final String SCREEN_READER_SERVICE_NAME =
|
||||||
|
"com.google.android.marvin.talkback.TalkBackService";
|
||||||
|
private static final String SELECT_TO_SPEAK_PACKAGE_NAME = "com.google.android.marvin.talkback";
|
||||||
|
private static final String SELECT_TO_SPEAK_SERVICE_NAME =
|
||||||
|
"com.google.android.accessibility.selecttospeak.SelectToSpeakService";
|
||||||
|
|
||||||
// Preference controls.
|
// Preference controls.
|
||||||
private Preference mDisplayMagnificationPreference;
|
private Preference mDisplayMagnificationPreference;
|
||||||
private Preference mScreenReaderPreference;
|
private Preference mScreenReaderPreference;
|
||||||
|
private Preference mSelectToSpeakPreference;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -59,12 +69,16 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
|||||||
|
|
||||||
mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE);
|
mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE);
|
||||||
mScreenReaderPreference = findPreference(SCREEN_READER_PREFERENCE);
|
mScreenReaderPreference = findPreference(SCREEN_READER_PREFERENCE);
|
||||||
|
mSelectToSpeakPreference = findPreference(SELECT_TO_SPEAK_PREFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
updateScreenReaderPreference();
|
updateAccessibilityServicePreference(mScreenReaderPreference,
|
||||||
|
findService(SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME));
|
||||||
|
updateAccessibilityServicePreference(mSelectToSpeakPreference,
|
||||||
|
findService(SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,13 +108,15 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
|||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccessibilityServiceInfo findFirstServiceWithSpokenFeedback() {
|
private AccessibilityServiceInfo findService(String packageName, String serviceName) {
|
||||||
final AccessibilityManager manager =
|
final AccessibilityManager manager =
|
||||||
getActivity().getSystemService(AccessibilityManager.class);
|
getActivity().getSystemService(AccessibilityManager.class);
|
||||||
final List<AccessibilityServiceInfo> accessibilityServices =
|
final List<AccessibilityServiceInfo> accessibilityServices =
|
||||||
manager.getInstalledAccessibilityServiceList();
|
manager.getInstalledAccessibilityServiceList();
|
||||||
for (AccessibilityServiceInfo info : accessibilityServices) {
|
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;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,28 +124,25 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateScreenReaderPreference() {
|
private void updateAccessibilityServicePreference(Preference preference,
|
||||||
// Find a screen reader.
|
AccessibilityServiceInfo info) {
|
||||||
AccessibilityServiceInfo info = findFirstServiceWithSpokenFeedback();
|
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
mScreenReaderPreference.setEnabled(false);
|
getPreferenceScreen().removePreference(preference);
|
||||||
} else {
|
return;
|
||||||
mScreenReaderPreference.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
|
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
|
||||||
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
|
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
|
||||||
mScreenReaderPreference.setTitle(title);
|
preference.setTitle(title);
|
||||||
|
|
||||||
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
|
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
|
||||||
mScreenReaderPreference.setKey(componentName.flattenToString());
|
preference.setKey(componentName.flattenToString());
|
||||||
|
|
||||||
// Update the extras.
|
// Update the extras.
|
||||||
Bundle extras = mScreenReaderPreference.getExtras();
|
Bundle extras = preference.getExtras();
|
||||||
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
|
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
|
||||||
|
|
||||||
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
|
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
|
||||||
mScreenReaderPreference.getKey());
|
preference.getKey());
|
||||||
extras.putString(AccessibilitySettings.EXTRA_TITLE, title);
|
extras.putString(AccessibilitySettings.EXTRA_TITLE, title);
|
||||||
|
|
||||||
String description = info.loadDescription(getPackageManager());
|
String description = info.loadDescription(getPackageManager());
|
||||||
|
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -50,6 +50,7 @@ com.android.settings.notification.NotificationStation
|
|||||||
com.android.settings.print.PrintJobSettingsFragment
|
com.android.settings.print.PrintJobSettingsFragment
|
||||||
com.android.settings.applications.SpecialAccessSettings
|
com.android.settings.applications.SpecialAccessSettings
|
||||||
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
|
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
|
||||||
|
com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard
|
||||||
com.android.settings.accounts.AccountSyncSettings
|
com.android.settings.accounts.AccountSyncSettings
|
||||||
com.android.settings.notification.RedactionInterstitial$RedactionInterstitialFragment
|
com.android.settings.notification.RedactionInterstitial$RedactionInterstitialFragment
|
||||||
com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
|
com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
|
||||||
|
Reference in New Issue
Block a user