From 6e546703a9d55cab1a14cb3426000997d72f56d5 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Sun, 27 Oct 2019 23:37:36 -0300 Subject: [PATCH] Show proper text for live streams watching/listening count --- .../fragments/detail/VideoDetailFragment.java | 8 +++++++- .../info_list/holder/StreamInfoItemHolder.java | 9 ++++++++- .../java/org/schabi/newpipe/util/Localization.java | 8 ++++++++ app/src/main/res/values/strings.xml | 13 +++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 915ed59cc..14e989625 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1067,7 +1067,13 @@ public class VideoDetailFragment uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy)); if (info.getViewCount() >= 0) { - videoCountView.setText(Localization.localizeViewCount(activity, info.getViewCount())); + if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) { + videoCountView.setText(Localization.listeningCount(activity, info.getViewCount())); + } else if (info.getStreamType().equals(StreamType.LIVE_STREAM)) { + videoCountView.setText(Localization.watchingCount(activity, info.getViewCount())); + } else { + videoCountView.setText(Localization.localizeViewCount(activity, info.getViewCount())); + } videoCountView.setVisibility(View.VISIBLE); } else { videoCountView.setVisibility(View.GONE); diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java index 10c81a200..6b54d0168 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java @@ -7,6 +7,7 @@ import android.widget.TextView; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.util.Localization; @@ -53,7 +54,13 @@ public class StreamInfoItemHolder extends StreamMiniInfoItemHolder { private String getStreamInfoDetailLine(final StreamInfoItem infoItem) { String viewsAndDate = ""; if (infoItem.getViewCount() >= 0) { - viewsAndDate = Localization.shortViewCount(itemBuilder.getContext(), infoItem.getViewCount()); + if (infoItem.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) { + viewsAndDate = Localization.listeningCount(itemBuilder.getContext(), infoItem.getViewCount()); + } else if (infoItem.getStreamType().equals(StreamType.LIVE_STREAM)) { + viewsAndDate = Localization.watchingCount(itemBuilder.getContext(), infoItem.getViewCount()); + } else { + viewsAndDate = Localization.shortViewCount(itemBuilder.getContext(), infoItem.getViewCount()); + } } if (!TextUtils.isEmpty(infoItem.getTextualUploadDate())) { if (viewsAndDate.isEmpty()) { 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 6835a48bd..9a6a9c96e 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -141,6 +141,14 @@ public class Localization { } } + public static String listeningCount(Context context, long listeningCount) { + return getQuantity(context, R.plurals.listening, R.string.no_one_listening, listeningCount, shortCount(context, listeningCount)); + } + + public static String watchingCount(Context context, long watchingCount) { + return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, shortCount(context, watchingCount)); + } + public static String shortViewCount(Context context, long viewCount) { return getQuantity(context, R.plurals.views, R.string.no_views, viewCount, shortCount(context, viewCount)); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de58d14bd..78dcb5244 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -263,6 +263,19 @@ %s view %s views + + No one is watching + + %s watching + %s watching + + + No one is listening + + %s listener + %s listeners + + No videos %s video