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

Commit 288a5971 authored by Weng Su's avatar Weng Su
Browse files

Fixed accessibility issues in Wi-Fi SSID view for SUW

- Keep the Save button enabled at all times

- Show "Enter the SSID" to remind the user

Bug: 386897596
Flag: EXEMPT bugfix
Test: Manual testing
  atest WifiDialogActivityTest \
        WifiConfigControllerTest
Change-Id: I577e78c34cbaa0640479adf09a916a526500fe68
parent 5e79d186
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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();
+11 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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
@@ -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
@@ -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(),
@@ -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;
+3 −0
Original line number Diff line number Diff line
@@ -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();
    }
+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"
    }
}
+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