From 914d3c4a66ae5d32b4badd9e49c3e2961ca40ddc Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 20 Mar 2020 21:43:17 +0100 Subject: [PATCH] Use "mini" stream count alternatives for info items Note: more_than_100_videos_mini and infinite_videos_mini are untranslatable --- .../holder/PlaylistMiniInfoItemHolder.java | 2 +- .../local/holder/LocalPlaylistItemHolder.java | 4 ++-- .../local/holder/RemotePlaylistItemHolder.java | 4 ++-- .../org/schabi/newpipe/util/Localization.java | 16 ++++++++++++++-- app/src/main/res/values/strings.xml | 6 ++++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java index 2b0c2ef28..d4af63062 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java @@ -43,7 +43,7 @@ public class PlaylistMiniInfoItemHolder extends InfoItemHolder { itemTitleView.setText(item.getName()); itemStreamCountView.setText(Localization - .localizeStreamCount(itemStreamCountView.getContext(), item.getStreamCount())); + .localizeStreamCountMini(itemStreamCountView.getContext(), item.getStreamCount())); itemUploaderView.setText(item.getUploaderName()); itemBuilder.getImageLoader() diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java index a3d72094d..458b3c30e 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java @@ -32,8 +32,8 @@ public class LocalPlaylistItemHolder extends PlaylistItemHolder { final PlaylistMetadataEntry item = (PlaylistMetadataEntry) localItem; itemTitleView.setText(item.name); - itemStreamCountView.setText(Localization.localizeStreamCount(itemStreamCountView.getContext(), - item.streamCount)); + itemStreamCountView.setText(Localization.localizeStreamCountMini( + itemStreamCountView.getContext(), item.streamCount)); itemUploaderView.setVisibility(View.INVISIBLE); itemBuilder.displayImage(item.thumbnailUrl, itemThumbnailView, diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java index 015173842..a47d61d2f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java @@ -34,8 +34,8 @@ public class RemotePlaylistItemHolder extends PlaylistItemHolder { final PlaylistRemoteEntity item = (PlaylistRemoteEntity) localItem; itemTitleView.setText(item.getName()); - itemStreamCountView.setText(Localization.localizeStreamCount(itemStreamCountView.getContext(), - item.getStreamCount())); + itemStreamCountView.setText(Localization.localizeStreamCountMini( + itemStreamCountView.getContext(), item.getStreamCount())); // Here is where the uploader name is set in the bookmarked playlists library if (!TextUtils.isEmpty(item.getUploader())) { itemUploaderView.setText(Localization.concatenateStrings(item.getUploader(), diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index c7d10438f..b8431adff 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -8,6 +8,7 @@ import android.content.res.Resources; import android.preference.PreferenceManager; import org.schabi.newpipe.extractor.ListExtractor; + import android.text.TextUtils; import android.util.DisplayMetrics; @@ -155,15 +156,26 @@ public final class Localization { public static String localizeStreamCount(final Context context, final long streamCount) { switch ((int) streamCount) { case (int) ListExtractor.ITEM_COUNT_MORE_THAN_100: - return context.getResources().getString(R.string.playlist_more_than_100_items); + return context.getResources().getString(R.string.more_than_100_videos); case (int) ListExtractor.ITEM_COUNT_INFINITE: - return context.getResources().getString(R.string.playlist_infinite_items); + return context.getResources().getString(R.string.infinite_videos); default: return getQuantity(context, R.plurals.videos, R.string.no_videos, streamCount, localizeNumber(context, streamCount)); } } + public static String localizeStreamCountMini(final Context context, final long streamCount) { + switch ((int) streamCount) { + case (int) ListExtractor.ITEM_COUNT_MORE_THAN_100: + return context.getResources().getString(R.string.more_than_100_videos_mini); + case (int) ListExtractor.ITEM_COUNT_INFINITE: + return context.getResources().getString(R.string.infinite_videos_mini); + default: + return String.valueOf(streamCount); + } + } + public static String localizeWatchingCount(final Context context, final long watchingCount) { return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, localizeNumber(context, watchingCount)); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d8641cc0f..930974668 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -284,6 +284,10 @@ %s listeners No videos + 100+ videos + ∞ videos + 100+ + %s video %s videos @@ -458,8 +462,6 @@ Playlist thumbnail changed. Could not delete playlist. Auto-generated (no uploader found) - 100+ videos - ∞ videos No Captions Fit