diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index 6c4d8fd014433..d51aa7939c3d8 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -1790,6 +1790,15 @@ public class TextUtils { } } + /** + * Return localized string representing the given number of selected items. + * + * @hide + */ + public static CharSequence formatSelectedCount(int count) { + return Resources.getSystem().getQuantityString(R.plurals.selected_count, count, count); + } + private static Object sLock = new Object(); private static char[] sTemp = null; diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 3b866d7d681f2..9ad4be2407844 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4186,4 +4186,9 @@ notification_template_material_inbox.xml. DO NOT TRANSLATE --> \u2026 + + + + %1$d selected + diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 8900688162332..b019adbbe1eb9 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2306,5 +2306,6 @@ + diff --git a/packages/DocumentsUI/res/values/strings.xml b/packages/DocumentsUI/res/values/strings.xml index 943104d2e0944..a4e6ce78f5230 100644 --- a/packages/DocumentsUI/res/values/strings.xml +++ b/packages/DocumentsUI/res/values/strings.xml @@ -68,9 +68,6 @@ Copy - - %1$d selected - By name diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index a789da86badd9..f4be9c5252b71 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -54,6 +54,7 @@ import android.os.OperationCanceledException; import android.os.Parcelable; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; +import android.text.TextUtils; import android.text.format.DateUtils; import android.text.format.Formatter; import android.text.format.Time; @@ -474,8 +475,7 @@ public class DirectoryFragment extends Fragment { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(R.menu.mode_directory, menu); - mode.setTitle(getResources() - .getString(R.string.mode_selected_count, mCurrentView.getCheckedItemCount())); + mode.setTitle(TextUtils.formatSelectedCount(mCurrentView.getCheckedItemCount())); return true; } @@ -571,8 +571,7 @@ public class DirectoryFragment extends Fragment { } } - mode.setTitle(getResources() - .getString(R.string.mode_selected_count, mCurrentView.getCheckedItemCount())); + mode.setTitle(TextUtils.formatSelectedCount(mCurrentView.getCheckedItemCount())); } };