Commit c04c65a2 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Remove pluralizable capabilities of counters labels.

This CL removes the special treatment applied to counters labels in
order to make the label pluralizable. Given the special format of
ChoiceLabel, some characters (like '<', '#' or '|') make the
application crash.

Those special characters can be escaped with ' but they will then be
displayed in the string, which is undesired.

We can safely remove this pluralizable logic as it is not used by any
scripts (the text shown is extracted from the website).

Bug: b/139643534
Change-Id: I88109b2f374c5c343545603a28aac38a8a190b5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763682Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Auto-Submit: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689448}
parent 2049435c
......@@ -4,17 +4,13 @@
package org.chromium.chrome.browser.autofill_assistant.form;
import java.text.ChoiceFormat;
abstract class AssistantFormCounter {
private final String mLabel;
private final String mSubtext;
private final ChoiceFormat mLabelChoiceFormat;
private AssistantFormCounter(String label, String subtext) {
mLabel = label;
mSubtext = subtext;
mLabelChoiceFormat = new ChoiceFormat(label);
}
String getLabel() {
......@@ -25,10 +21,6 @@ abstract class AssistantFormCounter {
return mSubtext;
}
ChoiceFormat getLabelChoiceFormat() {
return mLabelChoiceFormat;
}
abstract int getValue();
abstract boolean canDecreaseValue();
......
......@@ -213,9 +213,6 @@ class AssistantFormCounterInput extends AssistantFormInput {
private void updateLabelAndValue(AssistantFormCounter counter, CounterViewHolder view) {
// Update the label.
String label = counter.getLabel();
if (counter.getLabelChoiceFormat().getLimits().length > 0) {
label = counter.getLabelChoiceFormat().format(counter.getValue());
}
label = label.replaceAll(QUOTED_VALUE, Integer.toString(counter.getValue()));
view.mLabelView.setText(label);
......
......@@ -1460,8 +1460,7 @@ message FormInputProto {
message CounterInputProto {
// A single counter.
message Counter {
// The label shown with the counter, that handles plurals using the format
// defined by java.text.ChoiceFormat. All occurrences of the '{value}'
// The label shown with the counter. All occurrences of the '{value}'
// substring will be replaced by the current counter value.
optional string label = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment