Merge "Follow naming conventions of proguard.flags"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5e37d06..d92e14f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -125,10 +125,6 @@
                 android:value="com.android.settings.wifi.WifiSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/wireless_settings" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
-                android:resource="@string/wireless_networks_settings_title" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
-                android:value="com.android.settings.Settings$WirelessSettingsActivity" />
         </activity>
 
         <activity android:name=".wifi.WifiPickerActivity"
@@ -233,10 +229,6 @@
                 android:value="com.android.settings.bluetooth.BluetoothSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/wireless_settings" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
-                android:resource="@string/wireless_networks_settings_title" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
-                android:value="com.android.settings.Settings$WirelessSettingsActivity" />
         </activity>
 
         <activity-alias android:name=".bluetooth.AdvancedBluetoothSettings"
@@ -873,10 +865,6 @@
                 android:value="com.android.settings.DevelopmentSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/application_settings" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
-                android:resource="@string/applications_settings_header" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
-                android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
         </activity>
 
         <activity-alias android:name="DevelopmentSettings"
@@ -894,10 +882,6 @@
                 android:value="com.android.settings.DevelopmentSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/application_settings" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
-                android:resource="@string/applications_settings_header" />
-            <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
-                android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
         </activity-alias>
 
 
diff --git a/res/layout-land/choose_lock_pattern.xml b/res/layout-land/choose_lock_pattern.xml
index 9af76d1..588d8da 100644
--- a/res/layout-land/choose_lock_pattern.xml
+++ b/res/layout-land/choose_lock_pattern.xml
@@ -82,10 +82,11 @@
          android:background="@*android:drawable/code_lock_left"
          android:layout_width="2dip"
          android:layout_height="match_parent" />
+
     <!-- right side: lock pattern -->
     <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content" />
+         android:layout_width="match_parent"
+         android:layout_height="match_parent" />
 
 
 </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index 2da2b9a..8c4e912 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -56,10 +56,11 @@
          android:background="@*android:drawable/code_lock_left"
          android:layout_width="2dip"
          android:layout_height="match_parent" />
+
     <!-- right side: lock pattern -->
     <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content" />
+         android:layout_width="match_parent"
+         android:layout_height="match_parent" />
 
 
 </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/res/layout/choose_lock_pattern.xml b/res/layout/choose_lock_pattern.xml
index 79307c5..a356315 100644
--- a/res/layout/choose_lock_pattern.xml
+++ b/res/layout/choose_lock_pattern.xml
@@ -39,9 +39,10 @@
              android:background="@*android:drawable/code_lock_top"
              android:layout_width="match_parent"
              android:layout_height="2dip" />
+
         <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
-             android:layout_width="wrap_content"
-             android:layout_height="wrap_content" />
+             android:layout_width="match_parent"
+             android:layout_height="match_parent" />
 
         <!-- bottom line looks bad when button bar is their too, omit in this case -->
         <!--View
diff --git a/res/layout/choose_lock_pattern_tutorial.xml b/res/layout/choose_lock_pattern_tutorial.xml
index 39fc0a1..5f6ea56 100644
--- a/res/layout/choose_lock_pattern_tutorial.xml
+++ b/res/layout/choose_lock_pattern_tutorial.xml
@@ -54,16 +54,11 @@
 
     </ScrollView>
 
-    <!-- bottom: lock pattern -->
+    <!-- bottom: lock pattern. Note the size is match_parent in both axis since requested aspect
+         is square and the pattern view will choose the smaller of the two. -->
     <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
-         android:layout_width="300dip"
-         android:layout_height="300dip"
-         aspect="square"/>
-
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="0dip"
-        android:layout_weight="1"/>
+         android:layout_width="match_parent"
+         android:layout_height="match_parent"/>
 
     <LinearLayout
         style="@style/SecurityPreferenceButtonContainer"
diff --git a/res/layout/confirm_lock_pattern.xml b/res/layout/confirm_lock_pattern.xml
index 01ef5b1..5c6d812 100644
--- a/res/layout/confirm_lock_pattern.xml
+++ b/res/layout/confirm_lock_pattern.xml
@@ -32,9 +32,11 @@
          android:background="@*android:drawable/code_lock_top"
          android:layout_width="match_parent"
          android:layout_height="2dip" />
+
     <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content" />
