Improve UX of Wi-Fi QR code scanner enrollee flow
1. Do not start WifiSettings after enrollee success 2. Return WifiConfiguration to the calling object after enrollee success 3. In WifiDialog, do not show scan button if Save button is not visible to users 4. Fix scanner button may not respond problem by setting listener for scanner button of ssid field and password field 5. If SSID is assigned, only allow to enrollee for the network of assigned SSID Bug: 124416152 Test: manual test Change-Id: Ic5241c4767eaa8ea01782817d8302d8b0572ab36
This commit is contained in:
@@ -18,15 +18,16 @@ package com.android.settings.wifi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.wifi.dpp.WifiDppUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
@@ -40,6 +41,9 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
|
||||
|
||||
default void onSubmit(WifiDialog dialog) {
|
||||
}
|
||||
|
||||
default void onScan(WifiDialog dialog, String ssid) {
|
||||
}
|
||||
}
|
||||
|
||||
private static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
|
||||
@@ -80,18 +84,6 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, /* root */ null);
|
||||
final ImageButton scannerButton = mView.findViewById(R.id.password_scanner_button);
|
||||
if (scannerButton != null) {
|
||||
scannerButton.setOnClickListener((View v) -> {
|
||||
String ssid = null;
|
||||
if (mAccessPoint != null) {
|
||||
ssid = mAccessPoint.getSsidStr();
|
||||
}
|
||||
// Launch QR code scanner to join a network.
|
||||
getContext().startActivity(
|
||||
WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid));
|
||||
});
|
||||
}
|
||||
setView(mView);
|
||||
mController = new WifiConfigController(this, mView, mAccessPoint, mMode);
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -109,6 +101,35 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
View.OnClickListener onClickScannerButtonListener = v -> {
|
||||
if (mListener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String ssid = null;
|
||||
if (mAccessPoint == null) {
|
||||
final TextView ssidEditText = findViewById(R.id.ssid);
|
||||
ssid = ssidEditText.getText().toString();
|
||||
} else {
|
||||
ssid = mAccessPoint.getSsidStr();
|
||||
}
|
||||
mListener.onScan(/* WifiDialog */ this, ssid);
|
||||
};
|
||||
|
||||
final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button);
|
||||
ssidScannerButton.setOnClickListener(onClickScannerButtonListener);
|
||||
|
||||
final ImageButton passwordScannerButton = findViewById(R.id.password_scanner_button);
|
||||
passwordScannerButton.setOnClickListener(onClickScannerButtonListener);
|
||||
|
||||
if (mHideSubmitButton) {
|
||||
ssidScannerButton.setVisibility(View.GONE);
|
||||
passwordScannerButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
mController.updatePassword();
|
||||
|
Reference in New Issue
Block a user