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:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user