From 67e780def4e398fb2bd11d7105a40ce44f86e991 Mon Sep 17 00:00:00 2001 From: Calvin Pan Date: Mon, 17 Jan 2022 11:58:45 +0800 Subject: [PATCH] Clean in ChooserActivity Bug: 199230228 Test: make Change-Id: Id1364a9c67187ee4839392751f6ed41ca1b281bc --- .../com/android/internal/app/ChooserActivity.java | 13 +++++++++++-- core/res/res/values/strings.xml | 9 +++++---- core/res/res/values/symbols.xml | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index be7388bfca131..4ae6bf7e8379d 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -90,6 +90,7 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.util.HashedStringCache; import android.util.Log; +import android.util.PluralsMessageFormatter; import android.util.Size; import android.util.Slog; import android.view.LayoutInflater; @@ -216,6 +217,9 @@ public class ChooserActivity extends ResolverActivity implements private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20; public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter"; + private static final String PLURALS_COUNT = "count"; + private static final String PLURALS_FILE_NAME = "file_name"; + @VisibleForTesting public static final int LIST_VIEW_UPDATE_INTERVAL_IN_MILLIS = 250; @@ -1551,8 +1555,13 @@ public class ChooserActivity extends ResolverActivity implements } else { FileInfo fileInfo = extractFileInfo(uris.get(0), getContentResolver()); int remUriCount = uriCount - 1; - String fileName = getResources().getQuantityString(R.plurals.file_count, - remUriCount, fileInfo.name, remUriCount); + Map arguments = new HashMap<>(); + arguments.put(PLURALS_COUNT, remUriCount); + arguments.put(PLURALS_FILE_NAME, fileInfo.name); + String fileName = PluralsMessageFormatter.format( + getResources(), + arguments, + R.string.file_count); TextView fileNameView = contentPreviewLayout.findViewById( R.id.content_preview_filename); diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index c3e5b73abedc7..40fd12efe710b 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -5807,10 +5807,11 @@ Loading - - %s + %d file - %s + %d files - + {count, plural, + =1 {{file_name} + # file} + other {{file_name} + # files} + } + No recommended people to share with diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index c5dcbebe95d7f..76e0994d7b185 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1261,9 +1261,9 @@ - +