diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 6d314ac..1f54b17 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -16,18 +16,33 @@
 
 package com.android.settings;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.ComponentName;
+import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
+import android.os.ServiceManager;
 import android.preference.PreferenceActivity;
+import android.text.TextUtils;
 import android.util.Log;
+import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
 import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.Switch;
+import android.widget.TextView;
 
+import com.android.settings.bluetooth.BluetoothEnabler;
+import com.android.settings.wifi.WifiEnabler;
+
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -36,10 +51,11 @@
  */
 public class Settings extends PreferenceActivity implements ButtonBarHandler {
 
+    private static final String LOG_TAG = "Settings";
     private static final String META_DATA_KEY_HEADER_ID =
-            "com.android.settings.TOP_LEVEL_HEADER_ID";
+        "com.android.settings.TOP_LEVEL_HEADER_ID";
     private static final String META_DATA_KEY_FRAGMENT_CLASS =
-            "com.android.settings.FRAGMENT_CLASS";
+        "com.android.settings.FRAGMENT_CLASS";
     private static final String META_DATA_KEY_PARENT_TITLE =
         "com.android.settings.PARENT_FRAGMENT_TITLE";
     private static final String META_DATA_KEY_PARENT_FRAGMENT_CLASS =
@@ -58,6 +74,7 @@
     // TODO: Update Call Settings based on airplane mode state.
 
     protected HashMap<Integer, Integer> mHeaderIndexMap = new HashMap<Integer, Integer>();
+    private List<Header> mHeaders;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -107,6 +124,26 @@
         }
     }
 
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        ListAdapter listAdapter = getListAdapter();
+        if (listAdapter instanceof HeaderAdapter) {
+            ((HeaderAdapter) listAdapter).resume();
+        }
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+
+        ListAdapter listAdapter = getListAdapter();
+        if (listAdapter instanceof HeaderAdapter) {
+            ((HeaderAdapter) listAdapter).pause();
+        }
+    }
+
     private void switchToHeaderLocal(Header header) {
         mInLocalHeaderSwitch = true;
         switchToHeader(header);
@@ -148,7 +185,7 @@
                 mParentHeader.title = parentInfo.metaData.getString(META_DATA_KEY_PARENT_TITLE);
             }
         } catch (NameNotFoundException nnfe) {
-            Log.w("Settings", "Could not find parent activity : " + className);
+            Log.w(LOG_TAG, "Could not find parent activity : " + className);
         }
     }
 
@@ -174,21 +211,22 @@
 
     @Override
     public Intent getIntent() {
-        String startingFragment = getStartingFragmentClass(super.getIntent());
+        Intent superIntent = super.getIntent();
+        String startingFragment = getStartingFragmentClass(superIntent);
         if (startingFragment != null && !onIsMultiPane()) {
-            Intent modIntent = new Intent(super.getIntent());
+            Intent modIntent = new Intent(superIntent);
             modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
-            Bundle args = super.getIntent().getExtras();
+            Bundle args = superIntent.getExtras();
             if (args != null) {
                 args = new Bundle(args);
             } else {
                 args = new Bundle();
             }
-            args.putParcelable("intent", super.getIntent());
-            modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, super.getIntent().getExtras());
+            args.putParcelable("intent", superIntent);
+            modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras());
             return modIntent;
         }
-        return super.getIntent();
+        return superIntent;
     }
 
     /**
@@ -204,7 +242,7 @@
         if ("com.android.settings.ManageApplications".equals(intentClass)
                 || "com.android.settings.RunningServices".equals(intentClass)
                 || "com.android.settings.applications.StorageUse".equals(intentClass)) {
-            // Old name of manage apps.
+            // Old names of manage apps.
             intentClass = com.android.settings.applications.ManageApplications.class.getName();
         }
 
@@ -226,7 +264,18 @@
             mCurrentHeader = header;
             return header;
         }
-        return super.onGetInitialHeader();
+
+        // Find first non-category header
+        int position = 0;
+        while (position < mHeaders.size()) {
+            Header header = mHeaders.get(position);
+            if (HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY)
+                return header;
+            position++;
+        }
+
+        Log.e(LOG_TAG, "Unable to find a non-category header");
+        return null;
     }
 
     @Override
@@ -242,10 +291,12 @@
      * Populate the activity with the top-level headers.
      */
     @Override
-    public void onBuildHeaders(List<Header> target) {
-        loadHeadersFromResource(R.xml.settings_headers, target);
+    public void onBuildHeaders(List<Header> headers) {
+        loadHeadersFromResource(R.xml.settings_headers, headers);
 
-        updateHeaderList(target);
+        updateHeaderList(headers);
+
+        mHeaders = headers;
     }
 
     private void updateHeaderList(List<Header> target) {
@@ -262,7 +313,13 @@
             } else if (id == R.id.call_settings) {
                 if (!Utils.isVoiceCapable(this))
                     target.remove(header);
+            } else if (id == R.id.bluetooth_settings) {
+                // Remove Bluetooth Settings if Bluetooth service is not available.
+                if (ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE) == null) {
+                    target.remove(header);
+                }
             }
+
             // Increment if the current one wasn't removed by the Utils code.
             if (target.get(i) == header) {
                 // Hold on to the first header, when we need to reset to the top-level
@@ -296,6 +353,7 @@
                 }
             }
         } catch (NameNotFoundException nnfe) {
+            // No recovery
         }
     }
 
@@ -309,39 +367,197 @@
         return super.getNextButton();
     }
 
+    private static class HeaderAdapter extends ArrayAdapter<Header> {
+        static final int HEADER_TYPE_CATEGORY = 0;
+        static final int HEADER_TYPE_NORMAL = 1;
+        static final int HEADER_TYPE_SWITCH = 2;
+        private static final int HEADER_TYPE_COUNT = HEADER_TYPE_SWITCH + 1;
+
+        private final WifiEnabler mWifiEnabler;
+        private final BluetoothEnabler mBluetoothEnabler;
+
+        private static class HeaderViewHolder {
+            ImageView icon;
+            TextView title;
+            TextView summary;
+            Switch switch_;
+        }
+
+        private LayoutInflater mInflater;
+
+        static int getHeaderType(Header header) {
+            if (header.fragment == null && header.intent == null) {
+                return HEADER_TYPE_CATEGORY;
+            } else if (header.id == R.id.wifi_settings || header.id == R.id.bluetooth_settings) {
+                return HEADER_TYPE_SWITCH;
+            } else {
+                return HEADER_TYPE_NORMAL;
+            }
+        }
+
+        @Override
+        public int getItemViewType(int position) {
+            Header header = getItem(position);
+            return getHeaderType(header);
+        }
+
+        @Override
+        public boolean areAllItemsEnabled() {
+            return false; // because of categories
+        }
+
+        @Override
+        public boolean isEnabled(int position) {
+            return getItemViewType(position) != HEADER_TYPE_CATEGORY;
+        }
+
+        @Override
+        public int getViewTypeCount() {
+            return HEADER_TYPE_COUNT;
+        }
+
+        @Override
+        public boolean hasStableIds() {
+            return true;
+        }
+
+        public HeaderAdapter(Context context, List<Header> objects) {
+            super(context, 0, objects);
+            mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            
+            // These Switches are provided as placeholder until the adapter replaces these with actual
+            // Switches inflated from their layouts. Must be done before adapter is set in super
+            mWifiEnabler = new WifiEnabler(context, new Switch(context));
+            mBluetoothEnabler = new BluetoothEnabler(context, new Switch(context));
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            HeaderViewHolder holder;
+            Header header = getItem(position);
+            int headerType = getHeaderType(header);
+            View view = null;
+
+            if (convertView == null) {
+                holder = new HeaderViewHolder();
+                switch (headerType) {
+                    case HEADER_TYPE_CATEGORY:
+                        view = new TextView(getContext(), null, android.R.attr.listSeparatorTextViewStyle);
+                        holder.title = (TextView) view;
+                        break;
+
+                    case HEADER_TYPE_SWITCH:
+                        view = mInflater.inflate(R.layout.preference_header_switch_item, parent, false);
+                        holder.icon = (ImageView) view.findViewById(R.id.icon);
+                        holder.title = (TextView) view.findViewById(com.android.internal.R.id.title);
+                        holder.summary = (TextView) view.findViewById(com.android.internal.R.id.summary);
+                        holder.switch_ = (Switch) view.findViewById(R.id.switchWidget);
+                        break;
+
+                    case HEADER_TYPE_NORMAL:
+                        view = mInflater.inflate(com.android.internal.R.layout.preference_header_item, parent, false);
+                        holder.icon = (ImageView) view.findViewById(com.android.internal.R.id.icon);
+                        holder.title = (TextView) view.findViewById(com.android.internal.R.id.title);
+                        holder.summary = (TextView) view.findViewById(com.android.internal.R.id.summary);
+                        break;
+                }
+                view.setTag(holder);
+            } else {
+                view = convertView;
+                holder = (HeaderViewHolder) view.getTag();
+            }
+
+            // All view fields must be updated every time, because the view may be recycled
+            switch (headerType) {
+                case HEADER_TYPE_CATEGORY:
+                    holder.title.setText(header.getTitle(getContext().getResources()));
+                    break;
+
+                case HEADER_TYPE_SWITCH:
+                    // Would need a different treatment if the main menu had more switches
+                    if (header.id == R.id.wifi_settings) {
+                        mWifiEnabler.setSwitch(holder.switch_);
+                    } else {
+                        mBluetoothEnabler.setSwitch(holder.switch_);
+                    }
+                    // No break, fall through on purpose to update common fields
+
+                    //$FALL-THROUGH$
+                case HEADER_TYPE_NORMAL:
+                    holder.icon.setImageResource(header.iconRes);
+                    holder.title.setText(header.getTitle(getContext().getResources()));
+                    CharSequence summary = header.getSummary(getContext().getResources());
+                    if (!TextUtils.isEmpty(summary)) {
+                        holder.summary.setVisibility(View.VISIBLE);
+                        holder.summary.setText(summary);
+                    } else {
+                        holder.summary.setVisibility(View.GONE);
+                    }
+                    break;
+            }
+
+            return view;
+        }
+
+        public void resume() {
+            mWifiEnabler.resume();
+            mBluetoothEnabler.resume();
+        }
+        
+        public void pause() {
+            mWifiEnabler.pause();
+            mBluetoothEnabler.pause();
+        }
+    }
+
+    @Override
+    public void setListAdapter(ListAdapter adapter) {
+        if (mHeaders == null) {
+            mHeaders = new ArrayList<Header>();
+            // When the saved state provides the list of headers, onBuildHeaders is not called
+            // Copy the list of Headers from the adapter, preserving their order
+            for (int i = 0; i < adapter.getCount(); i++) {
+                mHeaders.add((Header) adapter.getItem(i));
+            }
+        }
+
+        // Ignore the adapter provided by PreferenceActivity and substitute ours instead
+        super.setListAdapter(new HeaderAdapter(this, mHeaders));
+    }
+
     /*
      * Settings subclasses for launching independently.
      */
 
