The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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 | |
The Android Open Source Project | abc48f8 | 2008-12-17 18:06:01 -0800 | [diff] [blame^] | 19 | import com.android.settings.bluetooth.BluetoothEnabler; |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 20 | import com.android.settings.wifi.WifiEnabler; |
| 21 | |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 22 | import android.net.wifi.WifiManager; |
| 23 | import android.os.Bundle; |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 24 | import android.preference.PreferenceActivity; |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 25 | import android.preference.CheckBoxPreference; |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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; |
The Android Open Source Project | abc48f8 | 2008-12-17 18:06:01 -0800 | [diff] [blame^] | 35 | private BluetoothEnabler mBtEnabler; |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 36 | |
| 37 | @Override |
| 38 | protected void onCreate(Bundle savedInstanceState) { |
| 39 | super.onCreate(savedInstanceState); |
| 40 | |
| 41 | addPreferencesFromResource(R.xml.wireless_settings); |
| 42 | |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 43 | initToggles(); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | protected void onResume() { |
| 48 | super.onResume(); |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 49 | |
| 50 | mWifiEnabler.resume(); |
| 51 | mAirplaneModeEnabler.resume(); |
The Android Open Source Project | abc48f8 | 2008-12-17 18:06:01 -0800 | [diff] [blame^] | 52 | mBtEnabler.resume(); |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | @Override |
| 56 | protected void onPause() { |
| 57 | super.onPause(); |
The Android Open Source Project | abc48f8 | 2008-12-17 18:06:01 -0800 | [diff] [blame^] | 58 | |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 59 | mWifiEnabler.pause(); |
| 60 | mAirplaneModeEnabler.pause(); |
The Android Open Source Project | abc48f8 | 2008-12-17 18:06:01 -0800 | [diff] [blame^] | 61 | mBtEnabler.pause(); |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 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 | |
The Android Open Source Project | abc48f8 | 2008-12-17 18:06:01 -0800 | [diff] [blame^] | 75 | mBtEnabler = new BluetoothEnabler( |
| 76 | this, |
| 77 | (CheckBoxPreference) findPreference(KEY_TOGGLE_BLUETOOTH)); |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 78 | } |
| 79 | |
The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 80 | } |