From c7c5ab567b2681a946ec756cdd17bd99128f9f54 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 16 Feb 2024 23:50:12 +0100 Subject: [PATCH] Use proper plurals when showing number of episodes (#6922) --- .../de/danoeh/antennapod/fragment/QueueFragment.java | 6 ++---- ui/i18n/src/main/res/values/strings.xml | 1 - .../downloads/DownloadStatisticsListAdapter.java | 9 ++++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index aacd05fcd..1a2b6438f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -33,7 +33,6 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.List; -import java.util.Locale; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; @@ -477,9 +476,8 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte } private void refreshInfoBar() { - String info = String.format(Locale.getDefault(), "%d%s", - queue.size(), getString(R.string.episodes_suffix)); - if (queue.size() > 0) { + String info = getResources().getQuantityString(R.plurals.num_episodes, queue.size(), queue.size()); + if (!queue.isEmpty()) { long timeLeft = 0; for (FeedItem item : queue) { float playbackSpeed = 1; diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index be9a9dcbc..060d2b29f 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -123,7 +123,6 @@ Description Shownotes swipe up to read shownotes - \u0020episodes Close Retry Include in auto downloads diff --git a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsListAdapter.java index 4839aa891..083a87514 100644 --- a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsListAdapter.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsListAdapter.java @@ -10,7 +10,6 @@ import de.danoeh.antennapod.ui.statistics.StatisticsListAdapter; import de.danoeh.antennapod.ui.statistics.feed.FeedStatisticsDialogFragment; import java.util.List; -import java.util.Locale; /** * Adapter for the download statistics list. @@ -45,10 +44,10 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter { @Override protected void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item) { - holder.value.setText(Formatter.formatShortFileSize(context, item.totalDownloadSize) - + " • " - + String.format(Locale.getDefault(), "%d%s", - item.episodesDownloadCount, context.getString(R.string.episodes_suffix))); + int numEpisodes = (int) item.episodesDownloadCount; + String text = Formatter.formatShortFileSize(context, item.totalDownloadSize); + text += " • " + context.getResources().getQuantityString(R.plurals.num_episodes, numEpisodes, numEpisodes); + holder.value.setText(text); holder.itemView.setOnClickListener(v -> { FeedStatisticsDialogFragment yourDialogFragment = FeedStatisticsDialogFragment.newInstance(