Merge "Fixed accessibility issues in Wi-Fi SSID view for SUW" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
fb74cf60eb
@@ -545,13 +545,13 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
&& !isValidSaePassword(mPasswordView.getText().toString())))) {
|
&& !isValidSaePassword(mPasswordView.getText().toString())))) {
|
||||||
passwordInvalid = true;
|
passwordInvalid = true;
|
||||||
}
|
}
|
||||||
if ((mSsidView != null && mSsidView.length() == 0)
|
if ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid) {
|
||||||
// If Accesspoint is not saved, apply passwordInvalid check
|
// If Accesspoint is not saved, apply passwordInvalid check
|
||||||
|| ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid
|
enabled = false;
|
||||||
// If AccessPoint is saved (modifying network) and password is changed, apply
|
} else if (mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid
|
||||||
// Invalid password check
|
&& mPasswordView.length() > 0) {
|
||||||
|| mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid
|
// If AccessPoint is saved (modifying network) and password is changed, apply
|
||||||
&& mPasswordView.length() > 0)) {
|
// Invalid password check
|
||||||
enabled = false;
|
enabled = false;
|
||||||
} else {
|
} else {
|
||||||
enabled = ipAndProxyFieldsAreValid();
|
enabled = ipAndProxyFieldsAreValid();
|
||||||
|
@@ -28,6 +28,8 @@ import android.widget.TextView;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.android.settings.R;
|
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.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||||
import com.android.settingslib.wifi.AccessPoint;
|
import com.android.settingslib.wifi.AccessPoint;
|
||||||
@@ -62,6 +64,7 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
|
|||||||
private View mView;
|
private View mView;
|
||||||
private WifiConfigController mController;
|
private WifiConfigController mController;
|
||||||
private boolean mHideSubmitButton;
|
private boolean mHideSubmitButton;
|
||||||
|
private WifiDialogHelper mDialogHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a WifiDialog with no additional style. It displays as a dialog above the current
|
* Creates a WifiDialog with no additional style. It displays as a dialog above the current
|
||||||
@@ -115,6 +118,9 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
|
|||||||
if (mAccessPoint == null) {
|
if (mAccessPoint == null) {
|
||||||
mController.hideForgetButton();
|
mController.hideForgetButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDialogHelper = new WifiDialogHelper(this,
|
||||||
|
new SsidInputGroup(getContext(), mView, R.id.ssid_layout, R.id.ssid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
|
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
|
||||||
@@ -155,9 +161,6 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
|
|||||||
public void onClick(DialogInterface dialogInterface, int id) {
|
public void onClick(DialogInterface dialogInterface, int id) {
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case BUTTON_SUBMIT:
|
|
||||||
mListener.onSubmit(this);
|
|
||||||
break;
|
|
||||||
case BUTTON_FORGET:
|
case BUTTON_FORGET:
|
||||||
if (WifiUtils.isNetworkLockedDown(getContext(), mAccessPoint.getConfig())) {
|
if (WifiUtils.isNetworkLockedDown(getContext(), mAccessPoint.getConfig())) {
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
||||||
@@ -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
|
@Override
|
||||||
public int getMode() {
|
public int getMode() {
|
||||||
return mMode;
|
return mMode;
|
||||||
|
@@ -346,6 +346,9 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
|||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialogInterface) {
|
public void onDismiss(DialogInterface dialogInterface) {
|
||||||
mDialog2 = null;
|
mDialog2 = null;
|
||||||
|
if (mDialog != null && mDialog.shouldSubmitBeforeFinish()) {
|
||||||
|
onSubmit(mDialog);
|
||||||
|
}
|
||||||
mDialog = null;
|
mDialog = null;
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
49
src/com/android/settings/wifi/utils/AlertDialogHelper.kt
Normal file
49
src/com/android/settings/wifi/utils/AlertDialogHelper.kt
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
}
|
||||||
|
}
|
36
src/com/android/settings/wifi/utils/WifiDialogHelper.kt
Normal file
36
src/com/android/settings/wifi/utils/WifiDialogHelper.kt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
}
|
||||||
|
}
|
@@ -145,14 +145,6 @@ public class WifiConfigControllerTest {
|
|||||||
.isEqualTo(View.GONE);
|
.isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isSubmittable_noSSID_shouldReturnFalse() {
|
|
||||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
|
||||||
assertThat(ssid).isNotNull();
|
|
||||||
ssid.setText("");
|
|
||||||
assertThat(mController.isSubmittable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_longPsk_shouldReturnFalse() {
|
public void isSubmittable_longPsk_shouldReturnFalse() {
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
|
@@ -349,4 +349,14 @@ public class WifiDialogActivityTest {
|
|||||||
|
|
||||||
verify(mActivity).dismissDialog();
|
verify(mActivity).dismissDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onDismiss_shouldSubmitBeforeFinish_callOnSubmit() {
|
||||||
|
mActivity.mDialog = mWifiDialog;
|
||||||
|
when(mWifiDialog.shouldSubmitBeforeFinish()).thenReturn(true);
|
||||||
|
|
||||||
|
mActivity.onDismiss(mWifiDialog);
|
||||||
|
|
||||||
|
verify(mActivity).onSubmit(mWifiDialog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user