Loading src/com/android/settings/wifi/WifiConfigController.java +7 −7 Original line number Diff line number Diff line Loading @@ -545,13 +545,13 @@ public class WifiConfigController implements TextWatcher, && !isValidSaePassword(mPasswordView.getText().toString())))) { passwordInvalid = true; } if ((mSsidView != null && mSsidView.length() == 0) if ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid) { // If Accesspoint is not saved, apply passwordInvalid check || ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid enabled = false; } else if (mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid && mPasswordView.length() > 0) { // If AccessPoint is saved (modifying network) and password is changed, apply // Invalid password check || mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid && mPasswordView.length() > 0)) { enabled = false; } else { enabled = ipAndProxyFieldsAreValid(); Loading src/com/android/settings/wifi/WifiDialog.java +11 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; import com.android.settings.wifi.utils.SsidInputGroup; import com.android.settings.wifi.utils.WifiDialogHelper; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.wifi.AccessPoint; Loading Loading @@ -62,6 +64,7 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, private View mView; private WifiConfigController mController; private boolean mHideSubmitButton; private WifiDialogHelper mDialogHelper; /** * Creates a WifiDialog with no additional style. It displays as a dialog above the current Loading Loading @@ -115,6 +118,9 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, if (mAccessPoint == null) { mController.hideForgetButton(); } mDialogHelper = new WifiDialogHelper(this, new SsidInputGroup(getContext(), mView, R.id.ssid_layout, R.id.ssid)); } @SuppressWarnings("MissingSuperCall") // TODO: Fix me Loading Loading @@ -155,9 +161,6 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, public void onClick(DialogInterface dialogInterface, int id) { if (mListener != null) { switch (id) { case BUTTON_SUBMIT: mListener.onSubmit(this); break; case BUTTON_FORGET: if (WifiUtils.isNetworkLockedDown(getContext(), mAccessPoint.getConfig())) { RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), Loading @@ -170,6 +173,11 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, } } /** Return true to tell the parent activity to call onSubmit before onDismiss. */ public boolean shouldSubmitBeforeFinish() { return mDialogHelper.isPositive(); } @Override public int getMode() { return mMode; Loading src/com/android/settings/wifi/WifiDialogActivity.java +3 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,9 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog @Override public void onDismiss(DialogInterface dialogInterface) { mDialog2 = null; if (mDialog != null && mDialog.shouldSubmitBeforeFinish()) { onSubmit(mDialog); } mDialog = null; finish(); } Loading src/com/android/settings/wifi/utils/AlertDialogHelper.kt 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.wifi.utils import android.content.DialogInterface import android.util.Log import androidx.appcompat.app.AlertDialog open class AlertDialogHelper(val alertDialog: AlertDialog) { var isPositive = false init { alertDialog.setOnShowListener { alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)?.setOnClickListener { onPositiveButtonClicked() } ?: Log.e(TAG, "Can't get the positive button!") } } open fun onPositiveButtonClicked() { if (!canDismiss()) { Log.w(TAG, "Can't dismiss dialog!") return } isPositive = true alertDialog.dismiss() } open fun canDismiss() = true companion object { const val TAG = "AlertDialogHelper" } } src/com/android/settings/wifi/utils/WifiDialogHelper.kt 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.wifi.utils import android.util.Log import androidx.appcompat.app.AlertDialog class WifiDialogHelper( alertDialog: AlertDialog, private val ssidInputGroup: SsidInputGroup? = null, ) : AlertDialogHelper(alertDialog) { override fun canDismiss(): Boolean { val isValid = ssidInputGroup?.validate() ?: true if (!isValid) Log.w(TAG, "SSID is invalid!") return isValid } companion object { const val TAG = "WifiDialogHelper" } } Loading
src/com/android/settings/wifi/WifiConfigController.java +7 −7 Original line number Diff line number Diff line Loading @@ -545,13 +545,13 @@ public class WifiConfigController implements TextWatcher, && !isValidSaePassword(mPasswordView.getText().toString())))) { passwordInvalid = true; } if ((mSsidView != null && mSsidView.length() == 0) if ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid) { // If Accesspoint is not saved, apply passwordInvalid check || ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid enabled = false; } else if (mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid && mPasswordView.length() > 0) { // If AccessPoint is saved (modifying network) and password is changed, apply // Invalid password check || mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid && mPasswordView.length() > 0)) { enabled = false; } else { enabled = ipAndProxyFieldsAreValid(); Loading
src/com/android/settings/wifi/WifiDialog.java +11 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; import com.android.settings.wifi.utils.SsidInputGroup; import com.android.settings.wifi.utils.WifiDialogHelper; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.wifi.AccessPoint; Loading Loading @@ -62,6 +64,7 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, private View mView; private WifiConfigController mController; private boolean mHideSubmitButton; private WifiDialogHelper mDialogHelper; /** * Creates a WifiDialog with no additional style. It displays as a dialog above the current Loading Loading @@ -115,6 +118,9 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, if (mAccessPoint == null) { mController.hideForgetButton(); } mDialogHelper = new WifiDialogHelper(this, new SsidInputGroup(getContext(), mView, R.id.ssid_layout, R.id.ssid)); } @SuppressWarnings("MissingSuperCall") // TODO: Fix me Loading Loading @@ -155,9 +161,6 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, public void onClick(DialogInterface dialogInterface, int id) { if (mListener != null) { switch (id) { case BUTTON_SUBMIT: mListener.onSubmit(this); break; case BUTTON_FORGET: if (WifiUtils.isNetworkLockedDown(getContext(), mAccessPoint.getConfig())) { RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), Loading @@ -170,6 +173,11 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, } } /** Return true to tell the parent activity to call onSubmit before onDismiss. */ public boolean shouldSubmitBeforeFinish() { return mDialogHelper.isPositive(); } @Override public int getMode() { return mMode; Loading
src/com/android/settings/wifi/WifiDialogActivity.java +3 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,9 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog @Override public void onDismiss(DialogInterface dialogInterface) { mDialog2 = null; if (mDialog != null && mDialog.shouldSubmitBeforeFinish()) { onSubmit(mDialog); } mDialog = null; finish(); } Loading
src/com/android/settings/wifi/utils/AlertDialogHelper.kt 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.wifi.utils import android.content.DialogInterface import android.util.Log import androidx.appcompat.app.AlertDialog open class AlertDialogHelper(val alertDialog: AlertDialog) { var isPositive = false init { alertDialog.setOnShowListener { alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)?.setOnClickListener { onPositiveButtonClicked() } ?: Log.e(TAG, "Can't get the positive button!") } } open fun onPositiveButtonClicked() { if (!canDismiss()) { Log.w(TAG, "Can't dismiss dialog!") return } isPositive = true alertDialog.dismiss() } open fun canDismiss() = true companion object { const val TAG = "AlertDialogHelper" } }
src/com/android/settings/wifi/utils/WifiDialogHelper.kt 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.wifi.utils import android.util.Log import androidx.appcompat.app.AlertDialog class WifiDialogHelper( alertDialog: AlertDialog, private val ssidInputGroup: SsidInputGroup? = null, ) : AlertDialogHelper(alertDialog) { override fun canDismiss(): Boolean { val isValid = ssidInputGroup?.validate() ?: true if (!isValid) Log.w(TAG, "SSID is invalid!") return isValid } companion object { const val TAG = "WifiDialogHelper" } }