UI fixes (back arrow, blue switch bar, append whether Talkback is on to

summary), Talkback no longer disabled when preference is tapped, fixes
SettingsPreferenceFragment to not check parent class to determine whether to
show options menu.

Change-Id: I3345e1a878f51b4387ca1bfe89855339617a94d6
This commit is contained in:
Anna Galusza
2016-01-29 17:32:19 -08:00
parent fe22e8998b
commit 0285c80664
8 changed files with 91 additions and 63 deletions

View File

@@ -109,6 +109,7 @@
<attr name="switchBarTheme" format="reference" /> <attr name="switchBarTheme" format="reference" />
<attr name="switchBarMarginStart" format="dimension" /> <attr name="switchBarMarginStart" format="dimension" />
<attr name="switchBarMarginEnd" format="dimension" /> <attr name="switchBarMarginEnd" format="dimension" />
<attr name="switchBarBackgroundColor" format="color" />
<attr name="preferenceBackgroundColor" format="color" /> <attr name="preferenceBackgroundColor" format="color" />

View File

@@ -3745,8 +3745,10 @@
<string name="vision_settings_description">Adjust these settings now to assist you through the remainder of the set up process. You can adjust them any time in device settings.</string> <string name="vision_settings_description">Adjust these settings now to assist you through the remainder of the set up process. You can adjust them any time in device settings.</string>
<!-- Title for the accessibility preference category of accessibility services. [CHAR LIMIT=25] --> <!-- Title for the accessibility preference category of accessibility services. [CHAR LIMIT=25] -->
<string name="accessibility_services_title">Services</string> <string name="accessibility_services_title">Services</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. [CHAR_LIMIT=none] --> <!-- Title for the Talkback Accessibility Service. Displayed on the Accessibility Settings screen in Setup Wizard. [CHAR_LIMIT=25] -->
<string name="talkback_summary">Screenreader tool primarily for people with blindness and low vision</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] -->
<string name="talkback_summary">Screenreader tool primarily for people with blindness and low vision\n<xliff:g id="service_state" example="On">%1$s</xliff:g></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] -->
@@ -3756,7 +3758,7 @@
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] --> <!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
<string name="accessibility_screen_magnification_title">Magnification gestures</string> <string name="accessibility_screen_magnification_title">Magnification gestures</string>
<!-- Summary for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=none] --> <!-- Summary for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=none] -->
<string name="accessibility_screen_magnification_summary">Zoom in and out by triple-tapping the screen with one finger.\n\nWhile zoomed in, you can:\n<ul><li>Pan: Drag two or more fingers across the screen.</li>\n<li>Adjust zoom level: Pinch two or more fingers together or spread them apart.</li>\n<li>Temporariliy magnify: Triple-tap, hold, and drag your finger to explore different parts of the screen. Lift your finger to return to our previous state.</li></ul>\n\nTriple-tap for magnification works everywhere except the keyboard and navigation bar.</string> <string name="accessibility_screen_magnification_summary">Zoom in and out by triple-tapping the screen with one finger.\n\nWhile zoomed in, you can:\n<ul><li>Pan: Drag two or more fingers across the screen.</li>\n<li>Adjust zoom level: Pinch two or more fingers together or spread them apart.</li>\n<li>Temporariliy magnify: Triple-tap, hold, and drag your finger to explore different parts of the screen. Lift your finger to return to your previous state.</li></ul>\n\nTriple-tap for magnification works everywhere except the keyboard and navigation bar.</string>
<!-- Title for the preference to enable the global geture that turns on accessibility. [CHAR LIMIT=35] --> <!-- Title for the preference to enable the global geture that turns on accessibility. [CHAR LIMIT=35] -->
<string name="accessibility_global_gesture_preference_title">Accessibility shortcut</string> <string name="accessibility_global_gesture_preference_title">Accessibility shortcut</string>
<!-- Summary for the preference to enable the global geture that turns on accessibility (on state). [CHAR LIMIT=60] --> <!-- Summary for the preference to enable the global geture that turns on accessibility (on state). [CHAR LIMIT=60] -->

View File

