Using plurals to define for min length of string

When a number of min length of a string is singular,
the definition of <plurals> can show a localization with a correct
grammar for singular.

Bug: http://b/78537276
Test: Manual
Change-Id: Ic5d94078f1c80a81a37ff7c11d5d5e106a764bed
This commit is contained in:
prochinwang
2018-04-30 15:03:41 +08:00
committed by Prochin Wang
parent 0e8e89f576
commit ae8fdff1af
2 changed files with 28 additions and 12 deletions

View File

@@ -843,14 +843,20 @@ public class ChooseLockPassword extends SettingsActivity {
mPasswordMinNonLetter));
}
if ((errorCode & TOO_SHORT) > 0) {
messages.add(getString(mIsAlphaMode ?
R.string.lockpassword_password_too_short
: R.string.lockpassword_pin_too_short, mPasswordMinLength));
messages.add(getResources().getQuantityString(
mIsAlphaMode
? R.plurals.lockpassword_password_too_short
: R.plurals.lockpassword_pin_too_short,
mPasswordMinLength,
mPasswordMinLength));
}
if ((errorCode & TOO_LONG) > 0) {
messages.add(getString(mIsAlphaMode ?
R.string.lockpassword_password_too_long
: R.string.lockpassword_pin_too_long, mPasswordMaxLength + 1));
messages.add(getResources().getQuantityString(
mIsAlphaMode
? R.plurals.lockpassword_password_too_long
: R.plurals.lockpassword_pin_too_long,
mPasswordMaxLength + 1,
mPasswordMaxLength + 1));
}
if ((errorCode & CONTAIN_SEQUENTIAL_DIGITS) > 0) {
messages.add(getString(R.string.lockpassword_pin_no_sequential_digits));