Settings: revise WifiEnabler and BluetoothEnabler.

This mainly changes the way both enablers react to the airplane mode. Now
enablers show a toast message instead of disabling the check box directly. This
avoids the inconsistent state introduced by WirelessSettings which controls the
check box using layout dependency.

Related bug: 2053751
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 1d0b2d8..bf75e27 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -17,6 +17,7 @@
 package com.android.settings;
 
 import android.bluetooth.BluetoothAdapter;
+import android.content.Context;
 import android.content.Intent;
 import android.net.wifi.WifiManager;
 import android.os.Bundle;
@@ -67,7 +68,17 @@
         // Let the intents be launched by the Preference manager
         return false;
     }
-    
+
+    public static boolean isRadioAllowed(Context context, String type) {
+        if (!AirplaneModeEnabler.isAirplaneModeOn(context)) {
+            return true;
+        }
+        // Here we use the same logic in onCreate().
+        String toggleable = Settings.System.getString(context.getContentResolver(),
+                Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
+        return toggleable != null && toggleable.contains(type);
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -86,7 +97,7 @@
         String toggleable = Settings.System.getString(getContentResolver(),
                 Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
 
-        // Manually set up dependencies for Wifi when not toggleable.
+        // 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);
@@ -99,7 +110,7 @@
             findPreference(KEY_BT_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
         }
 
-        // Disable BT Settings if BT service is not available.
+        // Disable Bluetooth Settings if Bluetooth service is not available.
         if (ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE) == null) {
             findPreference(KEY_BT_SETTINGS).setEnabled(false);
         }