Show error message when inputting invalid audio sharing password.

Test: atest
Bug: b/356071394
Flag: com.android.settingslib.flags.enable_le_audio_sharing
Change-Id: I6e1ff6d32175ad6e4286db922645d608a2708c45
This commit is contained in:
chelseahao
2024-10-28 17:14:19 +08:00
committed by Chelsea Hao
parent 75e2dc4b21
commit ae7acae24c
6 changed files with 82 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ public class AudioSharingPasswordPreference extends ValidatedEditTextPreference
@Nullable private EditText mEditText;
@Nullable private CheckBox mCheckBox;
@Nullable private View mDialogMessage;
@Nullable private View mEditTextFormatAlert;
private boolean mEditable = true;
interface OnDialogEventListener {
@@ -77,6 +78,7 @@ public class AudioSharingPasswordPreference extends ValidatedEditTextPreference
mEditText = view.findViewById(android.R.id.edit);
mCheckBox = view.findViewById(R.id.audio_sharing_stream_password_checkbox);
mDialogMessage = view.findViewById(android.R.id.message);
mEditTextFormatAlert = view.findViewById(R.id.edit_alert_message);
if (mEditText == null || mCheckBox == null || mDialogMessage == null) {
Log.w(TAG, "onBindDialogView() : Invalid layout");
@@ -123,6 +125,14 @@ public class AudioSharingPasswordPreference extends ValidatedEditTextPreference
mDialogMessage.setVisibility(editable ? GONE : VISIBLE);
}
void showEditTextFormatAlert(boolean show) {
if (mEditTextFormatAlert == null) {
Log.w(TAG, "showEditTextFormatAlert() : Invalid layout");
return;
}
mEditTextFormatAlert.setVisibility(show ? VISIBLE : GONE);
}
void setChecked(boolean checked) {
if (mCheckBox == null) {
Log.w(TAG, "setChecked() : Invalid layout");

View File

@@ -136,7 +136,11 @@ public class AudioSharingPasswordPreferenceController extends BasePreferenceCont
@Override
public boolean isTextValid(String value) {
return mAudioSharingPasswordValidator.isTextValid(value);
boolean isValid = mAudioSharingPasswordValidator.isTextValid(value);
if (mPreference != null) {
mPreference.showEditTextFormatAlert(!isValid);
}
return isValid;
}
@Override