+         android:layout_width="match_parent"
+         android:layout_height="match_parent" />
+
     <View
          android:background="@*android:drawable/code_lock_bottom"
          android:layout_width="match_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cc677ad..137b171 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -936,8 +936,8 @@
 
     <!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices -->
     <string name="bluetooth_preference_scan_title">Scan for devices</string>
-    <!-- Bluetooth settings: The title of the preference (list item) that finds nearby devices [CHAR LIMIT=30] -->
-    <string name="bluetooth_preference_find_nearby_title">Find nearby devices</string>
+    <!-- Bluetooth settings: The title of the action button that finds nearby devices [CHAR LIMIT=20] -->
+    <string name="bluetooth_preference_find_nearby_title">Scan</string>
     <!-- Bluetooth settings: The sub heading for device settings. [CHAR LIMIT=30] -->
     <string name="bluetooth_preference_device_settings">Device settings</string>
     <!-- Bluetooth settings: The sub heading for paired devices. [CHAR LIMIT=30] -->
@@ -2552,7 +2552,7 @@
     <string name="builtin_keyboard_settings_summary">Physical keyboard settings</string>
 
     <!-- Development Settings.  the title for the item to take the user to Development settings.  Development settings are settings meant for application developers.  -->
-    <string name="development_settings_title">Development</string>
+    <string name="development_settings_title">Developer options</string>
     <!-- Development Settings summary.  The summary of the item to take the user to Development settings.  Development settings are settings meant for application developers. -->
     <string name="development_settings_summary">Set options for application development</string>
     <!-- Setting checkbox title for Whether to enable USB debugging support on the phone. -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2e3c1d9..130fa03 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -126,13 +126,15 @@
     </style>
 
     <style name="SecurityPreferenceButtonContainer" parent="@android:style/Holo.SegmentedButton">
-        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
+        <item name="android:weightSum">2</item>
         <item name="android:dividerPadding">8dip</item>
     </style>
 
     <style name="SecurityPreferenceButton" parent="@android:style/Widget.Holo.Button.Borderless">
-        <item name="android:layout_width">140dip</item>
+        <item name="android:layout_width">0dip</item>
+        <item name="android:layout_weight">1</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="android:ellipsize">marquee</item>
         <item name="android:singleLine">true</item>
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index 492c9d1..4dfc718 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -23,7 +23,7 @@
                 android:summary="@string/system_update_settings_list_item_summary">
             <intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS" />
         </PreferenceScreen>
-        
+
         <!-- Device status - launches activity -->
         <PreferenceScreen android:key="status_info"
                 android:title="@string/device_status" 
@@ -32,13 +32,6 @@
                     android:targetPackage="com.android.settings"
                     android:targetClass="com.android.settings.deviceinfo.Status" />
         </PreferenceScreen>
-        
-        <PreferenceScreen
-                android:key="power_usage"
-                android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
-                android:title="@string/power_usage_summary_title"
-                android:summary="@string/power_usage_summary">
-        </PreferenceScreen>
 
         <!-- Legal Information -->
         <PreferenceScreen
diff --git a/res/xml/settings_headers.xml b/res/xml/settings_headers.xml
index 532bf7d..7e80db4 100644
--- a/res/xml/settings_headers.xml
+++ b/res/xml/settings_headers.xml
@@ -42,17 +42,6 @@
         android:title="@string/data_usage_summary_title"
         android:icon="@drawable/ic_settings_data_usage" />
 
-    <!-- Call settings - this is in the phone process -->
-    <header
-        android:id="@+id/call_settings"
-        android:icon="@drawable/ic_settings_call"
-        android:title="@string/call_settings_title">
-        <intent
-            android:action="android.intent.action.MAIN"
-            android:targetPackage="com.android.phone"
-            android:targetClass="com.android.phone.CallFeaturesSetting" />
-    </header>
-
     <!-- Operator hook -->
     <header
         android:fragment="com.android.settings.WirelessSettings"
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index a9002fa..41a4be5 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -63,8 +63,14 @@
             if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
                 int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
                 int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
+                int invalidCharger = intent.getIntExtra(BatteryManager.EXTRA_INVALID_CHARGER, 0);
+
                 boolean levelOk = level >= MIN_BATTERY_LEVEL;
