Skip to content

Commit

Permalink
Use proper plurals when showing number of episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteHamster committed Feb 15, 2024
1 parent c07ae17 commit 06fdc1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;
import java.util.Locale;

import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
Expand Down Expand Up @@ -477,9 +476,8 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
}

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;
Expand Down
1 change: 0 additions & 1 deletion ui/i18n/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<string name="description_label">Description</string>
<string name="shownotes_label">Shownotes</string>
<string name="shownotes_contentdescription">swipe up to read shownotes</string>
<string name="episodes_suffix">\u0020episodes</string>
<string name="close_label">Close</string>
<string name="retry_label">Retry</string>
<string name="auto_download_label">Include in auto downloads</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import de.danoeh.antennapod.ui.statistics.feed.FeedStatisticsDialogFragment;

import java.util.List;
import java.util.Locale;

/**
* Adapter for the download statistics list.
Expand Down Expand Up @@ -45,10 +44,10 @@ protected PieChartView.PieChartData generateChartData(List<StatisticsItem> stati

@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(
Expand Down

0 comments on commit 06fdc1c

Please sign in to comment.