-    public static class BluetoothSettingsActivity extends Settings { }
-    public static class WirelessSettingsActivity extends Settings { }
-    public static class TetherSettingsActivity extends Settings { }
-    public static class VpnSettingsActivity extends Settings { }
-    public static class DateTimeSettingsActivity extends Settings { }
-    public static class StorageSettingsActivity extends Settings { }
-    public static class WifiSettingsActivity extends Settings { }
-    public static class InputMethodAndLanguageSettingsActivity extends Settings { }
-    public static class InputMethodConfigActivity extends Settings { }
-    public static class InputMethodAndSubtypeEnablerActivity extends Settings { }
-    public static class LocalePickerActivity extends Settings { }
-    public static class UserDictionarySettingsActivity extends Settings { }
-    public static class SoundSettingsActivity extends Settings { }
-    public static class DisplaySettingsActivity extends Settings { }
-    public static class DeviceInfoSettingsActivity extends Settings { }
-    public static class ApplicationSettingsActivity extends Settings { }
-    public static class ManageApplicationsActivity extends Settings { }
-    public static class StorageUseActivity extends Settings { }
-    public static class DevelopmentSettingsActivity extends Settings { }
-    public static class AccessibilitySettingsActivity extends Settings { }
-    public static class SecuritySettingsActivity extends Settings { }
-    public static class PrivacySettingsActivity extends Settings { }
-    public static class DockSettingsActivity extends Settings { }
-    public static class RunningServicesActivity extends Settings { }
-    public static class ManageAccountsSettingsActivity extends Settings { }
-    public static class PowerUsageSummaryActivity extends Settings { }
-    public static class AccountSyncSettingsActivity extends Settings { }
-    public static class AccountSyncSettingsInAddAccountActivity extends Settings { }
-    public static class CryptKeeperSettingsActivity extends Settings { }
-    public static class DeviceAdminSettingsActivity extends Settings { }
-    public static class DataUsageSummaryActivity extends Settings { }
+    public static class BluetoothSettingsActivity extends Settings { /* empty */ }
+    public static class WirelessSettingsActivity extends Settings { /* empty */ }
+    public static class TetherSettingsActivity extends Settings { /* empty */ }
+    public static class VpnSettingsActivity extends Settings { /* empty */ }
+    public static class DateTimeSettingsActivity extends Settings { /* empty */ }
+    public static class StorageSettingsActivity extends Settings { /* empty */ }
+    public static class WifiSettingsActivity extends Settings { /* empty */ }
+    public static class InputMethodAndLanguageSettingsActivity extends Settings { /* empty */ }
+    public static class InputMethodConfigActivity extends Settings { /* empty */ }
+    public static class InputMethodAndSubtypeEnablerActivity extends Settings { /* empty */ }
+    public static class LocalePickerActivity extends Settings { /* empty */ }
+    public static class UserDictionarySettingsActivity extends Settings { /* empty */ }
+    public static class SoundSettingsActivity extends Settings { /* empty */ }
+    public static class DisplaySettingsActivity extends Settings { /* empty */ }
+    public static class DeviceInfoSettingsActivity extends Settings { /* empty */ }
+    public static class ApplicationSettingsActivity extends Settings { /* empty */ }
+    public static class ManageApplicationsActivity extends Settings { /* empty */ }
+    public static class StorageUseActivity extends Settings { /* empty */ }
+    public static class DevelopmentSettingsActivity extends Settings { /* empty */ }
+    public static class AccessibilitySettingsActivity extends Settings { /* empty */ }
+    public static class SecuritySettingsActivity extends Settings { /* empty */ }
+    public static class PrivacySettingsActivity extends Settings { /* empty */ }
+    public static class DockSettingsActivity extends Settings { /* empty */ }
+    public static class RunningServicesActivity extends Settings { /* empty */ }
+    public static class ManageAccountsSettingsActivity extends Settings { /* empty */ }
+    public static class PowerUsageSummaryActivity extends Settings { /* empty */ }
+    public static class AccountSyncSettingsActivity extends Settings { /* empty */ }
+    public static class AccountSyncSettingsInAddAccountActivity extends Settings { /* empty */ }
+    public static class CryptKeeperSettingsActivity extends Settings { /* empty */ }
+    public static class DeviceAdminSettingsActivity extends Settings { /* empty */ }
+    public static class DataUsageSummaryActivity extends Settings { /* empty */ }
 }
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 2844f3b..d09fcc5 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -16,35 +16,27 @@
 
 package com.android.settings;
 
-import com.android.internal.telephony.TelephonyIntents;
-import com.android.internal.telephony.TelephonyProperties;
-import com.android.settings.bluetooth.BluetoothEnabler;
-import com.android.settings.wifi.WifiEnabler;
-import com.android.settings.nfc.NfcEnabler;
-
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
-import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.content.Intent;
 import android.net.ConnectivityManager;
 import android.nfc.NfcAdapter;
 import android.os.Bundle;
-import android.os.ServiceManager;
 import android.os.SystemProperties;
 import android.preference.CheckBoxPreference;
 import android.preference.Preference;
 import android.preference.PreferenceScreen;
 import android.provider.Settings;
 
