1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings; 18 19 import com.android.settings.bluetooth.BluetoothEnabler; 20 import com.android.settings.wifi.WifiEnabler; 21 22 import android.net.wifi.WifiManager; 23 import android.os.Bundle; 24 import android.preference.PreferenceActivity; 25 import android.preference.CheckBoxPreference; 26 27 public class WirelessSettings extends PreferenceActivity { 28 29 private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane"; 30 private static final String KEY_TOGGLE_BLUETOOTH = "toggle_bluetooth"; 31 private static final String KEY_TOGGLE_WIFI = "toggle_wifi"; 32 33 private WifiEnabler mWifiEnabler; 34 private AirplaneModeEnabler mAirplaneModeEnabler; 35 private BluetoothEnabler mBtEnabler; 36 37 @Override onCreate(Bundle savedInstanceState)38 protected void onCreate(Bundle savedInstanceState) { 39 super.onCreate(savedInstanceState); 40 41 addPreferencesFromResource(R.xml.wireless_settings); 42 43 initToggles(); 44 } 45 46 @Override onResume()47 protected void onResume() { 48 super.onResume(); 49 50 mWifiEnabler.resume(); 51 mAirplaneModeEnabler.resume(); 52 mBtEnabler.resume(); 53 } 54 55 @Override onPause()56 protected void onPause() { 57 super.onPause(); 58 59 mWifiEnabler.pause(); 60 mAirplaneModeEnabler.pause(); 61 mBtEnabler.pause(); 62 } 63 initToggles()64 private void initToggles() { 65 66 mWifiEnabler = new WifiEnabler( 67 this, 68 (WifiManager) getSystemService(WIFI_SERVICE), 69 (CheckBoxPreference) findPreference(KEY_TOGGLE_WIFI)); 70 71 mAirplaneModeEnabler = new AirplaneModeEnabler( 72 this, 73 (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE)); 74 75 mBtEnabler = new BluetoothEnabler( 76 this, 77 (CheckBoxPreference) findPreference(KEY_TOGGLE_BLUETOOTH)); 78 } 79 80 } 81