From 86ee94eb04de41ec8beba177baef6ab4c9dabf24 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Wed, 28 Sep 2022 14:25:19 +0200 Subject: [PATCH] show subscriber count on player page --- .../fragments/detail/VideoDetailFragment.java | 31 +++++++++++++++---- .../fragment_video_detail.xml | 1 - .../main/res/layout/fragment_video_detail.xml | 1 - 3 files changed, 25 insertions(+), 8 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 7078ecffb..bf0b63e4b 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 @@ -1561,9 +1561,9 @@ public final class VideoDetailFragment binding.detailSubChannelThumbnailView.setVisibility(View.GONE); if (!isEmpty(info.getSubChannelName())) { - displayBothUploaderAndSubChannel(info); + displayBothUploaderAndSubChannel(info, activity); } else if (!isEmpty(info.getUploaderName())) { - displayUploaderAsSubChannel(info); + displayUploaderAsSubChannel(info, activity); } else { binding.detailUploaderTextView.setVisibility(View.GONE); binding.detailUploaderThumbnailView.setVisibility(View.GONE); @@ -1676,23 +1676,42 @@ public final class VideoDetailFragment noVideoStreams ? R.drawable.ic_headset_shadow : R.drawable.ic_play_arrow_shadow); } - private void displayUploaderAsSubChannel(final StreamInfo info) { + private void displayUploaderAsSubChannel(final StreamInfo info, final Context context) { binding.detailSubChannelTextView.setText(info.getUploaderName()); binding.detailSubChannelTextView.setVisibility(View.VISIBLE); binding.detailSubChannelTextView.setSelected(true); - binding.detailUploaderTextView.setVisibility(View.GONE); + + if (info.getUploaderSubscriberCount() > -1) { + binding.detailUploaderTextView.setText( + Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount())); + binding.detailUploaderTextView.setVisibility(View.VISIBLE); + } else { + binding.detailUploaderTextView.setVisibility(View.GONE); + } } - private void displayBothUploaderAndSubChannel(final StreamInfo info) { + private void displayBothUploaderAndSubChannel(final StreamInfo info, final Context context) { binding.detailSubChannelTextView.setText(info.getSubChannelName()); binding.detailSubChannelTextView.setVisibility(View.VISIBLE); binding.detailSubChannelTextView.setSelected(true); binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE); + final StringBuilder subText = new StringBuilder(); if (!isEmpty(info.getUploaderName())) { - binding.detailUploaderTextView.setText( + subText.append( String.format(getString(R.string.video_detail_by), info.getUploaderName())); + } + if (info.getUploaderSubscriberCount() > -1) { + if (subText.length() > 0) { + subText.append(Localization.DOT_SEPARATOR); + } + subText.append( + Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount())); + } + + if (subText.length() > 0) { + binding.detailUploaderTextView.setText(subText); binding.detailUploaderTextView.setVisibility(View.VISIBLE); binding.detailUploaderTextView.setSelected(true); } else { diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml index c7b77ee9a..c2e02d6ea 100644 --- a/app/src/main/res/layout-large-land/fragment_video_detail.xml +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -321,7 +321,6 @@ android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="@dimen/video_item_detail_uploader_text_size" - android:textStyle="bold" tools:ignore="RtlHardcoded" tools:text="Uploader" /> diff --git a/app/src/main/res/layout/fragment_video_detail.xml b/app/src/main/res/layout/fragment_video_detail.xml index b407c5ca7..a93631b34 100644 --- a/app/src/main/res/layout/fragment_video_detail.xml +++ b/app/src/main/res/layout/fragment_video_detail.xml @@ -308,7 +308,6 @@ android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="@dimen/video_item_detail_uploader_text_size" - android:textStyle="bold" tools:ignore="RtlHardcoded" tools:text="Uploader" />