+import com.android.internal.telephony.TelephonyIntents;
+import com.android.internal.telephony.TelephonyProperties;
+import com.android.settings.nfc.NfcEnabler;
+
 public class WirelessSettings extends SettingsPreferenceFragment {
 
     private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
-    private static final String KEY_TOGGLE_BLUETOOTH = "toggle_bluetooth";
-    private static final String KEY_TOGGLE_WIFI = "toggle_wifi";
     private static final String KEY_TOGGLE_NFC = "toggle_nfc";
-    private static final String KEY_WIFI_SETTINGS = "wifi_settings";
-    private static final String KEY_BT_SETTINGS = "bt_settings";
     private static final String KEY_VPN_SETTINGS = "vpn_settings";
     private static final String KEY_TETHER_SETTINGS = "tether_settings";
     private static final String KEY_PROXY_SETTINGS = "proxy_settings";
@@ -55,9 +47,7 @@
 
     private AirplaneModeEnabler mAirplaneModeEnabler;
     private CheckBoxPreference mAirplaneModePreference;
-    private WifiEnabler mWifiEnabler;
     private NfcEnabler mNfcEnabler;
-    private BluetoothEnabler mBtEnabler;
 
     /**
      * Invoked on each preference click in this hierarchy, overrides
@@ -95,15 +85,10 @@
         addPreferencesFromResource(R.xml.wireless_settings);
 
         final Activity activity = getActivity();
-        CheckBoxPreference airplane = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
-        CheckBoxPreference wifi = (CheckBoxPreference) findPreference(KEY_TOGGLE_WIFI);
-        CheckBoxPreference bt = (CheckBoxPreference) findPreference(KEY_TOGGLE_BLUETOOTH);
+        mAirplaneModePreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
         CheckBoxPreference nfc = (CheckBoxPreference) findPreference(KEY_TOGGLE_NFC);
 
-        mAirplaneModeEnabler = new AirplaneModeEnabler(activity, airplane);
-        mAirplaneModePreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
-        mWifiEnabler = new WifiEnabler(activity, wifi);
-        mBtEnabler = new BluetoothEnabler(activity, bt);
+        mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
         mNfcEnabler = new NfcEnabler(activity, nfc);
 
         String toggleable = Settings.System.getString(activity.getContentResolver(),
@@ -111,21 +96,12 @@
 
         // Manually set dependencies for Wifi when not toggleable.
         if (toggleable == null || !toggleable.contains(Settings.System.RADIO_WIFI)) {
-            wifi.setDependency(KEY_TOGGLE_AIRPLANE);
-            findPreference(KEY_WIFI_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
             findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
         }
 
         // Manually set dependencies for Bluetooth when not toggleable.
         if (toggleable == null || !toggleable.contains(Settings.System.RADIO_BLUETOOTH)) {
-            bt.setDependency(KEY_TOGGLE_AIRPLANE);
-            findPreference(KEY_BT_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
-        }
-
-        // Remove Bluetooth Settings if Bluetooth service is not available.
-        if (ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE) == null) {
-            getPreferenceScreen().removePreference(bt);
-            getPreferenceScreen().removePreference(findPreference(KEY_BT_SETTINGS));
+            // No bluetooth-dependent items in the list. Code kept in case one is added later.
         }
 
         // Remove NFC if its not available
@@ -191,8 +167,6 @@
         super.onResume();
 
         mAirplaneModeEnabler.resume();
-        mWifiEnabler.resume();
-        mBtEnabler.resume();
         mNfcEnabler.resume();
     }
 
@@ -201,8 +175,6 @@
         super.onPause();
 
         mAirplaneModeEnabler.pause();
-        mWifiEnabler.pause();
-        mBtEnabler.pause();
         mNfcEnabler.pause();
     }
 
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothSettings.java b/src/com/android/settings/bluetooth/AdvancedBluetoothSettings.java
new file mode 100644
index 0000000..83371cd
--- /dev/null
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothSettings.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011 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.bluetooth;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+public class AdvancedBluetoothSettings extends SettingsPreferenceFragment
+        implements Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_BT_DISCOVERABLE = "bt_discoverable";
+    private static final String KEY_BT_DISCOVERABLE_TIMEOUT = "bt_discoverable_timeout";
+    private static final String KEY_BT_NAME = "bt_name";
+    private static final String KEY_BT_SHOW_RECEIVED = "bt_show_received_files";
+
+    /* Private intent to show the list of received files */
+    private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
+            "android.btopp.intent.action.OPEN_RECEIVED_FILES";
+
+    private BluetoothDiscoverableEnabler mDiscoverableEnabler;
+    private BluetoothNamePreference mNamePreference;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        addPreferencesFromResource(R.xml.bluetooth_advanced_settings);
+
+        LocalBluetoothManager localManager = LocalBluetoothManager.getInstance(getActivity());
+        if (localManager != null) {
+            LocalBluetoothAdapter localAdapter = localManager.getBluetoothAdapter();
+            mDiscoverableEnabler = new BluetoothDiscoverableEnabler(getActivity(),
+                    localAdapter,
+                    (CheckBoxPreference) findPreference(KEY_BT_DISCOVERABLE),
+                    (ListPreference) findPreference(KEY_BT_DISCOVERABLE_TIMEOUT));
+        }
+
+        mNamePreference = (BluetoothNamePreference) findPreference(KEY_BT_NAME);
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        mDiscoverableEnabler.resume();
+        mNamePreference.resume();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+
+        mNamePreference.pause();
+        mDiscoverableEnabler.pause();
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+        if (KEY_BT_SHOW_RECEIVED.equals(preference.getKey())) {
+            Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
+            getActivity().sendBroadcast(intent);
+            return true;
+        }
+
+        return super.onPreferenceTreeClick(preferenceScreen, preference);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        return true;
+    }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index 79f23bb..50149d8 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -16,28 +16,27 @@
 
 package com.android.settings.bluetooth;
 
-import com.android.settings.R;
-import com.android.settings.WirelessSettings;
-
 import android.bluetooth.BluetoothAdapter;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.preference.Preference;
-import android.preference.CheckBoxPreference;
 import android.provider.Settings;
+import android.widget.CompoundButton;
+import android.widget.Switch;
 import android.widget.Toast;
 
+import com.android.settings.R;
+import com.android.settings.WirelessSettings;
+
 /**
  * BluetoothEnabler is a helper to manage the Bluetooth on/off checkbox
  * preference. It turns on/off Bluetooth and ensures the summary of the
  * preference reflects the current state.
  */
-public final class BluetoothEnabler implements Preference.OnPreferenceChangeListener {
+public final class BluetoothEnabler implements CompoundButton.OnCheckedChangeListener {
     private final Context mContext;
-    private final CheckBoxPreference mCheckBox;
-    private final CharSequence mOriginalSummary;
+    private Switch mSwitch;
 
     private final LocalBluetoothAdapter mLocalAdapter;
     private final IntentFilter mIntentFilter;
@@ -50,17 +49,15 @@
         }
     };
 
-    public BluetoothEnabler(Context context, CheckBoxPreference checkBox) {
+    public BluetoothEnabler(Context context, Switch switch_) {
         mContext = context;
-        mCheckBox = checkBox;
-        mOriginalSummary = checkBox.getSummary();
-        checkBox.setPersistent(false);
+        mSwitch = switch_;
 
         LocalBluetoothManager manager = LocalBluetoothManager.getInstance(context);
         if (manager == null) {
             // Bluetooth is not supported
             mLocalAdapter = null;
-            checkBox.setEnabled(false);
+            mSwitch.setEnabled(false);
         } else {
             mLocalAdapter = manager.getBluetoothAdapter();
         }
@@ -76,7 +73,7 @@
         handleStateChanged(mLocalAdapter.getBluetoothState());
 
         mContext.registerReceiver(mReceiver, mIntentFilter);
-        mCheckBox.setOnPreferenceChangeListener(this);
+        mSwitch.setOnCheckedChangeListener(this);
     }
 
     public void pause() {
@@ -85,51 +82,54 @@
         }
 
         mContext.unregisterReceiver(mReceiver);
-        mCheckBox.setOnPreferenceChangeListener(null);
+        mSwitch.setOnCheckedChangeListener(null);
     }
 
