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
This commit is contained in:
Ahaan Ugale
2021-03-24 20:22:35 -07:00
parent 448dac80de
commit a768fb8065
2 changed files with 14 additions and 3 deletions

View File

@@ -11686,6 +11686,12 @@
<string name="autofill_app">Autofill service</string> <string name="autofill_app">Autofill service</string>
<!-- Preference category for showing auto-fill services with saved passwords. [CHAR LIMIT=60] --> <!-- Preference category for showing auto-fill services with saved passwords. [CHAR LIMIT=60] -->
<string name="autofill_passwords">Passwords</string> <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] --> <!-- Keywords for the auto-fill feature. [CHAR LIMIT=NONE] -->
<string name="autofill_keywords">auto, fill, autofill, password</string> <string name="autofill_keywords">auto, fill, autofill, password</string>

View File

@@ -50,6 +50,7 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver; import com.android.internal.os.IResultReceiver;
import com.android.settings.R;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
@@ -130,9 +131,13 @@ public class PasswordsPreferenceController extends BasePreferenceController
final MutableLiveData<Integer> passwordCount = new MutableLiveData<>(); final MutableLiveData<Integer> passwordCount = new MutableLiveData<>();
passwordCount.observe( passwordCount.observe(
mLifecycleOwner, count -> {
// TODO(b/169455298): Validate the result. // TODO(b/169455298): Validate the result.
// TODO(b/169455298): Use a Quantity String resource. final CharSequence summary =
mLifecycleOwner, count -> pref.setSummary("" + count + " passwords saved")); 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): Limit the number of concurrent queries.
// TODO(b/169455298): Cache the results for some time. // TODO(b/169455298): Cache the results for some time.
requestSavedPasswordCount(service, user, passwordCount); requestSavedPasswordCount(service, user, passwordCount);