Make A11y SUW launchable from SUW and small UX changes based on last round of
UX studies. Change-Id: I9c20cd3abf910a37731da2af604f3af2cd30e942
This commit is contained in:
@@ -16,15 +16,24 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.DialogCreatable;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Activity with the accessibility settings specific to Setup Wizard.
|
||||
*/
|
||||
@@ -34,7 +43,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
// Preferences.
|
||||
private static final String DISPLAY_MAGNIFICATION_PREFERENCE =
|
||||
"screen_magnification_preference";
|
||||
private static final String DISPLAY_DALTONIZER_PREFERENCE = "daltonizer_preference";
|
||||
private static final String TALKBACK_PREFERENCE = "talkback_preference";
|
||||
private static final String FONT_SIZE_PREFERENCE = "font_size_preference";
|
||||
|
||||
@@ -42,7 +50,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
|
||||
// Preference controls.
|
||||
private Preference mDisplayMagnificationPreference;
|
||||
private Preference mDisplayDaltonizerPreference;
|
||||
private Preference mFontSizePreference;
|
||||
private Preference mTalkbackPreference;
|
||||
|
||||
@@ -62,7 +69,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
addPreferencesFromResource(R.xml.accessibility_settings_for_setup_wizard);
|
||||
|
||||
mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE);
|
||||
mDisplayDaltonizerPreference = findPreference(DISPLAY_DALTONIZER_PREFERENCE);
|
||||
mFontSizePreference = findPreference(FONT_SIZE_PREFERENCE);
|
||||
|
||||
mTalkbackPreference = findPreference(TALKBACK_PREFERENCE);
|
||||
@@ -86,6 +92,43 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a semicolon-delimited string containing a list of all the
|
||||
* installed {@link AccessibilityService}s that provide at least one
|
||||
* required feedback type.
|
||||
*
|
||||
* @param context The {@link android.app.Activity} context.
|
||||
* @param requiredFeedbackTypes An integer mask containing the required
|
||||
* feedback types.
|
||||
* @return A semicolon-delimited string containing a list of accessibility services.
|
||||
*/
|
||||
private String getAccessibilityServicesFiltered(
|
||||
Context context, int requiredFeedbackTypes) {
|
||||
final AccessibilityManager manager = context.getSystemService(AccessibilityManager.class);
|
||||
final List<AccessibilityServiceInfo> accessibilityServices = manager
|
||||
.getInstalledAccessibilityServiceList();
|
||||
final StringBuilder servicesToEnable = new StringBuilder();
|
||||
|
||||
for (AccessibilityServiceInfo accessibilityService : accessibilityServices) {
|
||||
if ((accessibilityService.feedbackType & requiredFeedbackTypes) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final ServiceInfo serviceInfo = accessibilityService.getResolveInfo().serviceInfo;
|
||||
final ComponentName componentName = new ComponentName(serviceInfo.packageName,
|
||||
serviceInfo.name);
|
||||
|
||||
servicesToEnable.append(componentName.flattenToString());
|
||||
servicesToEnable.append(':');
|
||||
}
|
||||
|
||||
if (servicesToEnable.length() > 0) {
|
||||
servicesToEnable.deleteCharAt(servicesToEnable.length() - 1);
|
||||
}
|
||||
|
||||
return servicesToEnable.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (mDisplayMagnificationPreference == preference) {
|
||||
@@ -98,6 +141,32 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
|
||||
Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
|
||||
} else if (mTalkbackPreference == preference) {
|
||||
// Toggle Talkback. The tutorial will automatically start when Talkback is first
|
||||
// activated.
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
|
||||
final boolean enable =
|
||||
Settings.Secure.getInt(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 0;
|
||||
final String servicesToEnable = getAccessibilityServicesFiltered(
|
||||
getActivity(), AccessibilityServiceInfo.FEEDBACK_SPOKEN);
|
||||
|
||||
// Enable all accessibility services with spoken feedback type.
|
||||
Settings.Secure.putString(resolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
|
||||
enable ? servicesToEnable : "");
|
||||
|
||||
// Allow the services we just enabled to toggle touch exploration.
|
||||
Settings.Secure.putString(resolver,
|
||||
Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
|
||||
enable ? servicesToEnable : "");
|
||||
|
||||
// Enable touch exploration.
|
||||
Settings.Secure.putInt(resolver, Settings.Secure.TOUCH_EXPLORATION_ENABLED,
|
||||
enable ? 1 : 0);
|
||||
|
||||
// Turn on accessibility mode last, since enabling accessibility with no
|
||||
// services has no effect.
|
||||
Settings.Secure.putInt(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, enable ? 1 : 0);
|
||||
}
|
||||
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
@@ -106,8 +175,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
private void updatePreferences() {
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
|
||||
mDisplayMagnificationPreference);
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
||||
mDisplayDaltonizerPreference);
|
||||
updateFontSizeSummary(mFontSizePreference);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user