Merge "USB: Toggle installer CD menu title when installer CD is enabled/disabled"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e10d8f7..c53aaf4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2726,6 +2726,8 @@
     <string name="accessibility_power_button_ends_call">Power button ends call</string>
     <!-- Accessibility settings: power button behavior summary text -->
     <string name="accessibility_power_button_ends_call_summary">During a call, pressing Power ends call instead of turning off screen</string>
+    <!-- Accessibility settings: touch exploration state -->
+    <string name="accessibility_touch_exploration_enabled">Touch exploration</string>
 
     <!-- Accessibility settings: button for lauching settings for an accessibility service -->
     <string name="settings_button">Settings</string>
@@ -3557,7 +3559,7 @@
     <string name="trusted_credentials_remove_confirmation">Permanently remove the user CA certificate?</string>
 
     <!-- Title for the touch exploration tutorial. [CHAR LIMIT=40] -->
-    <string name="accessibility_tutorial_title">Touch exploration tutorial</string>
+    <string name="accessibility_tutorial_title">Talk As I Touch tutorial</string>
     <!-- Button label to go to the next touch exploration tutorial lesson. [CHAR LIMIT=10] -->
     <string name="accessibility_tutorial_next">Next</string>
     <!-- Button label to go back to the previous touch explorationtutorial lesson. [CHAR LIMIT=10] -->
@@ -3568,31 +3570,31 @@
     <string name="accessibility_tutorial_skip">Skip tutorial</string>
 
     <!-- Title for touch exploration tutorial lesson 1. -->
-    <string name="accessibility_tutorial_lesson_1_title">Exploring the screen</string>
+    <string name="accessibility_tutorial_lesson_1_title">Lesson 1: Exploring the screen</string>
     <!-- Instruction for touch exploration tutorial lesson 1. -->
-    <string name="accessibility_tutorial_lesson_1_text_1">When touch exploration is enabled, you can touch the screen to hear spoken descriptions of the content under your finger. The screen currently contains a list of application icons. Find one of them by placing a finger on the screen and sliding it around.</string>
+    <string name="accessibility_tutorial_lesson_1_text_1">After you turn on Talk As I Touch, you can touch the screen to hear a description of what’s under your finger. For example, the current screen contains application icons. Find one of them by touching the screen and sliding your finger around.</string>
     <!-- Instruction for touch exploration tutorial lesson 1, displayed after the user touches one icon. -->
-    <string name="accessibility_tutorial_lesson_1_text_2_more">Good, keep your finger on the screen and keep sliding around to find at least one more icon.</string>
+    <string name="accessibility_tutorial_lesson_1_text_2_more">Good. Keep sliding your finger around the screen until you find at least one more icon.</string>
     <!-- Instruction for touch exploration tutorial lesson 1, displayed after the user touches a second icon. -->
-    <string name="accessibility_tutorial_lesson_1_text_3">When you\'ve found a widget that you want to click on, you can tap once to activate it. Slide your finger to find the icon for <xliff:g id="app_name" example="Browser">%s</xliff:g>.</string>
+    <string name="accessibility_tutorial_lesson_1_text_3">To activate something that you’re touching, tap it. Slide your finger until you find the icon for the <xliff:g id="app_name" example="Browser">%s</xliff:g>. Then tap the icon once to activate it.</string>
     <!-- Instruction for touch exploration tutorial lesson 1, displayed if the user touched the target area and stays inside it. -->
-    <string name="accessibility_tutorial_lesson_1_text_4">Your finger is on top of the <xliff:g id="app_name" example="Browser">%s</xliff:g> icon. Tap once to activate the icon.</string>
+    <string name="accessibility_tutorial_lesson_1_text_4">Your finger is touching the <xliff:g id="app_name" example="Browser">%s</xliff:g> icon. Tap once to activate the icon.</string>
     <!-- Instruction for touch exploration tutorial lesson 1, displayed if the user touches inside the target area but moves outside. -->
-    <string name="accessibility_tutorial_lesson_1_text_4_exited">You\'ve entered and left the <xliff:g id="app_name" example="Browser">%s</xliff:g> icon. Slowly explore again to find the icon while keeping your finger on the screen.</string>
+    <string name="accessibility_tutorial_lesson_1_text_4_exited">Your finger moved over the <xliff:g id="app_name" example="Browser">%s</xliff:g> icon, and then moved away. Slowly slide your finger around the screen until you find the Browser icon again.</string>
     <!-- Instruction for touch exploration tutorial lesson 1, displayed after the user has tapped the target icon. -->