-                boolean pluggedOk = plugged == BatteryManager.BATTERY_PLUGGED_AC;
+                boolean pluggedOk =
+                    (plugged == BatteryManager.BATTERY_PLUGGED_AC ||
+                     plugged == BatteryManager.BATTERY_PLUGGED_USB) &&
+                     invalidCharger == 0;
+
                 // Update UI elements based on power/battery status
                 mInitiateButton.setEnabled(levelOk && pluggedOk);
                 mPowerWarning.setVisibility(pluggedOk ? View.GONE : View.VISIBLE );
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index c3fe955..76f5a8e 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -40,7 +40,7 @@
 
 public class DeviceInfoSettings extends SettingsPreferenceFragment {
 
-    private static final String TAG = "DeviceInfoSettings";
+    private static final String LOG_TAG = "DeviceInfoSettings";
 
     private static final String KEY_CONTAINER = "container";
     private static final String KEY_TEAM = "team";
@@ -128,6 +128,7 @@
                 try {
                     startActivity(intent);
                 } catch (Exception e) {
+                    Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
                 }
             }
         }
@@ -142,7 +143,7 @@
             try {
                 preferenceGroup.removePreference(findPreference(preference));
             } catch (RuntimeException e) {
-                Log.d(TAG, "Property '" + property + "' missing and no '"
+                Log.d(LOG_TAG, "Property '" + property + "' missing and no '"
                         + preference + "' preference");
             }
         }
@@ -163,7 +164,7 @@
                     SystemProperties.get(property,
                             getResources().getString(R.string.device_info_default)));
         } catch (RuntimeException e) {
-
+            // No recovery
         }
     }
 
@@ -192,10 +193,10 @@
             Matcher m = p.matcher(procVersionStr);
 
             if (!m.matches()) {
-                Log.e(TAG, "Regex did not match on /proc/version: " + procVersionStr);
+                Log.e(LOG_TAG, "Regex did not match on /proc/version: " + procVersionStr);
                 return "Unavailable";
             } else if (m.groupCount() < 4) {
-                Log.e(TAG, "Regex match on /proc/version only returned " + m.groupCount()
+                Log.e(LOG_TAG, "Regex match on /proc/version only returned " + m.groupCount()
                         + " groups");
                 return "Unavailable";
             } else {
@@ -204,7 +205,7 @@
                         .append(m.group(4))).toString();
             }
         } catch (IOException e) {
-            Log.e(TAG,
+            Log.e(LOG_TAG,
                 "IO Exception when getting kernel version for Device Info screen",
                 e);
 
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index f07d965..69e6fad 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -76,12 +76,13 @@
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
+        setTheme(android.R.style.Theme_Holo_SplitActionBarWhenNarrow);
         getMetaData();
         mInLocalHeaderSwitch = true;
         super.onCreate(savedInstanceState);
         mInLocalHeaderSwitch = false;
 
-        if (isMultiPane()) {
+        if (!onIsHidingHeaders() && onIsMultiPane()) {
             highlightHeader();
             // Force the title so that it doesn't get overridden by a direct launch of
             // a specific settings screen.
@@ -107,6 +108,10 @@
                 }
             });
         }
+
+        // TODO Add support for android.R.id.home in all Setting's onOptionsItemSelected
+        // getActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP,
+        // ActionBar.DISPLAY_HOME_AS_UP);
     }
 
     @Override
@@ -193,7 +198,7 @@
 
         // If it is not launched from history, then reset to top-level
         if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0
-                && mFirstHeader != null && isMultiPane()) {
+                && mFirstHeader != null && !onIsHidingHeaders() && onIsMultiPane()) {
             switchToHeaderLocal(mFirstHeader);
         }
     }
