Merge "Add A11y SUW hub page after verifying build fix."
diff --git a/res/layout/preference_button.xml b/res/layout/preference_button.xml
new file mode 100644
index 0000000..35e4255
--- /dev/null
+++ b/res/layout/preference_button.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<!-- Layout for a ButtonPreference. -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/accessibility_button_preference_padding_top_bottom"
+    android:paddingTop="@dimen/accessibility_button_preference_padding_top_bottom"
+    android:paddingStart="@dimen/accessibility_layout_margin_start_end"
+    android:paddingEnd="@dimen/accessibility_layout_margin_start_end"
+    android:focusable="true"
+    android:selectable="false"
+    android:persistent="false" >
+
+        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:id="@+android:id/title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:selectable="true"
+            android:persistent="false"
+            android:gravity="left|center" />
+
+        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:id="@+android:id/summary"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:selectable="true"
+            android:persistent="false"
+            android:gravity="left|center" />
+
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 79655e4..f7c3437 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -266,4 +266,8 @@
 
     <!-- Display, Screen zoom -->
     <dimen name="screen_zoom_preview_height">240dp</dimen>
+
+    <!-- Accessibility Settings -->
+    <dimen name="accessibility_layout_margin_start_end">24dp</dimen>
+    <dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c8de631..5aea3f4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3623,6 +3623,8 @@
     <string name="accessibility_settings">Accessibility</string>
     <!-- Settings title for accessibility settings screen -->
     <string name="accessibility_settings_title">Accessibility settings</string>
+    <!-- Settings title for a brief version of Accessibility Settings, as displayed in Setup Wizard -->
+    <string name="accessibility_settings_for_setup_wizard_title">Guide me</string>
     <!-- Title for the accessibility preference category of accessibility services. [CHAR LIMIT=25] -->
     <string name="accessibility_services_title">Services</string>
     <!-- Title for the accessibility preference category of system related preferences. [CHAR LIMIT=25] -->
@@ -3634,7 +3636,7 @@
     <!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
     <string name="accessibility_screen_magnification_title">Magnification gestures</string>
     <!-- Summary for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=none] -->
-    <string name="accessibility_screen_magnification_summary">When this feature is turned on, you can zoom in and out by triple-tapping the screen.\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></ul>\n\nYou can also temporarily magnify what\u2019s under your finger by triple-tapping and holding. In this magnified state, you can drag your finger to explore different parts of the screen. Lift your finger to return to your previous state.\n\nNote: Triple-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 our 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] -->
     <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] -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 791f1b8..591bdad 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -16,7 +16,13 @@
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-        android:title="@string/accessibility_settings">
+        android:title="@string/accessibility_settings"
+        android:persistent="true">
+
+    <PreferenceScreen
+        android:key="accessibility_settings_for_setup_wizard"
+        android:title="@string/accessibility_settings_for_setup_wizard_title"
+        android:fragment="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
 
     <PreferenceCategory
             android:key="services_category"
diff --git a/res/xml/accessibility_settings_for_setup_wizard.xml b/res/xml/accessibility_settings_for_setup_wizard.xml
new file mode 100644
index 0000000..742b897
--- /dev/null
+++ b/res/xml/accessibility_settings_for_setup_wizard.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+        android:title="@string/accessibility_settings_title"
+        android:persistent="true" >
+
+    <Preference
+        android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
+        android:key="screen_magnification_preference"
+        android:layout="@layout/preference_button"
+        android:title="@string/accessibility_screen_magnification_title" />
+
+    <Preference
+        android:key="font_size_preference"
+        android:layout="@layout/preference_button"
+        android:title="@string/title_font_size" />
+
+    <com.android.settings.DisplayDensityPreference
+        android:key="force_density_preference"
+        android:layout="@layout/preference_button"
+        settings:keywords="@string/screen_zoom_keywords"
+        android:title="@string/screen_zoom_title"
+        android:summary="%s" />
+
+    <Preference
+        android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
+        android:key="daltonizer_preference"
+        android:layout="@layout/preference_button"
+        android:title="@string/accessibility_display_daltonizer_preference_title" />
+
+    <Preference
+        android:key="talkback_preference"
+        android:layout="@layout/preference_button" />
+
+</PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 672582d..fdf01e9 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -554,6 +554,7 @@
         }
         mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
 
+        // Text contrast.
         mToggleHighTextContrastPreference.setChecked(
                 Settings.Secure.getInt(getContentResolver(),
                         Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1);
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
new file mode 100644
index 0000000..ac12005
--- /dev/null
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2015 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 android.provider.Settings;
+import android.support.v7.preference.Preference;
+import com.android.internal.logging.MetricsLogger;
+import com.android.settings.DialogCreatable;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+/**
+ * Activity with the accessibility settings specific to Setup Wizard.
+ */
+public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragment
+        implements DialogCreatable, Preference.OnPreferenceChangeListener {
+
+    // 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 TALKBACK_NAME = "Talkback";
+
+    // Preference controls.
+    private Preference mDisplayMagnificationPreference;
+    private Preference mDisplayDaltonizerPreference;
+    private Preference mTalkbackPreference;
+
+    @Override
+    protected int getMetricsCategory() {
+        return MetricsLogger.ACCESSIBILITY;
+    }
+
+    @Override
+    protected int getHelpResource() {
+        return R.string.help_uri_accessibility;
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        addPreferencesFromResource(R.xml.accessibility_settings_for_setup_wizard);
+
+        mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE);
+        mDisplayDaltonizerPreference = findPreference(DISPLAY_DALTONIZER_PREFERENCE);
+
+        mTalkbackPreference = findPreference(TALKBACK_PREFERENCE);
+        mTalkbackPreference.setTitle(TALKBACK_NAME);
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        setHasOptionsMenu(false);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        updatePreferences();
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        return false;
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(Preference preference) {
+        if (mDisplayMagnificationPreference == preference) {
+            Bundle extras = mDisplayMagnificationPreference.getExtras();
+            extras.putString(AccessibilitySettings.EXTRA_TITLE,
+                    getString(R.string.accessibility_screen_magnification_title));
+            extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
+                    getActivity().getResources().getText(
+                    R.string.accessibility_screen_magnification_summary));
+            extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
+                    Settings.Secure.getInt(getContentResolver(),
+                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
+        }
+
+        return super.onPreferenceTreeClick(preference);
+    }
+
+    private void updatePreferences() {
+        updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
+                mDisplayMagnificationPreference);
+        updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
+                mDisplayDaltonizerPreference);
+    }
+
+    private void updateFeatureSummary(String prefKey, Preference pref) {
+        final boolean enabled = Settings.Secure.getInt(getContentResolver(), prefKey, 0) == 1;
+        pref.setSummary(enabled ? R.string.accessibility_feature_state_on
+                : R.string.accessibility_feature_state_off);
+    }
+}