-    <string name="accessibility_tutorial_lesson_1_text_5">Good. To move to the next section, find and activate the button labeled \"<xliff:g id="next" example="Next">%s</xliff:g>\" that\'s located near the bottom-right of the screen.</string>
+    <string name="accessibility_tutorial_lesson_1_text_5">Good. To move to the next lesson, find and activate the "<xliff:g id="next" example="Next">%s</xliff:g> button," located near the bottom-right corner of the screen.</string>
 
     <!-- Title for touch exploration tutorial lesson 2. -->
-    <string name="accessibility_tutorial_lesson_2_title">Scrolling using two fingers</string>
+    <string name="accessibility_tutorial_lesson_2_title">Lesson 2: Scrolling using two fingers</string>
     <!-- Instruction for touch exploration tutorial lesson 2. -->
-    <string name="accessibility_tutorial_lesson_2_text_1">To perform single-finger gestures like scrolling, you can place two fingers on the screen. The screen currently contains a scrollable list of application names. First, try exploring a few of the list items using one finger.</string>
+    <string name="accessibility_tutorial_lesson_2_text_1">To scroll through a list, you can slide two fingers along the screen. For example, the current screen contains a list of application names that can scroll up or down. First, try to identify a few items in the list by sliding one finger around.</string>
     <!-- Instruction for touch exploration tutorial lesson 2, displayed after the user touches one list item. -->
-    <string name="accessibility_tutorial_lesson_2_text_2_more">Good, keep sliding your finger around to find at least one more list item.</string>
+    <string name="accessibility_tutorial_lesson_2_text_2_more">Good. Keep sliding your finger around to find at least one more item.</string>
     <!-- Instruction for touch exploration tutorial lesson 2, displayed after the user touches a second list item. -->
-    <string name="accessibility_tutorial_lesson_2_text_3">Now scroll through the list by placing two fingers on a list item and sliding your fingers up. If you reach the top of the screen, you can place your fingers back on the list and continue.</string>
+    <string name="accessibility_tutorial_lesson_2_text_3">Now place two fingers on an item in the list and slide both fingers up. If you reach the top of the screen, lift your fingers, place them lower on the list, and continue sliding up.</string>
     <!-- Instruction for touch exploration tutorial lesson 2, displayed after the user scrolls a small amount. -->
-    <string name="accessibility_tutorial_lesson_2_text_3_more">Good, keep sliding your fingers up to scroll some more.</string>
+    <string name="accessibility_tutorial_lesson_2_text_3_more">Good. Keep sliding your fingers up to scroll some more.</string>
     <!-- Instruction for touch exploration tutorial lesson 2, displayed after the user has scrolled a large amount. -->
-    <string name="accessibility_tutorial_lesson_2_text_4">You have completed the touch exploration tutorial. To exit, find and click the button labeled \"<xliff:g id="finish" example="Finish">%s</xliff:g>.\"</string>
+    <string name="accessibility_tutorial_lesson_2_text_4">You have completed the tutorial. To exit and return to the Talk As I Touch setting, find and tap the <xliff:g id="finish" example="Finish">%s</xliff:g> button.</string>
 
 </resources>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 90aef84..feb5fb1 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -56,6 +56,10 @@
                 android:entries="@array/long_press_timeout_selector_titles"
                 android:entryValues="@array/long_press_timeout_selector_values"
                 android:defaultValue="@string/long_press_timeout_selector_default_value"/>
+        <CheckBoxPreference
+                android:key="touch_exploration_enabled"
+                android:title="@string/accessibility_touch_exploration_enabled"
+                android:persistent="false" />
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/src/com/android/settings/AccessibilitySettings.java b/src/com/android/settings/AccessibilitySettings.java
index 06fc5d6..a2d7d8c 100644
--- a/src/com/android/settings/AccessibilitySettings.java
+++ b/src/com/android/settings/AccessibilitySettings.java
@@ -75,6 +75,9 @@
     private static final String POWER_BUTTON_ENDS_CALL_CHECKBOX =
         "power_button_ends_call";
 
+    private static final String TOUCH_EXPLORATION_ENABLED_CHECKBOX =
+        "touch_exploration_enabled";
+
     private static final String KEY_TOGGLE_ACCESSIBILITY_SERVICE_CHECKBOX =
         "key_toggle_accessibility_service_checkbox";
 
@@ -93,6 +96,7 @@
 
     private PreferenceCategory mPowerButtonCategory;
     private CheckBoxPreference mPowerButtonEndsCallCheckBox;
+    private CheckBoxPreference mTouchExplorationEnabledCheckBox;
 
     private PreferenceGroup mAccessibilityServicesCategory;
 
@@ -128,6 +132,9 @@
         mPowerButtonEndsCallCheckBox = (CheckBoxPreference) findPreference(
                 POWER_BUTTON_ENDS_CALL_CHECKBOX);
 
