Merge "Retain text in Rename Device dialog." into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
35ff41b5f7
@@ -90,10 +90,13 @@ public class WifiP2pSettings extends SettingsPreferenceFragment
|
|||||||
private static final int DIALOG_RENAME = 3;
|
private static final int DIALOG_RENAME = 3;
|
||||||
|
|
||||||
private static final String SAVE_DIALOG_PEER = "PEER_STATE";
|
private static final String SAVE_DIALOG_PEER = "PEER_STATE";
|
||||||
|
private static final String SAVE_DEVICE_NAME = "DEV_NAME";
|
||||||
|
|
||||||
private WifiP2pDevice mThisDevice;
|
private WifiP2pDevice mThisDevice;
|
||||||
private WifiP2pDeviceList mPeers = new WifiP2pDeviceList();
|
private WifiP2pDeviceList mPeers = new WifiP2pDeviceList();
|
||||||
|
|
||||||
|
private String mSavedDeviceName;
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@@ -162,6 +165,9 @@ public class WifiP2pSettings extends SettingsPreferenceFragment
|
|||||||
WifiP2pDevice device = savedInstanceState.getParcelable(SAVE_DIALOG_PEER);
|
WifiP2pDevice device = savedInstanceState.getParcelable(SAVE_DIALOG_PEER);
|
||||||
mSelectedWifiPeer = new WifiP2pPeer(getActivity(), device);
|
mSelectedWifiPeer = new WifiP2pPeer(getActivity(), device);
|
||||||
}
|
}
|
||||||
|
if (savedInstanceState != null && savedInstanceState.containsKey(SAVE_DEVICE_NAME)) {
|
||||||
|
mSavedDeviceName = savedInstanceState.getString(SAVE_DEVICE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
mRenameListener = new OnClickListener() {
|
mRenameListener = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -376,6 +382,14 @@ public class WifiP2pSettings extends SettingsPreferenceFragment
|
|||||||
return dialog;
|
return dialog;
|
||||||
} else if (id == DIALOG_RENAME) {
|
} else if (id == DIALOG_RENAME) {
|
||||||
mDeviceNameText = new EditText(getActivity());
|
mDeviceNameText = new EditText(getActivity());
|
||||||
|
if (mSavedDeviceName != null) {
|
||||||
|
mDeviceNameText.setText(mSavedDeviceName);
|
||||||
|
mDeviceNameText.setSelection(mSavedDeviceName.length());
|
||||||
|
} else if (mThisDevice != null && !TextUtils.isEmpty(mThisDevice.deviceName)) {
|
||||||
|
mDeviceNameText.setText(mThisDevice.deviceName);
|
||||||
|
mDeviceNameText.setSelection(0, mThisDevice.deviceName.length());
|
||||||
|
}
|
||||||
|
mSavedDeviceName = null;
|
||||||
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(R.string.wifi_p2p_menu_rename)
|
.setTitle(R.string.wifi_p2p_menu_rename)
|
||||||
.setView(mDeviceNameText)
|
.setView(mDeviceNameText)
|
||||||
@@ -392,6 +406,9 @@ public class WifiP2pSettings extends SettingsPreferenceFragment
|
|||||||
if (mSelectedWifiPeer != null) {
|
if (mSelectedWifiPeer != null) {
|
||||||
outState.putParcelable(SAVE_DIALOG_PEER, mSelectedWifiPeer.device);
|
outState.putParcelable(SAVE_DIALOG_PEER, mSelectedWifiPeer.device);
|
||||||
}
|
}
|
||||||
|
if (mDeviceNameText != null) {
|
||||||
|
outState.putString(SAVE_DEVICE_NAME, mDeviceNameText.getText().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPeersAvailable(WifiP2pDeviceList peers) {
|
public void onPeersAvailable(WifiP2pDeviceList peers) {
|
||||||
|
Reference in New Issue
Block a user