Clean <plurals> in FindActionModeCallback
Bug: 199230228
Test: make
Change-Id: I59618e5467696d3173dfb4782ce55964694a42fc
diff --git a/boot/hiddenapi/hiddenapi-max-target-q.txt b/boot/hiddenapi/hiddenapi-max-target-q.txt
index 4832dd1..f70473c 100644
--- a/boot/hiddenapi/hiddenapi-max-target-q.txt
+++ b/boot/hiddenapi/hiddenapi-max-target-q.txt
@@ -398,7 +398,7 @@
Lcom/android/internal/R$layout;->select_dialog_singlechoice:I
Lcom/android/internal/R$layout;->webview_find:I
Lcom/android/internal/R$layout;->zoom_magnify:I
-Lcom/android/internal/R$plurals;->matches_found:I
+Lcom/android/internal/R$string;->matches_found:I
Lcom/android/internal/R$raw;->loaderror:I
Lcom/android/internal/R$raw;->nodomain:I
Lcom/android/internal/R$string;->byteShort:I
diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java
index e011d51..b1d07f5 100644
--- a/core/java/android/webkit/FindActionModeCallback.java
+++ b/core/java/android/webkit/FindActionModeCallback.java
@@ -26,6 +26,7 @@
import android.text.Selection;
import android.text.Spannable;
import android.text.TextWatcher;
+import android.util.PluralsMessageFormatter;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -35,6 +36,11 @@
import android.widget.EditText;
import android.widget.TextView;
+import com.android.internal.R;
+
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @hide
*/
@@ -180,9 +186,14 @@
if (mNumberOfMatches == 0) {
mMatches.setText(com.android.internal.R.string.no_matches);
} else {
- mMatches.setText(mResources.getQuantityString(
- com.android.internal.R.plurals.matches_found, mNumberOfMatches,
- mActiveMatchIndex + 1, mNumberOfMatches));
+ Map<String, Object> arguments = new HashMap<>();
+ arguments.put("count", mActiveMatchIndex + 1);
+ arguments.put("total", mNumberOfMatches);
+
+ mMatches.setText(PluralsMessageFormatter.format(
+ mResources,
+ arguments,
+ R.string.matches_found));
}
mMatches.setVisibility(View.VISIBLE);
}
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 7eee6e3..e2a8193 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4191,12 +4191,11 @@
<!-- Displayed on the Find dialog to display the index of the highlighted
match and total number of matches found in the current page. [CHAR LIMIT=NONE] -->
- <plurals name="matches_found">
- <!-- Case of one match -->
- <item quantity="one">1 match</item>
- <!-- Case of multiple total matches -->
- <item quantity="other"><xliff:g id="index" example="2">%d</xliff:g> of <xliff:g id="total" example="137">%d</xliff:g></item>
- </plurals>
+ <string name="matches_found">{ count, plural,
+ =1 {# match}
+ other {# of {total}}}
+ }
+ </string>
<!-- Label for the "Done" button on the far left of action mode toolbars. -->
<string name="action_mode_done">Done</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 9ec1810..b2d898b 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1263,8 +1263,8 @@
<java-symbol type="plurals" name="bugreport_countdown" />
<java-symbol type="plurals" name="file_count" />
<java-symbol type="plurals" name="last_num_days" />
- <java-symbol type="plurals" name="matches_found" />
<java-symbol type="plurals" name="restr_pin_countdown" />
+ <java-symbol type="string" name="matches_found" />
<java-symbol type="plurals" name="pinpuk_attempts" />
<java-symbol type="plurals" name="ssl_ca_cert_warning" />