Fix issues in AP dialog arising after clicking on AP preferences.
+Added a new flag to keep track if user wanted to modify AP by hard pressing on AP. Bug: 22485686 Change-Id: Ia60a564a5344393f5e5340a3493ae7c660ead3d7
This commit is contained in:
@@ -147,7 +147,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
|
|||||||
final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
|
final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
|
||||||
mDlgAccessPoint.getConfig());
|
mDlgAccessPoint.getConfig());
|
||||||
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
||||||
false /* not editting */, true /* hide the submit button */,
|
false /* not editting */, false, true /* hide the submit button */,
|
||||||
hideForgetButton);
|
hideForgetButton);
|
||||||
return mDialog;
|
return mDialog;
|
||||||
|
|
||||||
|
@@ -142,12 +142,14 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
|
|
||||||
private String[] mLevels;
|
private String[] mLevels;
|
||||||
private boolean mEdit;
|
private boolean mEdit;
|
||||||
|
private boolean mModify;
|
||||||
private TextView mSsidView;
|
private TextView mSsidView;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public WifiConfigController(
|
public WifiConfigController(
|
||||||
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
|
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit,
|
||||||
|
boolean modify) {
|
||||||
mConfigUi = parent;
|
mConfigUi = parent;
|
||||||
|
|
||||||
mView = view;
|
mView = view;
|
||||||
@@ -155,6 +157,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
|
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
|
||||||
accessPoint.getSecurity();
|
accessPoint.getSecurity();
|
||||||
mEdit = edit;
|
mEdit = edit;
|
||||||
|
mModify = modify;
|
||||||
|
|
||||||
mTextViewChangedHandler = new Handler();
|
mTextViewChangedHandler = new Handler();
|
||||||
mContext = mConfigUi.getContext();
|
mContext = mConfigUi.getContext();
|
||||||
@@ -245,7 +248,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEdit) {
|
if (mModify) {
|
||||||
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
|
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
|
||||||
} else {
|
} else {
|
||||||
final DetailedState state = mAccessPoint.getDetailedState();
|
final DetailedState state = mAccessPoint.getDetailedState();
|
||||||
@@ -303,12 +306,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mEdit) || (mAccessPoint != null
|
|
||||||
&& mAccessPoint.getDetailedState() == null && mAccessPoint.getLevel() != -1)){
|
|
||||||
mConfigUi.setCancelButton(res.getString(R.string.wifi_cancel));
|
mConfigUi.setCancelButton(res.getString(R.string.wifi_cancel));
|
||||||
}else{
|
|
||||||
mConfigUi.setCancelButton(res.getString(R.string.wifi_display_options_done));
|
|
||||||
}
|
|
||||||
if (mConfigUi.getSubmitButton() != null) {
|
if (mConfigUi.getSubmitButton() != null) {
|
||||||
enableSubmitIfAppropriate();
|
enableSubmitIfAppropriate();
|
||||||
}
|
}
|
||||||
@@ -370,7 +368,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* package */ WifiConfiguration getConfig() {
|
/* package */ WifiConfiguration getConfig() {
|
||||||
if (mAccessPoint != null && mAccessPoint.isSaved() && !mEdit) {
|
if (!mEdit) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -953,6 +951,10 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
return mEdit;
|
return mEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isModify() {
|
||||||
|
return mModify;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
mTextViewChangedHandler.post(new Runnable() {
|
mTextViewChangedHandler.post(new Runnable() {
|
||||||
|
@@ -31,6 +31,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
|
|||||||
static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
|
static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
|
||||||
|
|
||||||
private final boolean mEdit;
|
private final boolean mEdit;
|
||||||
|
private final boolean mModify;
|
||||||
private final DialogInterface.OnClickListener mListener;
|
private final DialogInterface.OnClickListener mListener;
|
||||||
private final AccessPoint mAccessPoint;
|
private final AccessPoint mAccessPoint;
|
||||||
|
|
||||||
@@ -40,17 +41,18 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
|
|||||||
private boolean mHideForgetButton;
|
private boolean mHideForgetButton;
|
||||||
|
|
||||||
public WifiDialog(Context context, DialogInterface.OnClickListener listener,
|
public WifiDialog(Context context, DialogInterface.OnClickListener listener,
|
||||||
AccessPoint accessPoint, boolean edit, boolean hideSubmitButton,
|
AccessPoint accessPoint, boolean edit, boolean modify,
|
||||||
boolean hideForgetButton) {
|
boolean hideSubmitButton, boolean hideForgetButton) {
|
||||||
this(context, listener, accessPoint, edit);
|
this(context, listener, accessPoint, edit, modify);
|
||||||
mHideSubmitButton = hideSubmitButton;
|
mHideSubmitButton = hideSubmitButton;
|
||||||
mHideForgetButton = hideForgetButton;
|
mHideForgetButton = hideForgetButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WifiDialog(Context context, DialogInterface.OnClickListener listener,
|
public WifiDialog(Context context, DialogInterface.OnClickListener listener,
|
||||||
AccessPoint accessPoint, boolean edit) {
|
AccessPoint accessPoint, boolean edit, boolean modify) {
|
||||||
super(context);
|
super(context);
|
||||||
mEdit = edit;
|
mEdit = edit;
|
||||||
|
mModify = modify;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mAccessPoint = accessPoint;
|
mAccessPoint = accessPoint;
|
||||||
mHideSubmitButton = false;
|
mHideSubmitButton = false;
|
||||||
@@ -67,7 +69,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
|
|||||||
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
|
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
|
||||||
setView(mView);
|
setView(mView);
|
||||||
setInverseBackgroundForced(true);
|
setInverseBackgroundForced(true);
|
||||||
mController = new WifiConfigController(this, mView, mAccessPoint, mEdit);
|
mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mModify);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (mHideSubmitButton) {
|
if (mHideSubmitButton) {
|
||||||
|
@@ -119,6 +119,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
// Instance state keys
|
// Instance state keys
|
||||||
private static final String SAVE_DIALOG_EDIT_MODE = "edit_mode";
|
private static final String SAVE_DIALOG_EDIT_MODE = "edit_mode";
|
||||||
|
private static final String SAVE_DIALOG_MODIFY_MODE = "modify_mode";
|
||||||
private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
|
private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
|
||||||
private static final String SAVED_WIFI_NFC_DIALOG_STATE = "wifi_nfc_dlg_state";
|
private static final String SAVED_WIFI_NFC_DIALOG_STATE = "wifi_nfc_dlg_state";
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
private boolean mEnableNextOnConnection;
|
private boolean mEnableNextOnConnection;
|
||||||
|
|
||||||
// Save the dialog details
|
// Save the dialog details
|
||||||
|
private boolean mDlgModify;
|
||||||
private boolean mDlgEdit;
|
private boolean mDlgEdit;
|
||||||
private AccessPoint mDlgAccessPoint;
|
private AccessPoint mDlgAccessPoint;
|
||||||
private Bundle mAccessPointSavedState;
|
private Bundle mAccessPointSavedState;
|
||||||
@@ -248,6 +250,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
|
mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
|
||||||
|
mDlgModify = savedInstanceState.getBoolean(SAVE_DIALOG_MODIFY_MODE);
|
||||||
if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
|
if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
|
||||||
mAccessPointSavedState =
|
mAccessPointSavedState =
|
||||||
savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
|
savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
|
||||||
@@ -379,6 +382,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
// If the dialog is showing, save its state.
|
// If the dialog is showing, save its state.
|
||||||
if (mDialog != null && mDialog.isShowing()) {
|
if (mDialog != null && mDialog.isShowing()) {
|
||||||
outState.putBoolean(SAVE_DIALOG_EDIT_MODE, mDlgEdit);
|
outState.putBoolean(SAVE_DIALOG_EDIT_MODE, mDlgEdit);
|
||||||
|
outState.putBoolean(SAVE_DIALOG_MODIFY_MODE, mDlgModify);
|
||||||
if (mDlgAccessPoint != null) {
|
if (mDlgAccessPoint != null) {
|
||||||
mAccessPointSavedState = new Bundle();
|
mAccessPointSavedState = new Bundle();
|
||||||
mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
|
mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
|
||||||
@@ -506,6 +510,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
mSelectedAccessPoint.generateOpenNetworkConfig();
|
mSelectedAccessPoint.generateOpenNetworkConfig();
|
||||||
connect(mSelectedAccessPoint.getConfig());
|
connect(mSelectedAccessPoint.getConfig());
|
||||||
} else {
|
} else {
|
||||||
|
mDlgModify = false;
|
||||||
showDialog(mSelectedAccessPoint, true);
|
showDialog(mSelectedAccessPoint, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -515,6 +520,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MENU_ID_MODIFY: {
|
case MENU_ID_MODIFY: {
|
||||||
|
mDlgModify = true;
|
||||||
showDialog(mSelectedAccessPoint, true);
|
showDialog(mSelectedAccessPoint, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -539,8 +545,12 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
connect(mSelectedAccessPoint.getConfig());
|
connect(mSelectedAccessPoint.getConfig());
|
||||||
} else {
|
} else if (mSelectedAccessPoint.isSaved()){
|
||||||
|
mDlgModify = false;
|
||||||
showDialog(mSelectedAccessPoint, false);
|
showDialog(mSelectedAccessPoint, false);
|
||||||
|
} else {
|
||||||
|
mDlgModify = false;
|
||||||
|
showDialog(mSelectedAccessPoint, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return super.onPreferenceTreeClick(screen, preference);
|
return super.onPreferenceTreeClick(screen, preference);
|
||||||
@@ -607,7 +617,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
|
final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
|
||||||
ap.getConfig()));
|
ap.getConfig()));
|
||||||
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
||||||
/* no hide submit/connect */ false,
|
mDlgModify, /* no hide submit/connect */ false,
|
||||||
/* hide forget if config locked down */ hideForget);
|
/* hide forget if config locked down */ hideForget);
|
||||||
return mDialog;
|
return mDialog;
|
||||||
case WPS_PBC_DIALOG_ID:
|
case WPS_PBC_DIALOG_ID:
|
||||||
@@ -825,17 +835,12 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
&& mSelectedAccessPoint.isSaved()) {
|
&& mSelectedAccessPoint.isSaved()) {
|
||||||
connect(mSelectedAccessPoint.getConfig());
|
connect(mSelectedAccessPoint.getConfig());
|
||||||
}
|
}
|
||||||
} else if (config.networkId != INVALID_NETWORK_ID) {
|
} else if (configController.isModify()) {
|
||||||
if (mSelectedAccessPoint != null) {
|
|
||||||
mWifiManager.save(config, mSaveListener);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (configController.isEdit()) {
|
|
||||||
mWifiManager.save(config, mSaveListener);
|
mWifiManager.save(config, mSaveListener);
|
||||||
} else {
|
} else {
|
||||||
|
mWifiManager.save(config, mSaveListener);
|
||||||
connect(config);
|
connect(config);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
mWifiTracker.resumeScanning();
|
mWifiTracker.resumeScanning();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user