diff options
author | 2022-01-17 12:00:22 +0800 | |
---|---|---|
committer | 2022-01-26 11:55:10 +0800 | |
commit | bf4e15d0176c5e0d24ddcb84d839b7056faf6d16 (patch) | |
tree | 56b9cc5d27105b7f6953ffb161d8d2d491a16c9b | |
parent | 67e780def4e398fb2bd11d7105a40ce44f86e991 (diff) |
Clean <plurals> in keyguard
Bug: 199230228
Test: make
Change-Id: I03723cfe18e5c948ca1896c5c2c389f46c48d891
4 files changed, 25 insertions, 15 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 40fd12efe710..5242b955917b 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4557,11 +4557,6 @@ <string name="kg_wrong_password">Wrong Password</string> <!-- Message shown when user enters wrong PIN --> <string name="kg_wrong_pin">Wrong PIN</string> - <!-- Countdown message shown after too many failed unlock attempts --> - <plurals name="kg_too_many_failed_attempts_countdown"> - <item quantity="one">Try again in 1 second.</item> - <item quantity="other">Try again in <xliff:g id="number">%d</xliff:g> seconds.</item> - </plurals> <!-- Instructions for using the pattern unlock screen --> <string name="kg_pattern_instructions">Draw your pattern</string> <!-- Instructions for using the SIM PIN unlock screen --> diff --git a/packages/SystemUI/res-keyguard/values/strings.xml b/packages/SystemUI/res-keyguard/values/strings.xml index 16010430df11..293c86e35f25 100644 --- a/packages/SystemUI/res-keyguard/values/strings.xml +++ b/packages/SystemUI/res-keyguard/values/strings.xml @@ -117,10 +117,11 @@ <!-- Message shown when user enters wrong PIN --> <string name="kg_wrong_pin">Wrong PIN</string> <!-- Countdown message shown after too many failed unlock attempts --> - <plurals name="kg_too_many_failed_attempts_countdown"> - <item quantity="one">Try again in 1 second.</item> - <item quantity="other">Try again in <xliff:g id="number">%d</xliff:g> seconds.</item> - </plurals> + <string name="kg_too_many_failed_attempts_countdown">{count, plural, + =1 {Try again in # second.} + other {Try again in # seconds.} + } + </string> <!-- Instructions for using the SIM PIN unlock screen --> <string name="kg_sim_pin_instructions">Enter SIM PIN.</string> <!-- Instructions for using the SIM PIN unlock screen when there's more than one SIM --> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index 1c4559eb0364..d5a0201d13e5 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -25,6 +25,7 @@ import android.content.res.ColorStateList; import android.os.AsyncTask; import android.os.CountDownTimer; import android.os.SystemClock; +import android.util.PluralsMessageFormatter; import android.view.KeyEvent; import com.android.internal.util.LatencyTracker; @@ -38,6 +39,9 @@ import com.android.systemui.R; import com.android.systemui.classifier.FalsingClassifier; import com.android.systemui.classifier.FalsingCollector; +import java.util.HashMap; +import java.util.Map; + public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKeyInputView> extends KeyguardInputViewController<T> { private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; @@ -153,9 +157,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey @Override public void onTick(long millisUntilFinished) { int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0); - mMessageAreaController.setMessage(mView.getResources().getQuantityString( - R.plurals.kg_too_many_failed_attempts_countdown, - secondsRemaining, secondsRemaining)); + Map<String, Object> arguments = new HashMap<>(); + arguments.put("count", secondsRemaining); + mMessageAreaController.setMessage(PluralsMessageFormatter.format( + mView.getResources(), + arguments, + R.string.kg_too_many_failed_attempts_countdown)); } @Override diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java index 94e07b713915..900f28213114 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java @@ -23,6 +23,7 @@ import android.content.res.ColorStateList; import android.os.AsyncTask; import android.os.CountDownTimer; import android.os.SystemClock; +import android.util.PluralsMessageFormatter; import android.view.MotionEvent; import android.view.View; @@ -40,7 +41,9 @@ import com.android.systemui.classifier.FalsingClassifier; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.statusbar.policy.DevicePostureController; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class KeyguardPatternViewController extends KeyguardInputViewController<KeyguardPatternView> { @@ -368,9 +371,13 @@ public class KeyguardPatternViewController @Override public void onTick(long millisUntilFinished) { final int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0); - mMessageAreaController.setMessage(mView.getResources().getQuantityString( - R.plurals.kg_too_many_failed_attempts_countdown, - secondsRemaining, secondsRemaining)); + Map<String, Object> arguments = new HashMap<>(); + arguments.put("count", secondsRemaining); + + mMessageAreaController.setMessage(PluralsMessageFormatter.format( + mView.getResources(), + arguments, + R.string.kg_too_many_failed_attempts_countdown)); } @Override |