Add limitation for the password
The UI allows the password as below cases. 1. empty case 2. at least 4 characters and fewer than 16 characters Bug: 263698307 Test: build pass and local test pass Change-Id: Ie1952cde16f4f260be2ca42b00b0de1d21a9f208 Merged-In: I216d91c083dfe36cbda84481a8d0a308cfa8bfa1
This commit is contained in:
committed by
SongFerng Wang
parent
30eb433a3f
commit
244d54d8a3
@@ -2348,7 +2348,10 @@
|
||||
<string name="media_output_broadcast_update_error">Can\u2019t save. Try again.</string>
|
||||
<!-- The error message when Broadcast name/code update failed and can't change again[CHAR LIMIT=60] -->
|
||||
<string name="media_output_broadcast_last_update_error">Can\u2019t save.</string>
|
||||
|
||||
<!-- The hint message when Broadcast code is less than 4 characters [CHAR LIMIT=60] -->
|
||||
<string name="media_output_broadcast_code_hint_no_less_than_min">Use at least 4 characters</string>
|
||||
<!-- The hint message when Broadcast code is more than 16 characters [CHAR LIMIT=60] -->
|
||||
<string name="media_output_broadcast_code_hint_no_more_than_max">Use fewer than 16 characters</string>
|
||||
|
||||
<!-- Label for clip data when copying the build number off QS [CHAR LIMIT=NONE]-->
|
||||
<string name="build_number_clip_data_label">Build number</string>
|
||||
|
||||
@@ -20,6 +20,8 @@ import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.HideReturnsTransformationMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.Log;
|
||||
@@ -64,11 +66,51 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog {
|
||||
private String mCurrentBroadcastName;
|
||||
private String mCurrentBroadcastCode;
|
||||
private boolean mIsStopbyUpdateBroadcastCode = false;
|
||||
private TextWatcher mTextWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (mAlertDialog == null || mBroadcastErrorMessage == null) {
|
||||
return;
|
||||
}
|
||||
boolean breakBroadcastCodeRuleTextLengthLessThanMin =
|
||||
s.length() > 0 && s.length() < BROADCAST_CODE_MIN_LENGTH;
|
||||
boolean breakBroadcastCodeRuleTextLengthMoreThanMax =
|
||||
s.length() > BROADCAST_CODE_MAX_LENGTH;
|
||||
boolean breakRule = breakBroadcastCodeRuleTextLengthLessThanMin
|
||||
|| breakBroadcastCodeRuleTextLengthMoreThanMax;
|
||||
|
||||
if (breakBroadcastCodeRuleTextLengthLessThanMin) {
|
||||
mBroadcastErrorMessage.setText(
|
||||
R.string.media_output_broadcast_code_hint_no_less_than_min);
|
||||
} else if (breakBroadcastCodeRuleTextLengthMoreThanMax) {
|
||||
mBroadcastErrorMessage.setText(
|
||||
R.string.media_output_broadcast_code_hint_no_more_than_max);
|
||||
}
|
||||
|
||||
mBroadcastErrorMessage.setVisibility(breakRule ? View.VISIBLE : View.INVISIBLE);
|
||||
Button positiveBtn = mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
if (positiveBtn != null) {
|
||||
positiveBtn.setEnabled(breakRule ? false : true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static final int METADATA_BROADCAST_NAME = 0;
|
||||
static final int METADATA_BROADCAST_CODE = 1;
|
||||
|
||||
private static final int MAX_BROADCAST_INFO_UPDATE = 3;
|
||||
private static final int BROADCAST_CODE_MAX_LENGTH = 16;
|
||||
private static final int BROADCAST_CODE_MIN_LENGTH = 4;
|
||||
|
||||
MediaOutputBroadcastDialog(Context context, boolean aboveStatusbar,
|
||||
BroadcastSender broadcastSender, MediaOutputController mediaOutputController) {
|
||||
@@ -219,6 +261,9 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog {
|
||||
R.layout.media_output_broadcast_update_dialog, null);
|
||||
final EditText editText = layout.requireViewById(R.id.broadcast_edit_text);
|
||||
editText.setText(editString);
|
||||
if (isBroadcastCode) {
|
||||
editText.addTextChangedListener(mTextWatcher);
|
||||
}
|
||||
mBroadcastErrorMessage = layout.requireViewById(R.id.broadcast_error_message);
|
||||
mAlertDialog = new Builder(mContext)
|
||||
.setTitle(isBroadcastCode ? R.string.media_output_broadcast_code
|
||||
|
||||
Reference in New Issue
Block a user