diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-05-18 13:27:05 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2012-05-18 13:27:05 -0700 |
commit | db3d4bb8c489da99d23cd6e6713a6f1f10fb52bc (patch) | |
tree | 4d41db57022f5b868a7c46d474ef93c91469e050 /src/com/android/settings/wifi | |
parent | 4837a691ceb4a5d7114d3f3be8352dde3e0f084c (diff) | |
download | packages_apps_settings-db3d4bb8c489da99d23cd6e6713a6f1f10fb52bc.zip packages_apps_settings-db3d4bb8c489da99d23cd6e6713a6f1f10fb52bc.tar.gz packages_apps_settings-db3d4bb8c489da99d23cd6e6713a6f1f10fb52bc.tar.bz2 |
Fix p2p settings crash
- Restore on orientation change
- Use appropriate string for dialog
Bug: 6456079
Bug: 6463563
Change-Id: I1fa0b90a14d09608b580ebf3d66b92fc8721eae7
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(); |