diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-05-18 15:10:41 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-18 15:10:41 -0700 |
commit | ee7589c02ab2cf4a4169531df54595f81f0d88a0 (patch) | |
tree | 90e92ad3362b4d6688035e71c9974c8c54d69431 /src/com/android/settings/wifi | |
parent | 409433e904f9b8a65a87274b7d5f582f0ac46e26 (diff) | |
parent | db3d4bb8c489da99d23cd6e6713a6f1f10fb52bc (diff) | |
download | packages_apps_settings-ee7589c02ab2cf4a4169531df54595f81f0d88a0.zip packages_apps_settings-ee7589c02ab2cf4a4169531df54595f81f0d88a0.tar.gz packages_apps_settings-ee7589c02ab2cf4a4169531df54595f81f0d88a0.tar.bz2 |
Merge "Fix p2p settings crash" into jb-dev
Diffstat (limited to 'src/com/android/settings/wifi')
-rw-r--r-- | src/com/android/settings/wifi/p2p/WifiP2pSettings.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java index 5f296b5..b369afe 100644 --- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java +++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java @@ -89,6 +89,8 @@ public class WifiP2pSettings extends SettingsPreferenceFragment private static final int DIALOG_CANCEL_CONNECT = 2; private static final int DIALOG_RENAME = 3; + private static final String SAVE_DIALOG_PEER = "PEER_STATE"; + private WifiP2pDevice mThisDevice; private WifiP2pDeviceList mPeers = new WifiP2pDeviceList(); @@ -134,8 +136,7 @@ public class WifiP2pSettings extends SettingsPreferenceFragment }; @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); + public void onActivityCreated(Bundle savedInstanceState) { addPreferencesFromResource(R.xml.wifi_p2p_settings); mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION); @@ -157,6 +158,11 @@ public class WifiP2pSettings extends SettingsPreferenceFragment Log.e(TAG, "mWifiP2pManager is null !"); } + if (savedInstanceState != null && savedInstanceState.containsKey(SAVE_DIALOG_PEER)) { + WifiP2pDevice device = savedInstanceState.getParcelable(SAVE_DIALOG_PEER); + mSelectedWifiPeer = new WifiP2pPeer(getActivity(), device); + } + mRenameListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -229,6 +235,8 @@ public class WifiP2pSettings extends SettingsPreferenceFragment mPeersGroup = new PreferenceCategory(getActivity()); mPeersGroup.setTitle(R.string.wifi_p2p_peer_devices); + + super.onActivityCreated(savedInstanceState); } @Override @@ -336,14 +344,19 @@ public class WifiP2pSettings extends SettingsPreferenceFragment @Override public Dialog onCreateDialog(int id) { if (id == DIALOG_DISCONNECT) { - int stringId = (mConnectedDevices > 1) ? R.string.wifi_p2p_disconnect_multiple_message : - R.string.wifi_p2p_disconnect_message; String deviceName = TextUtils.isEmpty(mSelectedWifiPeer.device.deviceName) ? mSelectedWifiPeer.device.deviceAddress : mSelectedWifiPeer.device.deviceName; + String msg; + if (mConnectedDevices > 1) { + msg = getActivity().getString(R.string.wifi_p2p_disconnect_multiple_message, + deviceName, mConnectedDevices - 1); + } else { + msg = getActivity().getString(R.string.wifi_p2p_disconnect_message, deviceName); + } AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.wifi_p2p_disconnect_title) - .setMessage(getActivity().getString(stringId, deviceName)) + .setMessage(msg) .setPositiveButton(getActivity().getString(R.string.dlg_ok), mDisconnectListener) .setNegativeButton(getActivity().getString(R.string.dlg_cancel), null) .create(); @@ -374,6 +387,13 @@ public class WifiP2pSettings extends SettingsPreferenceFragment return null; } + @Override + public void onSaveInstanceState(Bundle outState) { + if (mSelectedWifiPeer != null) { + outState.putParcelable(SAVE_DIALOG_PEER, mSelectedWifiPeer.device); + } + } + public void onPeersAvailable(WifiP2pDeviceList peers) { mPeersGroup.removeAll(); |