summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calvin Pan <calvinpan@google.com> 2022-01-17 11:52:08 +0800
committer Calvin Pan <calvinpan@google.com> 2022-01-24 14:46:19 +0800
commita9ace2c62033c59d3bc5e4284c44119394e70257 (patch)
tree14d3fba2c8eab7d6aa91aa1583462cb765a7de9b
parent9e38ebf366f52f7b29105705d9ea3a7ab74efe5b (diff)
Clean <plurals> in FindActionModeCallback
Bug: 199230228 Test: make Change-Id: I59618e5467696d3173dfb4782ce55964694a42fc
-rw-r--r--boot/hiddenapi/hiddenapi-max-target-q.txt2
-rw-r--r--core/java/android/webkit/FindActionModeCallback.java17
-rw-r--r--core/res/res/values/strings.xml11
-rw-r--r--core/res/res/values/symbols.xml2
4 files changed, 21 insertions, 11 deletions
diff --git a/boot/hiddenapi/hiddenapi-max-target-q.txt b/boot/hiddenapi/hiddenapi-max-target-q.txt
index 4832dd184ec5..f70473c313e4 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_multichoice:I
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 e011d51c51fd..b1d07f59dc4e 100644
--- a/core/java/android/webkit/FindActionModeCallback.java
+++ b/core/java/android/webkit/FindActionModeCallback.java
@@ -26,6 +26,7 @@ import android.text.Editable;
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.view.inputmethod.InputMethodManager;
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 @@ public class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
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 7eee6e3cddcb..e2a8193f171f 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 9ec1810f7cb5..b2d898bd1920 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" />