@@ -118,7 +118,11 @@
<item name="android:colorPrimary">@color/material_blue_700</item> <item name="android:colorPrimary">@color/material_blue_700</item>
<item name="android:colorPrimaryDark">@color/material_blue_700</item> <item name="android:colorPrimaryDark">@color/material_blue_700</item>
<item name="preferenceTheme">@style/PreferenceTheme</item> <item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item> <item name="switchBarTheme">@style/SetupWizardAccessibilitySwitchBarTheme</item>
</style>
<style name="SetupWizardAccessibilitySwitchBarTheme" parent="ThemeOverlay.SwitchBar.Settings">
<item name="switchBarBackgroundColor">@color/material_blue_500</item>
</style> </style>
<!-- Theme with no local references, used by AccountPreferenceBase where we have to inflate <!-- Theme with no local references, used by AccountPreferenceBase where we have to inflate
@@ -180,11 +184,13 @@
<style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar"> <style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar">
<item name="switchBarMarginStart">@dimen/switchbar_margin_start</item> <item name="switchBarMarginStart">@dimen/switchbar_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_margin_end</item> <item name="switchBarMarginEnd">@dimen/switchbar_margin_end</item>
<item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
</style> </style>
<style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar"> <style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar">
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item> <item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item> <item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
<item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
</style> </style>
<style name="Theme.DialogWhenLarge" parent="@*android:style/Theme.Material.Settings.DialogWhenLarge"> <style name="Theme.DialogWhenLarge" parent="@*android:style/Theme.Material.Settings.DialogWhenLarge">
@@ -237,6 +243,7 @@
<style name="ThemeOverlay.SwitchBar" parent="@android:style/ThemeOverlay"> <style name="ThemeOverlay.SwitchBar" parent="@android:style/ThemeOverlay">
<!-- Used by controls, e.g. CheckBox, ProgressBar, etc. --> <!-- Used by controls, e.g. CheckBox, ProgressBar, etc. -->
<item name="android:colorAccent">@color/switch_accent_color</item> <item name="android:colorAccent">@color/switch_accent_color</item>
<item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
</style> </style>
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings"> <style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">

View File

@@ -42,7 +42,7 @@
<Preference <Preference
android:key="talkback_preference" android:key="talkback_preference"
android:summary="@string/talkback_summary" android:title="@string/talkback_title"
android:persistent="true" /> android:persistent="true" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -52,6 +52,12 @@ import java.util.UUID;
public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceFragment public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceFragment
implements DialogCreatable { implements DialogCreatable {
/**
* The Help Uri Resource key. This can be passed as an extra argument when creating the
* Fragment.
**/
public static final String HELP_URI_RESOURCE_KEY = "help_uri_resource";
private static final String TAG = "SettingsPreference"; private static final String TAG = "SettingsPreference";
private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600; private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600;
@@ -101,7 +107,13 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
} }
// Prepare help url and enable menu if necessary // Prepare help url and enable menu if necessary
int helpResource = getHelpResource(); Bundle arguments = getArguments();
int helpResource;
if (arguments != null && arguments.containsKey(HELP_URI_RESOURCE_KEY)) {
helpResource = arguments.getInt(HELP_URI_RESOURCE_KEY);
} else {
helpResource = getHelpResource();
}
if (helpResource != 0) { if (helpResource != 0) {
mHelpUri = getResources().getString(helpResource); mHelpUri = getResources().getString(helpResource);
} }

View File

@@ -46,8 +46,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
private static final String TALKBACK_PREFERENCE = "talkback_preference"; private static final String TALKBACK_PREFERENCE = "talkback_preference";
private static final String FONT_SIZE_PREFERENCE = "font_size_preference"; private static final String FONT_SIZE_PREFERENCE = "font_size_preference";
private static final String TALKBACK_NAME = "Talkback";
// Preference controls. // Preference controls.
private Preference mDisplayMagnificationPreference; private Preference mDisplayMagnificationPreference;
private Preference mFontSizePreference; private Preference mFontSizePreference;
@@ -58,11 +56,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
return MetricsProto.MetricsEvent.ACCESSIBILITY; return MetricsProto.MetricsEvent.ACCESSIBILITY;
} }
@Override
protected int getHelpResource() {
return R.string.help_uri_accessibility;
}
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@@ -70,9 +63,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE); mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE);
mFontSizePreference = findPreference(FONT_SIZE_PREFERENCE); mFontSizePreference = findPreference(FONT_SIZE_PREFERENCE);
mTalkbackPreference = findPreference(TALKBACK_PREFERENCE); mTalkbackPreference = findPreference(TALKBACK_PREFERENCE);
mTalkbackPreference.setTitle(TALKBACK_NAME);
} }
@Override @Override
@@ -136,37 +127,36 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
extras.putString(AccessibilitySettings.EXTRA_TITLE, extras.putString(AccessibilitySettings.EXTRA_TITLE,
getString(R.string.accessibility_screen_magnification_title)); getString(R.string.accessibility_screen_magnification_title));
extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY, extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
getActivity().getResources().getText( getText(R.string.accessibility_screen_magnification_summary));
R.string.accessibility_screen_magnification_summary));
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
Settings.Secure.getInt(getContentResolver(), Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1); Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
} else if (mTalkbackPreference == preference) { } else if (mTalkbackPreference == preference) {
// Toggle Talkback. The tutorial will automatically start when Talkback is first // Enable Talkback if disabled. The tutorial will automatically start when Talkback is
// activated. // first activated.
final ContentResolver resolver = getContentResolver(); final ContentResolver resolver = getContentResolver();
final int accessibilityEnabled =
final boolean enable = Settings.Secure.getInt(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, 0);
Settings.Secure.getInt(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 0; if (accessibilityEnabled == 0) {
final String servicesToEnable = getAccessibilityServicesFiltered( final String servicesToEnable = getAccessibilityServicesFiltered(
getActivity(), AccessibilityServiceInfo.FEEDBACK_SPOKEN); getActivity(), AccessibilityServiceInfo.FEEDBACK_SPOKEN);
// Enable all accessibility services with spoken feedback type. // Enable all accessibility services with spoken feedback type.
Settings.Secure.putString(resolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, Settings.Secure.putString(resolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
enable ? servicesToEnable : ""); servicesToEnable);
// Allow the services we just enabled to toggle touch exploration. // Allow the services we just enabled to toggle touch exploration.
Settings.Secure.putString(resolver, Settings.Secure.putString(resolver,
Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
enable ? servicesToEnable : ""); servicesToEnable);
// Enable touch exploration. // Enable touch exploration.
Settings.Secure.putInt(resolver, Settings.Secure.TOUCH_EXPLORATION_ENABLED, Settings.Secure.putInt(resolver, Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1);
enable ? 1 : 0);
// Turn on accessibility mode last, since enabling accessibility with no // Turn on accessibility mode last, since enabling accessibility with no
// services has no effect. // services has no effect.
Settings.Secure.putInt(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, enable ? 1 : 0); Settings.Secure.putInt(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, 1);
}
} }
return super.onPreferenceTreeClick(preference); return super.onPreferenceTreeClick(preference);
@@ -176,6 +166,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
mDisplayMagnificationPreference); mDisplayMagnificationPreference);
updateFontSizeSummary(mFontSizePreference); updateFontSizeSummary(mFontSizePreference);
updateTalkbackSummary();
} }
private void updateFeatureSummary(String prefKey, Preference pref) { private void updateFeatureSummary(String prefKey, Preference pref) {
@@ -192,4 +183,13 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
res.getConfiguration().fontScale, strEntryValues); res.getConfiguration().fontScale, strEntryValues);
pref.setSummary(entries[index]); pref.setSummary(entries[index]);
} }
private void updateTalkbackSummary() {
final boolean enabled = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
final String enabledText = (enabled
? getString(R.string.accessibility_feature_state_on)
: getString(R.string.accessibility_feature_state_off));
mTalkbackPreference.setSummary(getString(R.string.talkback_summary, enabledText));
}
} }