-    public boolean onPreferenceChange(Preference preference, Object value) {
-        boolean enable = (Boolean) value;
+    public void setSwitch(Switch switch_) {
+        if (mSwitch == switch_) return;
+        mSwitch.setOnCheckedChangeListener(null);
+        mSwitch = switch_;
+        mSwitch.setOnCheckedChangeListener(this);
 
+        final int bluetoothState = mLocalAdapter.getBluetoothState();
+        boolean isEnabled = bluetoothState == BluetoothAdapter.STATE_ON;
+        boolean isDisabled = bluetoothState == BluetoothAdapter.STATE_OFF;
+        mSwitch.setChecked(isEnabled);
+        mSwitch.setEnabled(isEnabled || isDisabled);
+    }
+
+    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
         // Show toast message if Bluetooth is not allowed in airplane mode
-        if (enable && !WirelessSettings
-                .isRadioAllowed(mContext, Settings.System.RADIO_BLUETOOTH)) {
-            Toast.makeText(mContext, R.string.wifi_in_airplane_mode,
-                    Toast.LENGTH_SHORT).show();
-            return false;
+        if (isChecked &&
+                !WirelessSettings.isRadioAllowed(mContext, Settings.System.RADIO_BLUETOOTH)) {
+            Toast.makeText(mContext, R.string.wifi_in_airplane_mode, Toast.LENGTH_SHORT).show();
+            // Reset switch to off
+            buttonView.setChecked(false);
         }
 
-        mLocalAdapter.setBluetoothEnabled(enable);
-        mCheckBox.setEnabled(false);
-
-        // Don't update UI to opposite state until we're sure
-        return false;
+        mLocalAdapter.setBluetoothEnabled(isChecked);
+        mSwitch.setEnabled(false);
     }
 
     void handleStateChanged(int state) {
         switch (state) {
             case BluetoothAdapter.STATE_TURNING_ON:
-                mCheckBox.setSummary(R.string.wifi_starting);
-                mCheckBox.setEnabled(false);
+                mSwitch.setEnabled(false);
                 break;
             case BluetoothAdapter.STATE_ON:
-                mCheckBox.setChecked(true);
-                mCheckBox.setSummary(null);
-                mCheckBox.setEnabled(true);
+                mSwitch.setChecked(true);
+                mSwitch.setEnabled(true);
                 break;
             case BluetoothAdapter.STATE_TURNING_OFF:
-                mCheckBox.setSummary(R.string.wifi_stopping);
-                mCheckBox.setEnabled(false);
+                mSwitch.setEnabled(false);
                 break;
             case BluetoothAdapter.STATE_OFF:
-                mCheckBox.setChecked(false);
-                mCheckBox.setSummary(mOriginalSummary);
-                mCheckBox.setEnabled(true);
+                mSwitch.setChecked(false);
+                mSwitch.setEnabled(true);
                 break;
             default:
-                mCheckBox.setChecked(false);
-                mCheckBox.setSummary(R.string.wifi_error);
-                mCheckBox.setEnabled(true);
+                mSwitch.setChecked(false);
+                mSwitch.setEnabled(true);
         }
     }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 5e4e130..9c90b20 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -16,15 +16,20 @@
 
 package com.android.settings.bluetooth;
 
+import android.app.ActionBar;
+import android.app.Activity;
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
-import android.content.Intent;
-import android.preference.CheckBoxPreference;
-import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
 import android.util.Log;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
+import android.widget.Switch;
 
 import com.android.settings.R;
 
@@ -35,77 +40,120 @@
 public final class BluetoothSettings extends DeviceListPreferenceFragment {
     private static final String TAG = "BluetoothSettings";
 
-    private static final String KEY_BT_CHECKBOX = "bt_checkbox";
-    private static final String KEY_BT_DISCOVERABLE = "bt_discoverable";
-    private static final String KEY_BT_DISCOVERABLE_TIMEOUT = "bt_discoverable_timeout";
-    private static final String KEY_BT_NAME = "bt_name";
-    private static final String KEY_BT_SHOW_RECEIVED = "bt_show_received_files";
+    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 BluetoothEnabler mEnabler;
-    private BluetoothDiscoverableEnabler mDiscoverableEnabler;
-    private BluetoothNamePreference mNamePreference;
-
-    /* Private intent to show the list of received files */
-    private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
-            "android.btopp.intent.action.OPEN_RECEIVED_FILES";
+    private BluetoothEnabler mBluetoothEnabler;
 
     /** Initialize the filter to show bonded devices only. */
-    public BluetoothSettings() {
-        super(BluetoothDeviceFilter.BONDED_DEVICE_FILTER);
-    }
+    //public BluetoothSettings() {
+    //    super(BluetoothDeviceFilter.BONDED_DEVICE_FILTER);
+    //}
 
     @Override
     void addPreferencesForActivity() {
         addPreferencesFromResource(R.xml.bluetooth_settings);
 
-        mEnabler = new BluetoothEnabler(getActivity(),
-                (CheckBoxPreference) findPreference(KEY_BT_CHECKBOX));
+        Activity activity = getActivity();
 
-        mDiscoverableEnabler = new BluetoothDiscoverableEnabler(getActivity(),
-                mLocalAdapter,
-                (CheckBoxPreference) findPreference(KEY_BT_DISCOVERABLE),
-                    (ListPreference) findPreference(KEY_BT_DISCOVERABLE_TIMEOUT));
+        Switch actionBarSwitch = new Switch(activity);
 
-        mNamePreference = (BluetoothNamePreference) findPreference(KEY_BT_NAME);
+        if (activity instanceof PreferenceActivity) {
+            PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+            if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
+                final int padding = activity.getResources().getDimensionPixelSize(
+                        R.dimen.action_bar_switch_padding);
+                actionBarSwitch.setPadding(0, 0, padding, 0);
+                activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+                        ActionBar.DISPLAY_SHOW_CUSTOM);
+                activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
+                        ActionBar.LayoutParams.WRAP_CONTENT,
+                        ActionBar.LayoutParams.WRAP_CONTENT,
+                        Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+            }
+        }
+
+        mBluetoothEnabler = new BluetoothEnabler(activity, actionBarSwitch);
+
+        if (mLocalAdapter != null && mLocalAdapter.isEnabled()) {
+            activity.getActionBar().setSubtitle(mLocalAdapter.getName());
+        }
+
+        // TODO activity.setTheme(android.R.style.Theme_Holo_SplitActionBarWhenNarrow);
+
+        setHasOptionsMenu(true);
     }
 
     @Override
     public void onResume() {
         super.onResume();
 
-        // Repopulate (which isn't too bad since it's cached in the settings
-        // bluetooth manager)
-        addDevices();
+        mBluetoothEnabler.resume();
 
-        mEnabler.resume();
-        mDiscoverableEnabler.resume();
-        mNamePreference.resume();
+        updateContent(mLocalAdapter.getBluetoothState());
     }
 
     @Override
     public void onPause() {
         super.onPause();
 
-        mNamePreference.pause();
-        mDiscoverableEnabler.pause();
-        mEnabler.pause();
+        mBluetoothEnabler.pause();
+    }
+
+    @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);
+        menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.bluetooth_menu_advanced)
+                .setIcon(android.R.drawable.ic_menu_manage);
+    }
+
+    @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);
+                }
+                return true;
+            case MENU_ID_ADVANCED:
+                if (getActivity() instanceof PreferenceActivity) {
+                    ((PreferenceActivity) getActivity()).startPreferencePanel(
+                            AdvancedBluetoothSettings.class.getCanonicalName(),
+                            null,
+                            R.string.bluetooth_advanced_titlebar, null,
+                            this, 0);
+                } else {
+                    startFragment(this, AdvancedBluetoothSettings.class.getCanonicalName(), -1, null);
+                }
+                return true;
+        }
+        return super.onOptionsItemSelected(item);
     }
 
     private final View.OnClickListener mListener = new View.OnClickListener() {
         public void onClick(View v) {
             // User clicked on advanced options icon for a device in the list
             if (v.getTag() instanceof CachedBluetoothDevice) {
-                CachedBluetoothDevice
-                        device = (CachedBluetoothDevice) v.getTag();
+                CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
 
                 Preference pref = new Preference(getActivity());
                 pref.setTitle(device.getName());
                 pref.setFragment(DeviceProfilesSettings.class.getName());
                 pref.getExtras().putParcelable(DeviceProfilesSettings.EXTRA_DEVICE,
                         device.getDevice());
-                ((PreferenceActivity) getActivity())
-                        .onPreferenceStartFragment(BluetoothSettings.this,
-                                pref);
+                ((PreferenceActivity) getActivity()).onPreferenceStartFragment(
+                        BluetoothSettings.this, pref);
             } else {
                 Log.w(TAG, "onClick() called for other View: " + v);
             }
@@ -113,19 +161,54 @@
     };
 
     @Override
-    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
-            Preference preference) {
-        if (KEY_BT_SHOW_RECEIVED.equals(preference.getKey())) {
-            Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
-            getActivity().sendBroadcast(intent);
-            return true;
-        }
-
-        return super.onPreferenceTreeClick(preferenceScreen, preference);
+    void onDevicePreferenceClick(BluetoothDevicePreference btPreference) {
+        mLocalAdapter.stopScanning();
+        super.onDevicePreferenceClick(btPreference);
     }
 
-    public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice,
-            int bondState) {
+    @Override
+    public void onBluetoothStateChanged(int bluetoothState) {
+        super.onBluetoothStateChanged(bluetoothState);
+        updateContent(bluetoothState);
+    }
+
+    private void updateContent(int bluetoothState) {
+        final PreferenceScreen preferenceScreen = getPreferenceScreen();
+        getActivity().invalidateOptionsMenu();
+        int messageId = 0;
+
+        switch (bluetoothState) {
+            case BluetoothAdapter.STATE_ON:
+                preferenceScreen.removeAll();
+                // Repopulate (which isn't too bad since it's cached in the settings bluetooth manager)
+                addDevices();
+                mLocalAdapter.startScanning(false);
+                return;
+
+            case BluetoothAdapter.STATE_TURNING_OFF:
+                int preferenceCount = preferenceScreen.getPreferenceCount();
+                for (int i = 0; i < preferenceCount; i++) {
+                    preferenceScreen.getPreference(i).setEnabled(false);
+                }
+                return;
+
+            case BluetoothAdapter.STATE_OFF:
+                messageId = R.string.bluetooth_empty_list_bluetooth_off;
+                break;
+
+            case BluetoothAdapter.STATE_TURNING_ON:
+                messageId = R.string.bluetooth_turning_on;
+                break;
+        }
+
+        removeAllDevices();
+        // TODO: from xml, add top padding. Same as in wifi
+        Preference emptyListPreference = new Preference(getActivity());
+        emptyListPreference.setTitle(messageId);
+        preferenceScreen.addPreference(emptyListPreference);
+    }
+
+    public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
         if (bondState == BluetoothDevice.BOND_BONDED) {
             // add to "Paired devices" list after remote-initiated pairing
             if (mDevicePreferenceMap.get(cachedDevice) == null) {
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index a978e23..409edb9 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -21,6 +21,7 @@
 import android.os.Bundle;
 import android.preference.Preference;
 import android.preference.PreferenceCategory;
+import android.preference.PreferenceGroup;
 import android.preference.PreferenceScreen;
 import android.util.Log;
 
@@ -36,7 +37,6 @@
  *
  * @see BluetoothSettings
  * @see DevicePickerFragment
- * @see BluetoothFindNearby
  */
 public abstract class DeviceListPreferenceFragment extends
         SettingsPreferenceFragment implements BluetoothCallback {
@@ -53,7 +53,7 @@
     LocalBluetoothAdapter mLocalAdapter;
     LocalBluetoothManager mLocalManager;
 
-    private PreferenceCategory mDeviceList;
+    private PreferenceGroup mDeviceListGroup;
 
     final WeakHashMap<CachedBluetoothDevice, BluetoothDevicePreference> mDevicePreferenceMap =
             new WeakHashMap<CachedBluetoothDevice, BluetoothDevicePreference>();
@@ -83,8 +83,13 @@
 
         addPreferencesForActivity();
 
-        mDeviceList = (PreferenceCategory) findPreference(KEY_BT_DEVICE_LIST);
-        if (mDeviceList == null) {
+        mDeviceListGroup = (PreferenceCategory) findPreference(KEY_BT_DEVICE_LIST);
+        if (mDeviceListGroup == null) {
+            // If null, device preferences are added directly to the root of the preference screen
+            mDeviceListGroup = getPreferenceScreen();
+            mDeviceListGroup.setOrderingAsAdded(false);
+        }
+        if (mDeviceListGroup == null) {
             Log.e(TAG, "Could not find device list preference object!");
         }
     }
@@ -105,13 +110,15 @@
     @Override
     public void onPause() {
         super.onPause();
-
-        mLocalAdapter.stopScanning();
+        removeAllDevices();
         mLocalManager.setForegroundActivity(null);
         mLocalManager.getEventManager().unregisterCallback(this);
+    }
 
+    void removeAllDevices() {
+        mLocalAdapter.stopScanning();
         mDevicePreferenceMap.clear();
-        mDeviceList.removeAll();
+        mDeviceListGroup.removeAll();
     }
 
     void addDevices() {
@@ -132,7 +139,7 @@
         }
 
         if (preference instanceof BluetoothDevicePreference) {
-            BluetoothDevicePreference btPreference = (BluetoothDevicePreference)preference;
+            BluetoothDevicePreference btPreference = (BluetoothDevicePreference) preference;
             CachedBluetoothDevice device = btPreference.getCachedDevice();
             mSelectedDevice = device.getDevice();
             onDevicePreferenceClick(btPreference);
@@ -152,6 +159,9 @@
             return;
         }
 
+        // No update while list shows state message
+        if (mLocalAdapter.getBluetoothState() != BluetoothAdapter.STATE_ON) return;
+
         if (mFilter.matches(cachedDevice.getDevice())) {
             createDevicePreference(cachedDevice);
         }
@@ -162,7 +172,7 @@
                 getActivity(), cachedDevice);
 
         initDevicePreference(preference);
-        mDeviceList.addPreference(preference);
+        mDeviceListGroup.addPreference(preference);
         mDevicePreferenceMap.put(cachedDevice, preference);
     }
 
@@ -170,13 +180,14 @@
      * Overridden in {@link BluetoothSettings} to add a listener.
      * @param preference the newly added preference
      */
-    void initDevicePreference(BluetoothDevicePreference preference) { }
+    void initDevicePreference(BluetoothDevicePreference preference) {
+        // Does nothing by default
+    }
 
     public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) {
-        BluetoothDevicePreference preference = mDevicePreferenceMap.remove(
-                cachedDevice);
+        BluetoothDevicePreference preference = mDevicePreferenceMap.remove(cachedDevice);
         if (preference != null) {
-            mDeviceList.removePreference(preference);
+            mDeviceListGroup.removePreference(preference);
         }
     }
 
@@ -185,9 +196,10 @@
     }
 
     private void updateProgressUi(boolean start) {
-        if (mDeviceList instanceof ProgressCategory) {
-            ((ProgressCategory) mDeviceList).setProgress(start);
+        if (mDeviceListGroup instanceof ProgressCategory) {
+            ((ProgressCategory) mDeviceListGroup).setProgress(start);
         }
+        // else TODO Add a spinner at the end of the list to show in progress state
     }
 
     public void onBluetoothStateChanged(int bluetoothState) {
diff --git a/src/com/android/settings/bluetooth/DevicePickerFragment.java b/src/com/android/settings/bluetooth/DevicePickerFragment.java
index 126df02..3aeb7e2 100644
--- a/src/com/android/settings/bluetooth/DevicePickerFragment.java
+++ b/src/com/android/settings/bluetooth/DevicePickerFragment.java
@@ -89,7 +89,7 @@
         super.onBluetoothStateChanged(bluetoothState);
 
         if (bluetoothState == BluetoothAdapter.STATE_ON) {
-                mLocalAdapter.startScanning(false);
+            mLocalAdapter.startScanning(false);
         }
     }
 
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index 9db4baf..ecb7112 100644
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -50,7 +50,7 @@
     private static final String KEY_RENAME_DEVICE = "rename_device";
     private static final String KEY_PROFILE_CONTAINER = "profile_container";
     private static final String KEY_UNPAIR = "unpair";
-    private static final String KEY_ALLOW_INCOMING = "allow_incoming";
+    //private static final String KEY_ALLOW_INCOMING = "allow_incoming";
 
     public static final String EXTRA_DEVICE = "device";
 
@@ -355,6 +355,7 @@
         mCachedDevice.unpair();
     }
 
