resolved conflicts for merge of e304b9f4 to eclair-mr2

This commit is contained in:
Neel Parekh
2009-10-22 18:26:46 -07:00
3 changed files with 116 additions and 72 deletions

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/wifi_settings_category">
<com.android.settings.ProgressCategory
android:key="access_points"
android:title="@string/wifi_access_points"
android:persistent="false" />
<Preference
android:key="add_other_network"
android:title="@string/wifi_add_other_network"
android:persistent="false" />
</PreferenceScreen>

View File

@@ -65,6 +65,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
*/
private Dialog mDialog;
private static final String KEY_ONLY_ACCESS_POINTS = "only_access_points";
private static final String KEY_ADD_OTHER_NETWORK = "add_other_network";
private static final int CONTEXT_MENU_ID_CONNECT = Menu.FIRST;
@@ -117,11 +118,19 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
mWifiLayer.onCreatedCallback();
}
private int getPreferenceResource() {
if (getIntent().getBooleanExtra(KEY_ONLY_ACCESS_POINTS, false)) {
return R.xml.wifi_access_points;
} else {
return R.xml.wifi_settings;
}
}
/**
* Shouldn't have any dependency on the wifi layer.
*/
private void onCreatePreferences() {
addPreferencesFromResource(R.xml.wifi_settings);
addPreferencesFromResource(getPreferenceResource());
final PreferenceScreen preferenceScreen = getPreferenceScreen();
@@ -134,14 +143,16 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
// * this ordering logic is in AccessPointPreference's compareTo
mApCategory.setOrderingAsAdded(false);
mWifiEnabled = (CheckBoxPreference) preferenceScreen.findPreference(KEY_WIFI_ENABLED);
mWifiEnabler = new WifiEnabler(this, (WifiManager) getSystemService(WIFI_SERVICE),
mWifiEnabled);
if (!getIntent().getBooleanExtra("only_access_points", false)) {
mWifiEnabled = (CheckBoxPreference) preferenceScreen.findPreference(KEY_WIFI_ENABLED);
mWifiEnabler = new WifiEnabler(this, (WifiManager) getSystemService(WIFI_SERVICE),
mWifiEnabled);
mOpenNetworkNotificationsEnabled = (CheckBoxPreference) preferenceScreen
.findPreference(KEY_OPEN_NETWORK_NOTIFICATIONS_ENABLED);
mOpenNetworkNotificationsEnabled.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
mOpenNetworkNotificationsEnabled = (CheckBoxPreference) preferenceScreen
.findPreference(KEY_OPEN_NETWORK_NOTIFICATIONS_ENABLED);
mOpenNetworkNotificationsEnabled.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
}
mAddOtherNetwork = preferenceScreen.findPreference(KEY_ADD_OTHER_NETWORK);
@@ -155,7 +166,9 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
protected void onResume() {
super.onResume();
mWifiLayer.onResume();
mWifiEnabler.resume();
if (mWifiEnabler != null) {
mWifiEnabler.resume();
}
// do what we should have after keystore is unlocked.
if (mResumeState != null) {
if (mKeyStore.test() == KeyStore.NO_ERROR) {
@@ -176,7 +189,9 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
protected void onPause() {
super.onPause();
mWifiLayer.onPause();
mWifiEnabler.pause();
if (mWifiEnabler != null) {
mWifiEnabler.pause();
}
}
@Override
@@ -261,8 +276,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
if (state == null) {
return;
}
menu.setHeaderTitle(state.ssid);
menu.setHeaderTitle(state.getHumanReadableSsid());
if (state.isConnectable()) {
menu.add(0, CONTEXT_MENU_ID_CONNECT, 0, R.string.wifi_context_menu_connect);