Merge "Show error message when inputting invalid audio sharing password." into main

This commit is contained in:
Chelsea Hao
2024-10-30 09:24:35 +00:00
committed by Android (Google) Code Review
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