+    /*
     private void setIncomingFileTransfersAllowed(boolean allow) {
         // TODO: make an IPC call into BluetoothOpp to update
         Log.d(TAG, "Set allow incoming = " + allow);
@@ -364,6 +365,7 @@
         // TODO: get this value from BluetoothOpp ???
         return true;
     }
+    */
 
     private boolean getAutoConnect(LocalBluetoothProfile prof) {
         return prof.isPreferred(mCachedDevice.getDevice());
diff --git a/src/com/android/settings/wifi/AdvancedSettings.java b/src/com/android/settings/wifi/AdvancedSettings.java
index faea9f2..4855c99 100644
--- a/src/com/android/settings/wifi/AdvancedSettings.java
+++ b/src/com/android/settings/wifi/AdvancedSettings.java
@@ -16,21 +16,23 @@
 
 package com.android.settings.wifi;
 
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
-
-import android.app.Activity;
 import android.content.Context;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.Bundle;
-import android.os.SystemProperties;
+import android.preference.CheckBoxPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
+import android.preference.PreferenceScreen;
+import android.provider.Settings;
+import android.provider.Settings.Secure;
 import android.text.TextUtils;
-import android.widget.Toast;
 import android.util.Log;
+import android.widget.Toast;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
 
 public class AdvancedSettings extends SettingsPreferenceFragment
         implements Preference.OnPreferenceChangeListener {
@@ -39,6 +41,8 @@
     private static final String KEY_MAC_ADDRESS = "mac_address";
     private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address";
     private static final String KEY_FREQUENCY_BAND = "frequency_band";
+    private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks";
+    private static final String KEY_SLEEP_POLICY = "sleep_policy";
 
     private WifiManager mWifiManager;
 
@@ -62,27 +66,61 @@
     }
 
     private void initPreferences() {
+        CheckBoxPreference notifyOpenNetworks =
+                (CheckBoxPreference) findPreference(KEY_NOTIFY_OPEN_NETWORKS);
+        notifyOpenNetworks.setChecked(Secure.getInt(getContentResolver(),
+                Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
+        notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
 
-        ListPreference pref = (ListPreference) findPreference(KEY_FREQUENCY_BAND);
+        ListPreference frequencyPref = (ListPreference) findPreference(KEY_FREQUENCY_BAND);
 
         if (mWifiManager.isDualBandSupported()) {
-            pref.setOnPreferenceChangeListener(this);
+            frequencyPref.setOnPreferenceChangeListener(this);
             int value = mWifiManager.getFrequencyBand();
             if (value != -1) {
-                pref.setValue(String.valueOf(value));
+                frequencyPref.setValue(String.valueOf(value));
             } else {
                 Log.e(TAG, "Failed to fetch frequency band");
             }
         } else {
-            getPreferenceScreen().removePreference(pref);
+            if (frequencyPref != null) {
+                // null if it has already been removed before resume
+                getPreferenceScreen().removePreference(frequencyPref);
+            }
         }
+
+        ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
+        if (sleepPolicyPref != null) {
+            if (Utils.isWifiOnly()) {
+                sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
+                sleepPolicyPref.setSummary(R.string.wifi_setting_sleep_policy_summary_wifi_only);
+            }
+            sleepPolicyPref.setOnPreferenceChangeListener(this);
+            int value = Settings.System.getInt(getContentResolver(),
+                    Settings.System.WIFI_SLEEP_POLICY,
+                    Settings.System.WIFI_SLEEP_POLICY_NEVER);
+            sleepPolicyPref.setValue(String.valueOf(value));
+        }
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
+        String key = preference.getKey();
+
+        if (KEY_NOTIFY_OPEN_NETWORKS.equals(key)) {
+            Secure.putInt(getContentResolver(),
+                    Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
+                    ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
+        } else {
+            return super.onPreferenceTreeClick(screen, preference);
+        }
+        return true;
     }
 
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         String key = preference.getKey();
-        if (key == null) return true;
 
-        if (key.equals(KEY_FREQUENCY_BAND)) {
+        if (KEY_FREQUENCY_BAND.equals(key)) {
             try {
                 mWifiManager.setFrequencyBand(Integer.parseInt(((String) newValue)), true);
             } catch (NumberFormatException e) {
@@ -92,6 +130,17 @@
             }
         }
 
+        if (KEY_SLEEP_POLICY.equals(key)) {
+            try {
+                Settings.System.putInt(getContentResolver(),
+                        Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
+            } catch (NumberFormatException e) {
+                Toast.makeText(getActivity(), R.string.wifi_setting_sleep_policy_error,
+                        Toast.LENGTH_SHORT).show();
+                return false;
+            }
+        }
+
         return true;
     }
 
diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java
new file mode 100644
index 0000000..1da8b68
--- /dev/null
+++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2011 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.wifi;
+
+import android.content.Context;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.text.TextUtils;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
+
+public class AdvancedWifiSettings extends SettingsPreferenceFragment
+        implements Preference.OnPreferenceChangeListener {
+
+    private static final String TAG = "AdvancedWifiSettings";
+    private static final String KEY_MAC_ADDRESS = "mac_address";
+    private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address";
+    private static final String KEY_FREQUENCY_BAND = "frequency_band";
+
+    private WifiManager mWifiManager;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        addPreferencesFromResource(R.xml.wifi_advanced_settings);
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        initPreferences();
+        refreshWifiInfo();
+    }
+
+    private void initPreferences() {
+
+        ListPreference pref = (ListPreference) findPreference(KEY_FREQUENCY_BAND);
+
+        if (mWifiManager.isDualBandSupported()) {
+            pref.setOnPreferenceChangeListener(this);
+            int value = mWifiManager.getFrequencyBand();
+            if (value != -1) {
+                pref.setValue(String.valueOf(value));
+            } else {
+                Log.e(TAG, "Failed to fetch frequency band");
+            }
+        } else {
+            getPreferenceScreen().removePreference(pref);
+        }
+    }
+
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        String key = preference.getKey();
+        if (key == null) return true;
+
+        if (key.equals(KEY_FREQUENCY_BAND)) {
+            try {
+                mWifiManager.setFrequencyBand(Integer.parseInt(((String) newValue)), true);
+            } catch (NumberFormatException e) {
+                Toast.makeText(getActivity(), R.string.wifi_setting_frequency_band_error,
+                        Toast.LENGTH_SHORT).show();
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    private void refreshWifiInfo() {
+        WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
+
+        Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
+        String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
+        wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
+                : getActivity().getString(R.string.status_unavailable));
+
+        Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);
+        String ipAddress = Utils.getWifiIpAddresses(getActivity());
+        wifiIpAddressPref.setSummary(ipAddress == null ?
+                getActivity().getString(R.string.status_unavailable) : ipAddress);
+    }
+
+}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 91f4110..a8ce94f 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -16,33 +16,29 @@
 
 package com.android.settings.wifi;
 
+import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
+
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.res.Resources;
-import android.net.DhcpInfo;
 import android.net.LinkAddress;
 import android.net.LinkProperties;
 import android.net.NetworkInfo.DetailedState;
 import android.net.NetworkUtils;
-import android.net.Proxy;
 import android.net.ProxyProperties;
 import android.net.RouteInfo;
 import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiConfiguration.IpAssignment;
 import android.net.wifi.WifiConfiguration.AuthAlgorithm;
+import android.net.wifi.WifiConfiguration.IpAssignment;
 import android.net.wifi.WifiConfiguration.KeyMgmt;
-import android.net.wifi.WpsConfiguration;
-import android.net.wifi.WpsConfiguration.Setup;
-
-import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
 import android.net.wifi.WifiConfiguration.ProxySettings;
 import android.net.wifi.WifiInfo;
+import android.net.wifi.WpsConfiguration;
+import android.net.wifi.WpsConfiguration.Setup;
 import android.security.Credentials;
 import android.security.KeyStore;
 import android.text.Editable;
 import android.text.InputType;
 import android.text.TextWatcher;
-import android.text.format.Formatter;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
@@ -57,12 +53,10 @@
 import com.android.settings.R;
 
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
 import java.util.Iterator;
 
 /**
- * The class for allowing UIs like {@link WifiDialog} and {@link WifiConfigPreference} to
+ * The class for allowing UIs like {@link WifiDialog} and {@link WifiConfigUiBase} to
  * share the logic for controlling buttons, text fields, etc.
  */
 public class WifiConfigController implements TextWatcher,
@@ -429,7 +423,9 @@
         int networkPrefixLength = -1;
         try {
             networkPrefixLength = Integer.parseInt(mNetworkPrefixLengthView.getText().toString());
-        } catch (NumberFormatException e) { }
+        } catch (NumberFormatException e) {
+            // Use -1
+        }
         if (networkPrefixLength < 0 || networkPrefixLength > 32) {
             return R.string.wifi_ip_settings_invalid_network_prefix_length;
         }
@@ -698,6 +694,7 @@
 
     private void setSelection(Spinner spinner, String value) {
         if (value != null) {
+            @SuppressWarnings("unchecked")
             ArrayAdapter<String> adapter = (ArrayAdapter<String>) spinner.getAdapter();
             for (int i = adapter.getCount() - 1; i >= 0; --i) {
                 if (value.equals(adapter.getItem(i))) {
@@ -719,10 +716,12 @@
 
     @Override
     public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+        // work done in afterTextChanged
     }
 
     @Override
     public void onTextChanged(CharSequence s, int start, int before, int count) {
+        // work done in afterTextChanged
     }
 
     @Override
@@ -750,5 +749,6 @@
 
     @Override
     public void onNothingSelected(AdapterView<?> parent) {
+        //
     }
 }
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 7f1221e..223022d 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -16,9 +16,6 @@
 
 package com.android.settings.wifi;
 
-import com.android.settings.R;
-import com.android.settings.WirelessSettings;
-
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -27,19 +24,19 @@
 import android.net.wifi.SupplicantState;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
-import android.preference.Preference;
-import android.preference.CheckBoxPreference;
 import android.provider.Settings;
-import android.text.TextUtils;
+import android.widget.CompoundButton;
+import android.widget.Switch;
 import android.widget.Toast;
 
+import com.android.settings.R;
+import com.android.settings.WirelessSettings;
+
 import java.util.concurrent.atomic.AtomicBoolean;
 
-public class WifiEnabler implements Preference.OnPreferenceChangeListener {
+public class WifiEnabler implements CompoundButton.OnCheckedChangeListener  {
     private final Context mContext;
-    private final CheckBoxPreference mCheckBox;
-    private final CharSequence mOriginalSummary;
-
+    private Switch mSwitch;
     private AtomicBoolean mConnected = new AtomicBoolean(false);
 
     private final WifiManager mWifiManager;
@@ -65,11 +62,9 @@
         }
     };
 
-    public WifiEnabler(Context context, CheckBoxPreference checkBox) {
+    public WifiEnabler(Context context, Switch switch_) {
         mContext = context;
-        mCheckBox = checkBox;
-        mOriginalSummary = checkBox.getSummary();
-        checkBox.setPersistent(false);
+        mSwitch = switch_;
 
         mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
@@ -81,78 +76,86 @@
     public void resume() {
         // Wi-Fi state is sticky, so just let the receiver update UI
         mContext.registerReceiver(mReceiver, mIntentFilter);
-        mCheckBox.setOnPreferenceChangeListener(this);
+        mSwitch.setOnCheckedChangeListener(this);
     }
 
     public void pause() {
         mContext.unregisterReceiver(mReceiver);
-        mCheckBox.setOnPreferenceChangeListener(null);
+        mSwitch.setOnCheckedChangeListener(null);
     }
 
-    public boolean onPreferenceChange(Preference preference, Object value) {
-        boolean enable = (Boolean) value;
+    public void setSwitch(Switch switch_) {
+        if (mSwitch == switch_) return;
+        mSwitch.setOnCheckedChangeListener(null);
+        mSwitch = switch_;
+        mSwitch.setOnCheckedChangeListener(this);
 
+        final int wifiState = mWifiManager.getWifiState();
+        boolean isEnabled = wifiState == WifiManager.WIFI_STATE_ENABLED;
+        boolean isDisabled = wifiState == WifiManager.WIFI_STATE_DISABLED;
+        mSwitch.setChecked(isEnabled);
+        mSwitch.setEnabled(isEnabled || isDisabled);
+    }
+
+    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
         // Show toast message if Wi-Fi is not allowed in airplane mode
-        if (enable && !WirelessSettings
-                .isRadioAllowed(mContext, Settings.System.RADIO_WIFI)) {
-            Toast.makeText(mContext, R.string.wifi_in_airplane_mode,
-                    Toast.LENGTH_SHORT).show();
-            return false;
+        if (isChecked && !WirelessSettings.isRadioAllowed(mContext, Settings.System.RADIO_WIFI)) {
+            Toast.makeText(mContext, R.string.wifi_in_airplane_mode, Toast.LENGTH_SHORT).show();
+            // Reset switch to off. No infinite check/listenenr loop.
+            buttonView.setChecked(false);
         }
 
-        /**
-         * Disable tethering if enabling Wifi
-         */
+        // Disable tethering if enabling Wifi
         int wifiApState = mWifiManager.getWifiApState();
-        if (enable && ((wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
+        if (isChecked && ((wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
                 (wifiApState == WifiManager.WIFI_AP_STATE_ENABLED))) {
             mWifiManager.setWifiApEnabled(null, false);
         }
-        if (mWifiManager.setWifiEnabled(enable)) {
-            mCheckBox.setEnabled(false);
-        } else {
-            mCheckBox.setSummary(R.string.wifi_error);
-        }
 
-        // Don't update UI to opposite state until we're sure
-        return false;
+        if (mWifiManager.setWifiEnabled(isChecked)) {
+            // Intent has been taken into account, disable until new state is active
+            mSwitch.setEnabled(false);
+        } else {
+            // Error
+            Toast.makeText(mContext, R.string.wifi_error, Toast.LENGTH_SHORT).show();
+        }
     }
 
     private void handleWifiStateChanged(int state) {
         switch (state) {
             case WifiManager.WIFI_STATE_ENABLING:
-                mCheckBox.setSummary(R.string.wifi_starting);
-                mCheckBox.setEnabled(false);
+                mSwitch.setEnabled(false);
                 break;
             case WifiManager.WIFI_STATE_ENABLED:
-                mCheckBox.setChecked(true);
-                mCheckBox.setSummary(null);
-                mCheckBox.setEnabled(true);
+                mSwitch.setChecked(true);
+                mSwitch.setEnabled(true);
                 break;
             case WifiManager.WIFI_STATE_DISABLING:
-                mCheckBox.setSummary(R.string.wifi_stopping);
-                mCheckBox.setEnabled(false);
+                mSwitch.setEnabled(false);
                 break;
             case WifiManager.WIFI_STATE_DISABLED:
-                mCheckBox.setChecked(false);
-                mCheckBox.setSummary(mOriginalSummary);
-                mCheckBox.setEnabled(true);
+                mSwitch.setChecked(false);
+                mSwitch.setEnabled(true);
                 break;
             default:
-                mCheckBox.setChecked(false);
-                mCheckBox.setSummary(R.string.wifi_error);
-                mCheckBox.setEnabled(true);
+                mSwitch.setChecked(false);
+                mSwitch.setEnabled(true);
         }
     }
 
-    private void handleStateChanged(NetworkInfo.DetailedState state) {
+    private void handleStateChanged(@SuppressWarnings("unused") NetworkInfo.DetailedState state) {
+        // After the refactoring from a CheckBoxPreference to a Switch, this method is useless since
+        // there is nowhere to display a summary.
+        // This code is kept in case a future change re-introduces an associated text.
+        /*
         // WifiInfo is valid if and only if Wi-Fi is enabled.
-        // Here we use the state of the check box as an optimization.
-        if (state != null && mCheckBox.isChecked()) {
+        // Here we use the state of the switch as an optimization.
+        if (state != null && mSwitch.isChecked()) {
             WifiInfo info = mWifiManager.getConnectionInfo();
             if (info != null) {
-                mCheckBox.setSummary(Summary.get(mContext, info.getSSID(), state));
+                //setSummary(Summary.get(mContext, info.getSSID(), state));
             }
         }
+        */
     }
 }
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index a09c5c4..a829602 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -18,6 +18,7 @@
 
 import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
 
+import android.app.ActionBar;
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.BroadcastReceiver;
@@ -31,40 +32,35 @@
 import android.net.wifi.ScanResult;
 import android.net.wifi.SupplicantState;
 import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WpsResult;
-import android.net.wifi.WifiConfiguration.KeyMgmt;
-import android.net.wifi.WpsConfiguration;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.preference.CheckBoxPreference;
 import android.preference.Preference;
-import android.preference.ListPreference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
-import android.provider.Settings.Secure;
-import android.provider.Settings;
 import android.security.Credentials;
 import android.security.KeyStore;
 import android.util.Log;
 import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.widget.Toast;
 import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.Switch;
+import android.widget.Toast;
 
 import com.android.internal.util.AsyncChannel;
-import com.android.settings.ProgressCategoryBase;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -83,14 +79,14 @@
  * other decorations specific to that screen.
  */
 public class WifiSettings extends SettingsPreferenceFragment
-        implements DialogInterface.OnClickListener, Preference.OnPreferenceChangeListener  {
+        implements DialogInterface.OnClickListener  {
     private static final String TAG = "WifiSettings";
     private static final int MENU_ID_SCAN = Menu.FIRST;
-    private static final int MENU_ID_ADVANCED = Menu.FIRST + 1;
-    private static final int MENU_ID_CONNECT = Menu.FIRST + 2;
-    private static final int MENU_ID_FORGET = Menu.FIRST + 3;
-    private static final int MENU_ID_MODIFY = Menu.FIRST + 4;
-    private static final String KEY_SLEEP_POLICY = "sleep_policy";
+    private static final int MENU_ID_ADD_NETWORK = Menu.FIRST + 1;
+    private static final int MENU_ID_ADVANCED = Menu.FIRST + 2;
+    private static final int MENU_ID_CONNECT = Menu.FIRST + 3;
+    private static final int MENU_ID_FORGET = Menu.FIRST + 4;
+    private static final int MENU_ID_MODIFY = Menu.FIRST + 5;
 
     private final IntentFilter mFilter;
     private final BroadcastReceiver mReceiver;
@@ -98,12 +94,8 @@
 
     private WifiManager mWifiManager;
     private WifiEnabler mWifiEnabler;
-    private CheckBoxPreference mNotifyOpenNetworks;
-    private ProgressCategoryBase mAccessPoints;
-    private Preference mAddNetwork;
     // An access point being editted is stored here.
     private AccessPoint mSelectedAccessPoint;
-    private boolean mEdit;
 
     private DetailedState mLastState;
     private WifiInfo mLastInfo;
@@ -180,60 +172,48 @@
         // state, start it off in the right state
         mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
 
-        // Avoid re-adding on returning from an overlapping activity/fragment.
-        if (getPreferenceScreen() == null || getPreferenceScreen().getPreferenceCount() < 2) {
-            if (mEnableNextOnConnection) {
-                if (hasNextButton()) {
-                    final ConnectivityManager connectivity = (ConnectivityManager)
-                            getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
-                    if (connectivity != null) {
-                        NetworkInfo info = connectivity.getNetworkInfo(
-                                ConnectivityManager.TYPE_WIFI);
-                        changeNextButtonState(info.isConnected());
-                    }
+        if (mEnableNextOnConnection) {
+            if (hasNextButton()) {
+                final ConnectivityManager connectivity = (ConnectivityManager)
+                        getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
+                if (connectivity != null) {
+                    NetworkInfo info = connectivity.getNetworkInfo(
+                            ConnectivityManager.TYPE_WIFI);
+                    changeNextButtonState(info.isConnected());
                 }
             }
-
-            if (mInXlSetupWizard) {
-                addPreferencesFromResource(R.xml.wifi_access_points_for_wifi_setup_xl);
-            } else if (intent.getBooleanExtra("only_access_points", false)) {
-                addPreferencesFromResource(R.xml.wifi_access_points);
-            } else {
-                addPreferencesFromResource(R.xml.wifi_settings);
-                mWifiEnabler = new WifiEnabler(activity,
-                        (CheckBoxPreference) findPreference("enable_wifi"));
-                mNotifyOpenNetworks =
-                        (CheckBoxPreference) findPreference("notify_open_networks");
-                mNotifyOpenNetworks.setChecked(Secure.getInt(getContentResolver(),
-                        Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
-            }
-            // This may be either ProgressCategory or AccessPointCategoryForXL.
-            final ProgressCategoryBase preference =
-                    (ProgressCategoryBase) findPreference("access_points");
-            mAccessPoints = preference;
-            mAccessPoints.setOrderingAsAdded(false);
-            mAddNetwork = findPreference("add_network");
-
-            ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
-            if (pref != null) {
-                if (Utils.isWifiOnly()) {
-                    pref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
-                    pref.setSummary(R.string.wifi_setting_sleep_policy_summary_wifi_only);
-                }
-                pref.setOnPreferenceChangeListener(this);
-                int value = Settings.System.getInt(getContentResolver(),
-                        Settings.System.WIFI_SLEEP_POLICY,
-                        Settings.System.WIFI_SLEEP_POLICY_NEVER);
-                pref.setValue(String.valueOf(value));
-            }
-
-            registerForContextMenu(getListView());
-            setHasOptionsMenu(true);
         }
 
+        if (mInXlSetupWizard) {
+            addPreferencesFromResource(R.xml.wifi_access_points_for_wifi_setup_xl);
+        } else {
+            addPreferencesFromResource(R.xml.wifi_settings);
+
+            Switch actionBarSwitch = new Switch(activity);
+
+            if (activity instanceof PreferenceActivity) {
+                PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+                if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
+                    final int padding = activity.getResources().getDimensionPixelSize(
+                            R.dimen.action_bar_switch_padding);
+                    actionBarSwitch.setPadding(0, 0, padding, 0);
+                    activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+                            ActionBar.DISPLAY_SHOW_CUSTOM);
+                    activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
+                            ActionBar.LayoutParams.WRAP_CONTENT,
+                            ActionBar.LayoutParams.WRAP_CONTENT,
+                            Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+                }
+            }
+
+            mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);
+        }
+
+        registerForContextMenu(getListView());
+        setHasOptionsMenu(true);
+
         // After confirming PreferenceScreen is available, we call super.
         super.onActivityCreated(savedInstanceState);
-
     }
 
     @Override
@@ -249,6 +229,7 @@
             mWifiManager.connectNetwork(mKeyStoreNetworkId);
         }
         mKeyStoreNetworkId = INVALID_NETWORK_ID;
+
         updateAccessPoints();
     }
 
@@ -270,8 +251,11 @@
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         // We don't want menus in Setup Wizard XL.
         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);
+                    .setIcon(R.drawable.ic_menu_scan_network).setEnabled(wifiIsEnabled);
+            menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
+                    .setIcon(android.R.drawable.ic_menu_add).setEnabled(wifiIsEnabled);
             menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
                     .setIcon(android.R.drawable.ic_menu_manage);
         }
@@ -286,6 +270,11 @@
                     mScanner.forceScan();
                 }
                 return true;
+            case MENU_ID_ADD_NETWORK:
+                if (mWifiManager.isWifiEnabled()) {
+                    onAddNetworkPressed();
+                }
+                return true;
             case MENU_ID_ADVANCED:
                 if (getActivity() instanceof PreferenceActivity) {
                     ((PreferenceActivity) getActivity()).startPreferencePanel(
@@ -363,43 +352,17 @@
         if (preference instanceof AccessPoint) {
             mSelectedAccessPoint = (AccessPoint) preference;
             showConfigUi(mSelectedAccessPoint, false);
-        } else if (preference == mAddNetwork) {
-            onAddNetworkPressed();
-        } else if (preference == mNotifyOpenNetworks) {
-            Secure.putInt(getContentResolver(),
-                    Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
-                    mNotifyOpenNetworks.isChecked() ? 1 : 0);
         } else {
             return super.onPreferenceTreeClick(screen, preference);
         }
         return true;
     }
 
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        String key = preference.getKey();
-        if (key == null) return true;
-
-        if (key.equals(KEY_SLEEP_POLICY)) {
-            try {
-                Settings.System.putInt(getContentResolver(),
-                        Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
-            } catch (NumberFormatException e) {
-                Toast.makeText(getActivity(), R.string.wifi_setting_sleep_policy_error,
-                        Toast.LENGTH_SHORT).show();
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-
     /**
      * Shows an appropriate Wifi configuration component.
      * Called when a user clicks "Add network" preference or one of available networks is selected.
      */
     private void showConfigUi(AccessPoint accessPoint, boolean edit) {
-        mEdit = edit;
         if (mInXlSetupWizard) {
             ((WifiSettingsForSetupWizardXL)getActivity()).showConfigUi(accessPoint, edit);
         } else {
@@ -430,20 +393,40 @@
      * the strength of network and the security for it.
      */
     private void updateAccessPoints() {
-        mAccessPoints.removeAll();
+        final PreferenceScreen preferenceScreen = getPreferenceScreen();
+        preferenceScreen.removeAll();
+        final int wifiState = mWifiManager.getWifiState();
 
-        // AccessPoints are automatically sorted with TreeSet.
-        final Collection<AccessPoint> accessPoints = constructAccessPoints();
-        if (mInXlSetupWizard) {
-            ((WifiSettingsForSetupWizardXL)getActivity()).onAccessPointsUpdated(
-                    mAccessPoints, accessPoints);
-        } else {
-            for (AccessPoint accessPoint : accessPoints) {
-                mAccessPoints.addPreference(accessPoint);
-            }
+        switch (wifiState) {
+            case WifiManager.WIFI_STATE_ENABLED:
+                // AccessPoints are automatically sorted with TreeSet.
+                final Collection<AccessPoint> accessPoints = constructAccessPoints();
+                if (mInXlSetupWizard) {
+                    ((WifiSettingsForSetupWizardXL)getActivity()).onAccessPointsUpdated(
+                            getPreferenceScreen(), accessPoints);
+                } else {
+                    for (AccessPoint accessPoint : accessPoints) {
+                        getPreferenceScreen().addPreference(accessPoint);
+                    }
+                }
+                break;
+
+            case WifiManager.WIFI_STATE_DISABLING:
+                addMessagePreference(R.string.wifi_stopping);
+                break;
+
+            case WifiManager.WIFI_STATE_DISABLED:
+                addMessagePreference(R.string.wifi_empty_list_wifi_off);
+                break;
         }
     }
 
+    private void addMessagePreference(int messageId) {
+        Preference emptyListPreference = new Preference(getActivity());
+        emptyListPreference.setTitle(messageId);
+        getPreferenceScreen().addPreference(emptyListPreference);
+    }
+
     private Collection<AccessPoint> constructAccessPoints() {
         Collection<AccessPoint> accessPoints = new ArrayList<AccessPoint>();
 
@@ -542,9 +525,9 @@
             mLastState = state;
         }
 
-        for (int i = mAccessPoints.getPreferenceCount() - 1; i >= 0; --i) {
+        for (int i = getPreferenceScreen().getPreferenceCount() - 1; i >= 0; --i) {
             // Maybe there's a WifiConfigPreference
-            Preference preference = mAccessPoints.getPreference(i);
+            Preference preference = getPreferenceScreen().getPreference(i);
             if (preference instanceof AccessPoint) {
                 final AccessPoint accessPoint = (AccessPoint) preference;
                 accessPoint.update(mLastInfo, mLastState);
@@ -557,12 +540,25 @@
     }
 
     private void updateWifiState(int state) {
-        if (state == WifiManager.WIFI_STATE_ENABLED) {
-            mScanner.resume();
-        } else {
-            mScanner.pause();
-            mAccessPoints.removeAll();
+        getActivity().invalidateOptionsMenu();
+
+        switch (state) {
+            case WifiManager.WIFI_STATE_ENABLED:
+                mScanner.resume();
+                return; // not break, to avoid pause
+
+            case WifiManager.WIFI_STATE_ENABLING:
+                getPreferenceScreen().removeAll();
+                addMessagePreference(R.string.wifi_starting);
+                break;
+
+            case WifiManager.WIFI_STATE_DISABLED:
+                getPreferenceScreen().removeAll();
+                addMessagePreference(R.string.wifi_empty_list_wifi_off);
+                break;
         }
+
+        mScanner.pause();
     }
 
     private class Scanner extends Handler {
@@ -580,7 +576,6 @@
 
         void pause() {
             mRetry = 0;
-            mAccessPoints.setProgress(false);
             removeMessages(0);
         }
 
@@ -594,7 +589,6 @@
                         Toast.LENGTH_LONG).show();
                 return;
             }
-            mAccessPoints.setProgress(mRetry != 0);
             // Combo scans can take 5-6s to complete. Increase interval to 10s.
             sendEmptyMessageDelayed(0, 10000);
         }
@@ -636,6 +630,7 @@
                             }
                             break;
                     }
+                    break;
                 //TODO: more connectivity feedback
                 default:
                     //Ignore
@@ -740,7 +735,7 @@
             mScanner.resume();
         }
 
-        mAccessPoints.removeAll();
+        getPreferenceScreen().removeAll();
     }
 
     /**
@@ -753,8 +748,9 @@
     }
 
     /* package */ int getAccessPointsCount() {
-        if (mAccessPoints != null) {
-            return mAccessPoints.getPreferenceCount();
+        final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
+        if (wifiIsEnabled) {
+            return getPreferenceScreen().getPreferenceCount();
         } else {
             return 0;
         }
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index 93d55d5..a3f1764 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.wifi;
 
-import com.android.settings.R;
-
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
@@ -28,11 +26,9 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.preference.PreferenceCategory;
+import android.preference.PreferenceScreen;
 import android.text.TextUtils;
 import android.util.Log;
-import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
@@ -43,6 +39,7 @@
 import android.widget.TextView;
 
 import com.android.internal.util.AsyncChannel;
+import com.android.settings.R;
 
 import java.util.Collection;
 import java.util.EnumMap;
@@ -666,9 +663,10 @@
     /**
      * Called when the list of AccessPoints are modified and this Activity needs to refresh
      * the list.
+     * @param preferenceScreen
      */
     /* package */ void onAccessPointsUpdated(
-            PreferenceCategory holder, Collection<AccessPoint> accessPoints) {
+            PreferenceScreen preferenceScreen, Collection<AccessPoint> accessPoints) {
         // If we already show some of access points but the bar still shows "scanning" state, it
         // should be stopped.
         if (mProgressBar.isIndeterminate() && accessPoints.size() > 0) {
@@ -683,7 +681,7 @@
 
         for (AccessPoint accessPoint : accessPoints) {
             accessPoint.setLayoutResource(R.layout.custom_preference);
-            holder.addPreference(accessPoint);
+            preferenceScreen.addPreference(accessPoint);
         }
     }
 
@@ -788,11 +786,6 @@
         mWifiManager.connectNetwork(config);
     }
 
-    @Override
-    public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
-        super.onCreateContextMenu(menu, view, menuInfo);
-    }
-
     /**
      * Replace the current background with a new background whose id is resId if needed.
      */