@@ -211,7 +216,9 @@
     public Intent getIntent() {
         Intent superIntent = super.getIntent();
         String startingFragment = getStartingFragmentClass(superIntent);
-        if (startingFragment != null && !isMultiPane()) {
+        // This is called from super.onCreate, isMultiPane() is not yet reliable
+        // Do not use onIsHidingHeaders either, which relies itself on this method
+        if (startingFragment != null && !onIsMultiPane()) {
             Intent modIntent = new Intent(superIntent);
             modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
             Bundle args = superIntent.getExtras();
@@ -298,9 +305,6 @@
                     target.remove(header);
             } else if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
                 Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header);
-            } else if (id == R.id.call_settings) {
-                if (!Utils.isVoiceCapable(this))
-                    target.remove(header);
             } else if (id == R.id.wifi_settings) {
                 // Remove WiFi Settings if WiFi service is not available.
                 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java
index f7945d8..d76f08f 100644
--- a/src/com/android/settings/TextToSpeechSettings.java
+++ b/src/com/android/settings/TextToSpeechSettings.java
@@ -26,15 +26,12 @@
 import android.app.AlertDialog;
 import android.content.ActivityNotFoundException;
 import android.content.ContentResolver;
-import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceGroup;
 import android.provider.Settings;
 import android.provider.Settings.SettingNotFoundException;
 import android.speech.tts.TextToSpeech;
@@ -695,13 +692,16 @@
         mTts = new TextToSpeech(getActivity().getApplicationContext(), this, engine);
         mEnableDemo = false;
         mVoicesMissing = false;
-        updateWidgetState();
-        checkVoiceData();
 
-        // Finally, persist this value to settings.
+        // Persist this value to settings and update the UI before we check
+        // voice data because if the TTS class connected without any exception, "engine"
+        // will be the default engine irrespective of whether the voice check
+        // passes or not.
         Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
-        // .. and update the UI.
         mDefaultSynthPref.setValue(engine);
+        updateWidgetState();
+
+        checkVoiceData();
 
         Log.v(TAG, "The default synth is now: " + engine);
     }
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 9c90b20..f20ad78 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -40,9 +40,8 @@
 public final class BluetoothSettings extends DeviceListPreferenceFragment {
     private static final String TAG = "BluetoothSettings";
 
-    private static final int MENU_ID_MAKE_DISCOVERABLE = Menu.FIRST;
-    private static final int MENU_ID_SCAN = Menu.FIRST + 1;
-    private static final int MENU_ID_ADVANCED = Menu.FIRST + 2;
+    private static final int MENU_ID_SCAN = Menu.FIRST;
+    private static final int MENU_ID_ADVANCED = Menu.FIRST + 1;
 
     private BluetoothEnabler mBluetoothEnabler;
 
@@ -80,8 +79,6 @@
             activity.getActionBar().setSubtitle(mLocalAdapter.getName());
         }
 
-        // TODO activity.setTheme(android.R.style.Theme_Holo_SplitActionBarWhenNarrow);
-
         setHasOptionsMenu(true);
     }
 
@@ -104,23 +101,22 @@
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         boolean bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON;
-        menu.add(Menu.NONE, MENU_ID_MAKE_DISCOVERABLE, 0, R.string.bluetooth_visibility)
-                .setEnabled(bluetoothIsEnabled);
         menu.add(Menu.NONE, MENU_ID_SCAN, 0, R.string.bluetooth_preference_find_nearby_title)
-                .setIcon(R.drawable.ic_menu_scan_network).setEnabled(bluetoothIsEnabled);
+                //.setIcon(R.drawable.ic_menu_scan_network)
+                .setEnabled(bluetoothIsEnabled)
+                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
         menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.bluetooth_menu_advanced)
-                .setIcon(android.R.drawable.ic_menu_manage);
+                //.setIcon(android.R.drawable.ic_menu_manage)
+                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
-            case MENU_ID_MAKE_DISCOVERABLE:
                 // TODO
 //                if (mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON) {
 //                    onAddNetworkPressed();
 //                }
-                return true;
             case MENU_ID_SCAN:
                 if (mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON) {
                     mLocalAdapter.startScanning(true);
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index a829602..549e695 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -253,11 +253,16 @@
         if (!mInXlSetupWizard) {
             final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
             menu.add(Menu.NONE, MENU_ID_SCAN, 0, R.string.wifi_menu_scan)
-                    .setIcon(R.drawable.ic_menu_scan_network).setEnabled(wifiIsEnabled);
+                    //.setIcon(R.drawable.ic_menu_scan_network)
+                    .setEnabled(wifiIsEnabled)
+                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
             menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
-                    .setIcon(android.R.drawable.ic_menu_add).setEnabled(wifiIsEnabled);
+                    //.setIcon(android.R.drawable.ic_menu_add)
+                    .setEnabled(wifiIsEnabled)
+                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
             menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
-                    .setIcon(android.R.drawable.ic_menu_manage);
+                    //.setIcon(android.R.drawable.ic_menu_manage)
+                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
         }
         super.onCreateOptionsMenu(menu, inflater);
     }