From a768fb8065b66d0ef84bcc3ad0c72d7dbd3f3dae Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Wed, 24 Mar 2021 20:22:35 -0700 Subject: [PATCH] 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 --- res/values/strings.xml | 6 ++++++ .../autofill/PasswordsPreferenceController.java | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 50a8eea39e5..4ef23a5d21f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11686,6 +11686,12 @@ Autofill service Passwords + + + %1$d password + %1$d passwords + auto, fill, autofill, password diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java index 123addac7e2..47882ded46e 100644 --- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java +++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java @@ -50,6 +50,7 @@ import androidx.preference.PreferenceScreen; 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 @@ public class PasswordsPreferenceController extends BasePreferenceController final MutableLiveData 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);