Clean <plurals> in FillUi

Bug: 199230228
Test: make
Change-Id: I0a31b1178e60b2e5acf312b40bf749e433b95475
This commit is contained in:
Calvin Pan
2022-01-17 12:04:32 +08:00
parent 4ffb7e8884
commit 9ebedd8f3e
3 changed files with 14 additions and 7 deletions

View File

@@ -5530,10 +5530,11 @@
<string name="autofill_picker_no_suggestions">No autofill suggestions</string>
<!-- Accessibility string to announce there are some autofill suggestions in the autofill picker. [CHAR LIMIT=NONE] -->
<plurals name="autofill_picker_some_suggestions">
<item quantity="one">One autofill suggestion</item>
<item quantity="other"><xliff:g id="count" example="Two">%1$s</xliff:g> autofill suggestions</item>
</plurals>
<string name="autofill_picker_some_suggestions">{count, plural,
=1 {One autofill suggestion}
other {# autofill suggestions}
}
</string>
<!-- Title for the autofill save dialog shown when the the contents of the activity can be saved
by an autofill service, but the service does not know what the activity represents [CHAR LIMIT=NONE] -->

View File

@@ -3506,7 +3506,7 @@
<java-symbol type="id" name="autofill_save_yes" />
<java-symbol type="string" name="autofill_error_cannot_autofill" />
<java-symbol type="string" name="autofill_picker_no_suggestions" />
<java-symbol type="plurals" name="autofill_picker_some_suggestions" />
<java-symbol type="string" name="autofill_picker_some_suggestions" />
<java-symbol type="string" name="autofill" />
<java-symbol type="string" name="autofill_picker_accessibility_title " />
<java-symbol type="string" name="autofill_update_title" />

View File

@@ -32,6 +32,7 @@ import android.service.autofill.Dataset;
import android.service.autofill.Dataset.DatasetFieldFilter;
import android.service.autofill.FillResponse;
import android.text.TextUtils;
import android.util.PluralsMessageFormatter;
import android.util.Slog;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
@@ -63,7 +64,9 @@ import com.android.server.autofill.Helper;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -898,8 +901,11 @@ final class FillUi {
if (count <= 0) {
text = mContext.getString(R.string.autofill_picker_no_suggestions);
} else {
text = mContext.getResources().getQuantityString(
R.plurals.autofill_picker_some_suggestions, count, count);
Map<String, Object> arguments = new HashMap<>();
arguments.put("count", count);
text = PluralsMessageFormatter.format(mContext.getResources(),
arguments,
R.string.autofill_picker_some_suggestions);
}
mListView.announceForAccessibility(text);
}