Use a Quantity String for the autofill password count.
Bug: 169455298
Test: manual - check display with sample app and different numbers of
passwords
Test: make RunSettingsRoboTests
Test: atest SettingsUnitTests:com.android.settings.applications.autofill.PasswordsPreferenceControllerTest
Change-Id: I12f2a415499c210df429088fe11c64e7431babb3
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 50a8eea..4ef23a5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11686,6 +11686,12 @@
<string name="autofill_app">Autofill service</string>
<!-- Preference category for showing auto-fill services with saved passwords. [CHAR LIMIT=60] -->
<string name="autofill_passwords">Passwords</string>
+ <!-- Summary for passwords settings that shows how many passwords are saved for each autofill
+ service. [CHAR LIMIT=NONE] -->
+ <plurals name="autofill_passwords_count">
+ <item quantity="one"><xliff:g id="count">%1$d</xliff:g> password</item>
+ <item quantity="other"><xliff:g id="count">%1$d</xliff:g> passwords</item>
+ </plurals>
<!-- Keywords for the auto-fill feature. [CHAR LIMIT=NONE] -->
<string name="autofill_keywords">auto, fill, autofill, password</string>
diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
index 123adda..47882de 100644
--- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
+++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
@@ -50,6 +50,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
+import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
@@ -130,9 +131,13 @@
final MutableLiveData<Integer> passwordCount = new MutableLiveData<>();
passwordCount.observe(
- // TODO(b/169455298): Validate the result.
- // TODO(b/169455298): Use a Quantity String resource.
- mLifecycleOwner, count -> pref.setSummary("" + count + " passwords saved"));
+ mLifecycleOwner, count -> {
+ // TODO(b/169455298): Validate the result.
+ final CharSequence summary =
+ mContext.getResources().getQuantityString(
+ R.plurals.autofill_passwords_count, count, count);
+ pref.setSummary(summary);
+ });
// TODO(b/169455298): Limit the number of concurrent queries.
// TODO(b/169455298): Cache the results for some time.
requestSavedPasswordCount(service, user, passwordCount);