Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bf0db8d authored by Sanket Padawe's avatar Sanket Padawe
Browse files

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
parent 32b96646
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
                final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
                        mDlgAccessPoint.getConfig());
                mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
                        false /* not editting */, true /* hide the submit button */,
                        false /* not editting */, false, true /* hide the submit button */,
                        hideForgetButton);
                return mDialog;

+11 −9
Original line number Diff line number Diff line
@@ -142,12 +142,14 @@ public class WifiConfigController implements TextWatcher,

    private String[] mLevels;
    private boolean mEdit;
    private boolean mModify;
    private TextView mSsidView;

    private Context mContext;

    public WifiConfigController(
            WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
            WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit,
            boolean modify) {
        mConfigUi = parent;

        mView = view;
@@ -155,6 +157,7 @@ public class WifiConfigController implements TextWatcher,
        mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
                accessPoint.getSecurity();
        mEdit = edit;
        mModify = modify;

        mTextViewChangedHandler = new Handler();
        mContext = mConfigUi.getContext();
@@ -245,7 +248,7 @@ public class WifiConfigController implements TextWatcher,
                }
            }

            if (mEdit) {
            if (mModify) {
                mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
            } else {
                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));
        }else{
            mConfigUi.setCancelButton(res.getString(R.string.wifi_display_options_done));
        }
        if (mConfigUi.getSubmitButton() != null) {
            enableSubmitIfAppropriate();
        }
@@ -370,7 +368,7 @@ public class WifiConfigController implements TextWatcher,
    }

    /* package */ WifiConfiguration getConfig() {
        if (mAccessPoint != null && mAccessPoint.isSaved() && !mEdit) {
        if (!mEdit) {
            return null;
        }

@@ -953,6 +951,10 @@ public class WifiConfigController implements TextWatcher,
        return mEdit;
    }

    public boolean isModify() {
        return mModify;
    }

    @Override
    public void afterTextChanged(Editable s) {
        mTextViewChangedHandler.post(new Runnable() {
+7 −5
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
    static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;

    private final boolean mEdit;
    private final boolean mModify;
    private final DialogInterface.OnClickListener mListener;
    private final AccessPoint mAccessPoint;

@@ -40,17 +41,18 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
    private boolean mHideForgetButton;

    public WifiDialog(Context context, DialogInterface.OnClickListener listener,
            AccessPoint accessPoint, boolean edit, boolean hideSubmitButton,
            boolean hideForgetButton) {
        this(context, listener, accessPoint, edit);
            AccessPoint accessPoint, boolean edit, boolean modify,
            boolean hideSubmitButton, boolean hideForgetButton) {
        this(context, listener, accessPoint, edit, modify);
        mHideSubmitButton = hideSubmitButton;
        mHideForgetButton = hideForgetButton;
    }

    public WifiDialog(Context context, DialogInterface.OnClickListener listener,
            AccessPoint accessPoint, boolean edit) {
            AccessPoint accessPoint, boolean edit, boolean modify) {
        super(context);
        mEdit = edit;
        mModify = modify;
        mListener = listener;
        mAccessPoint = accessPoint;
        mHideSubmitButton = false;
@@ -67,7 +69,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
        mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
        setView(mView);
        setInverseBackgroundForced(true);
        mController = new WifiConfigController(this, mView, mAccessPoint, mEdit);
        mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mModify);
        super.onCreate(savedInstanceState);

        if (mHideSubmitButton) {
+16 −11
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ public class WifiSettings extends RestrictedSettingsFragment

    // Instance state keys
    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 SAVED_WIFI_NFC_DIALOG_STATE = "wifi_nfc_dlg_state";

@@ -150,6 +151,7 @@ public class WifiSettings extends RestrictedSettingsFragment
    private boolean mEnableNextOnConnection;

    // Save the dialog details
    private boolean mDlgModify;
    private boolean mDlgEdit;
    private AccessPoint mDlgAccessPoint;
    private Bundle mAccessPointSavedState;
@@ -248,6 +250,7 @@ public class WifiSettings extends RestrictedSettingsFragment

        if (savedInstanceState != null) {
            mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
            mDlgModify = savedInstanceState.getBoolean(SAVE_DIALOG_MODIFY_MODE);
            if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
                mAccessPointSavedState =
                    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 (mDialog != null && mDialog.isShowing()) {
            outState.putBoolean(SAVE_DIALOG_EDIT_MODE, mDlgEdit);
            outState.putBoolean(SAVE_DIALOG_MODIFY_MODE, mDlgModify);
            if (mDlgAccessPoint != null) {
                mAccessPointSavedState = new Bundle();
                mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
@@ -506,6 +510,7 @@ public class WifiSettings extends RestrictedSettingsFragment
                    mSelectedAccessPoint.generateOpenNetworkConfig();
                    connect(mSelectedAccessPoint.getConfig());
                } else {
                    mDlgModify = false;
                    showDialog(mSelectedAccessPoint, true);
                }
                return true;
@@ -515,6 +520,7 @@ public class WifiSettings extends RestrictedSettingsFragment
                return true;
            }
            case MENU_ID_MODIFY: {
                mDlgModify = true;
                showDialog(mSelectedAccessPoint, true);
                return true;
            }
@@ -539,8 +545,12 @@ public class WifiSettings extends RestrictedSettingsFragment
                    getActivity().invalidateOptionsMenu();
                }
                connect(mSelectedAccessPoint.getConfig());
            } else {
            } else if (mSelectedAccessPoint.isSaved()){
                mDlgModify = false;
                showDialog(mSelectedAccessPoint, false);
            } else {
                mDlgModify = false;
                showDialog(mSelectedAccessPoint, true);
            }
        } else {
            return super.onPreferenceTreeClick(screen, preference);
@@ -607,7 +617,7 @@ public class WifiSettings extends RestrictedSettingsFragment
                final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
                        ap.getConfig()));
                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);
                return mDialog;
            case WPS_PBC_DIALOG_ID:
@@ -825,17 +835,12 @@ public class WifiSettings extends RestrictedSettingsFragment
                    && mSelectedAccessPoint.isSaved()) {
                connect(mSelectedAccessPoint.getConfig());
            }
        } else if (config.networkId != INVALID_NETWORK_ID) {
            if (mSelectedAccessPoint != null) {
        } else if (configController.isModify()) {
            mWifiManager.save(config, mSaveListener);
            }
        } else {
            if (configController.isEdit()) {
            mWifiManager.save(config, mSaveListener);
            } else {
            connect(config);
        }
        }

        mWifiTracker.resumeScanning();
    }