+        mTouchExplorationEnabledCheckBox = (CheckBoxPreference) findPreference(
+                TOUCH_EXPLORATION_ENABLED_CHECKBOX);
+
         mLongPressTimeoutListPreference = (ListPreference) findPreference(
                 KEY_LONG_PRESS_TIMEOUT_LIST_PREFERENCE);
 
@@ -155,6 +162,10 @@
             getPreferenceScreen().removePreference(mPowerButtonCategory);
         }
 
+        boolean touchExplorationEnabled = (Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.TOUCH_EXPLORATION_REQUESTED, 0) == 1);
+        mTouchExplorationEnabledCheckBox.setChecked(touchExplorationEnabled);
+
         mLongPressTimeoutListPreference.setOnPreferenceChangeListener(this);
     }
 
@@ -296,6 +307,10 @@
                     Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
                     (isChecked ? Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP
                             : Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF));
+        } else if (TOUCH_EXPLORATION_ENABLED_CHECKBOX.equals(key)) {
+            final int touchExplorationState = ((CheckBoxPreference) preference).isChecked() ? 1 : 0;
+            Settings.Secure.putInt(getContentResolver(),
+                    Settings.Secure.TOUCH_EXPLORATION_REQUESTED, touchExplorationState);
         } else if (TOGGLE_ACCESSIBILITY_SCRIPT_INJECTION_CHECKBOX.equals(key)) {
             handleToggleAccessibilityScriptInjection((CheckBoxPreference) preference);
         } else if (preference instanceof CheckBoxPreference) {
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
old mode 100644
new mode 100755
index 1ec8ff2..1cdd41a
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
@@ -297,8 +297,8 @@
     }
 
     public void afterTextChanged(Editable s) {
-        if (s.length() > 0) {
-            mOkButton.setEnabled(true);
+        if (mOkButton != null) {
+            mOkButton.setEnabled(s.length() > 0);
         }
     }
 
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
old mode 100644
new mode 100755
index ecb7112..cee2a53
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -30,7 +30,11 @@
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
-
+import android.widget.EditText;
+import android.text.TextWatcher;
+import android.app.Dialog;
+import android.widget.Button;
+import android.text.Editable;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 
@@ -53,7 +57,7 @@
     //private static final String KEY_ALLOW_INCOMING = "allow_incoming";
 
     public static final String EXTRA_DEVICE = "device";
-
+    private RenameEditTextPreference mRenameDeviceNamePref;
     private LocalBluetoothManager mManager;
     private CachedBluetoothDevice mCachedDevice;
     private LocalBluetoothProfileManager mProfileManager;
@@ -65,7 +69,24 @@
             = new HashMap<LocalBluetoothProfile, CheckBoxPreference>();
 
     private AlertDialog mDisconnectDialog;
+    private class RenameEditTextPreference implements TextWatcher{
+        public void afterTextChanged(Editable s) {
+            Dialog d = mDeviceNamePref.getDialog();
+            if (d instanceof AlertDialog) {
+                ((AlertDialog) d).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(s.length() > 0);
+            }
+        }
 
+        // TextWatcher interface
+        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+            // not used
+        }
+
+        // TextWatcher interface
+        public void onTextChanged(CharSequence s, int start, int before, int count) {
+            // not used
+        }
+    }
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -88,7 +109,7 @@
             finish();
             return;  // TODO: test this failure path
         }
-
+        mRenameDeviceNamePref = new RenameEditTextPreference();
         mManager = LocalBluetoothManager.getInstance(getActivity());
         CachedBluetoothDeviceManager deviceManager =
                 mManager.getCachedDeviceManager();
@@ -135,8 +156,18 @@
 
         mManager.setForegroundActivity(getActivity());
         mCachedDevice.registerCallback(this);
-
+        if(mCachedDevice.getBondState() == BluetoothDevice.BOND_NONE)
+            finish();
         refresh();
+        EditText et = mDeviceNamePref.getEditText();
+        if (et != null) {
+            et.addTextChangedListener(mRenameDeviceNamePref);
+            Dialog d = mDeviceNamePref.getDialog();
+            if (d instanceof AlertDialog) {
+                Button b = ((AlertDialog) d).getButton(AlertDialog.BUTTON_POSITIVE);
+                b.setEnabled(et.getText().length() > 0);
+            }
+        }
     }
 
     @Override
@@ -171,7 +202,7 @@
         pref.setOrder(getProfilePreferenceIndex(profile.getOrdinal()));
         pref.setOnExpandClickListener(this);
 
-        int iconResource = profile.getDrawableResource(null);  // FIXME: get BT class for this?
+        int iconResource = profile.getDrawableResource(mCachedDevice.getBtClass());
         if (iconResource != 0) {
             pref.setProfileDrawable(getResources().getDrawable(iconResource));
         }