View File

@@ -18,14 +18,25 @@ package com.android.settings.accessibility;
import android.app.Fragment; import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsActivity; import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity { public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
getActionBar().setDisplayHomeAsUpEnabled(true);
setIsDrawerPresent(false);
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Return true, so we get notified when items in the menu are clicked. // Return true, so we get notified when items in the menu are clicked.
@@ -41,16 +52,7 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
@Override @Override
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
CharSequence titleText, Fragment resultTo, int resultRequestCode) { CharSequence titleText, Fragment resultTo, int resultRequestCode) {
args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true); startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
} }
@Override
public void openDrawer() {
// Do nothing.
}
@Override
public void closeDrawer() {
// Do nothing.
}
} }

View File

@@ -67,8 +67,9 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners = private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners =
new ArrayList<OnSwitchChangeListener>(); new ArrayList<OnSwitchChangeListener>();
private static int[] MARGIN_ATTRIBUTES = { private static int[] XML_ATTRIBUTES = {
R.attr.switchBarMarginStart, R.attr.switchBarMarginEnd}; R.attr.switchBarMarginStart, R.attr.switchBarMarginEnd,
R.attr.switchBarBackgroundColor};
public SwitchBar(Context context) { public SwitchBar(Context context) {
this(context, null); this(context, null);
@@ -87,9 +88,10 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
LayoutInflater.from(context).inflate(R.layout.switch_bar, this); LayoutInflater.from(context).inflate(R.layout.switch_bar, this);
final TypedArray a = context.obtainStyledAttributes(attrs, MARGIN_ATTRIBUTES); final TypedArray a = context.obtainStyledAttributes(attrs, XML_ATTRIBUTES);
int switchBarMarginStart = (int) a.getDimension(0, 0); int switchBarMarginStart = (int) a.getDimension(0, 0);
int switchBarMarginEnd = (int) a.getDimension(1, 0); int switchBarMarginEnd = (int) a.getDimension(1, 0);
int switchBarBackgroundColor = (int) a.getColor(2, 0);
a.recycle(); a.recycle();
mTextView = (TextView) findViewById(R.id.switch_text); mTextView = (TextView) findViewById(R.id.switch_text);
@@ -107,6 +109,8 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
lp = (MarginLayoutParams) mSwitch.getLayoutParams(); lp = (MarginLayoutParams) mSwitch.getLayoutParams();
lp.setMarginEnd(switchBarMarginEnd); lp.setMarginEnd(switchBarMarginEnd);
setBackgroundColor(switchBarBackgroundColor);
mSwitch.setBackgroundColor(switchBarBackgroundColor);
addOnSwitchChangeListener(new OnSwitchChangeListener() { addOnSwitchChangeListener(new OnSwitchChangeListener() {
@Override @Override