Add sub-channel details to video detail fragment

This commit is contained in:
Roy Yosef 2020-04-13 23:40:44 +03:00 committed by wb9688
parent 2060312dc1
commit 1429774487
9 changed files with 211 additions and 66 deletions

View File

@ -66,6 +66,7 @@ android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
encoding 'utf-8'
}
// Required and used only by groupie

View File

@ -172,9 +172,10 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
private TextView videoUploadDateView;
private TextView videoDescriptionView;
private View uploaderRootLayout;
private TextView uploaderTextView;
private ImageView uploaderThumb;
private TextView parentChannelTextView;
private ImageView parentChannelThumb;
private TextView thumbsUpTextView;
private ImageView thumbsUpImageView;
@ -418,19 +419,25 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
this.openDownloadDialog();
}
break;
case R.id.detail_uploader_root_layout:
case R.id.detail_parent_channel_text_view:
case R.id.detail_parent_channel_thumbnail_view:
if (TextUtils.isEmpty(currentInfo.getParentChannelUrl())) {
Log.w(TAG, "Can't open parent's channel because we got no channel URL");
if (!TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
openChannel(currentInfo.getUploaderUrl(), currentInfo.getUploaderName());
}
} else {
openChannel(currentInfo.getParentChannelUrl(),
currentInfo.getParentChannelName());
}
break;
case R.id.detail_uploader_text_view:
case R.id.detail_uploader_thumbnail_view:
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
Log.w(TAG, "Can't open channel because we got no channel URL");
} else {
try {
NavigationHelper.openChannelFragment(
getFragmentManager(),
currentInfo.getServiceId(),
currentInfo.getUploaderUrl(),
currentInfo.getUploaderName());
} catch (Exception e) {
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
}
openChannel(currentInfo.getUploaderUrl(), currentInfo.getUploaderName());
}
break;
case R.id.detail_thumbnail_root_layout:
@ -447,6 +454,18 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
}
}
private void openChannel(final String parentChannelUrl, final String parentChannelName) {
try {
NavigationHelper.openChannelFragment(
getFragmentManager(),
currentInfo.getServiceId(),
parentChannelUrl,
parentChannelName);
} catch (Exception e) {
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
}
}
@Override
public boolean onLongClick(final View v) {
if (isLoading.get() || currentInfo == null) {
@ -522,9 +541,10 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
thumbsDownImageView = rootView.findViewById(R.id.detail_thumbs_down_img_view);
thumbsDisabledTextView = rootView.findViewById(R.id.detail_thumbs_disabled_view);
uploaderRootLayout = rootView.findViewById(R.id.detail_uploader_root_layout);
uploaderTextView = rootView.findViewById(R.id.detail_uploader_text_view);
uploaderThumb = rootView.findViewById(R.id.detail_uploader_thumbnail_view);
parentChannelTextView = rootView.findViewById(R.id.detail_parent_channel_text_view);
parentChannelThumb = rootView.findViewById(R.id.detail_parent_channel_thumbnail_view);
appBarLayout = rootView.findViewById(R.id.appbarlayout);
viewPager = rootView.findViewById(R.id.viewpager);
@ -554,8 +574,12 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
protected void initListeners() {
super.initListeners();
uploaderTextView.setOnClickListener(this);
uploaderThumb.setOnClickListener(this);
parentChannelTextView.setOnClickListener(this);
parentChannelThumb.setOnClickListener(this);
videoTitleRoot.setOnClickListener(this);
uploaderRootLayout.setOnClickListener(this);
thumbnailBackgroundButton.setOnClickListener(this);
detailControlsBackground.setOnClickListener(this);
detailControlsPopup.setOnClickListener(this);
@ -603,6 +627,11 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS, onFailListener);
}
if (!TextUtils.isEmpty(info.getParentChannelAvatarUrl())) {
IMAGE_LOADER.displayImage(info.getParentChannelAvatarUrl(), parentChannelThumb,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
}
if (!TextUtils.isEmpty(info.getUploaderAvatarUrl())) {
IMAGE_LOADER.displayImage(info.getUploaderAvatarUrl(), uploaderThumb,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
@ -964,7 +993,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
@NonNull final StreamInfo info,
@NonNull final Stream selectedStream) {
NavigationHelper.playOnExternalPlayer(context, currentInfo.getName(),
currentInfo.getUploaderName(), selectedStream);
currentInfo.getParentChannelName(), selectedStream);
final HistoryRecordManager recordManager = new HistoryRecordManager(requireContext());
disposables.add(recordManager.onViewed(info).onErrorComplete()
@ -1097,9 +1126,9 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
}
IMAGE_LOADER.cancelDisplayTask(thumbnailImageView);
IMAGE_LOADER.cancelDisplayTask(uploaderThumb);
IMAGE_LOADER.cancelDisplayTask(parentChannelThumb);
thumbnailImageView.setImageBitmap(null);
uploaderThumb.setImageBitmap(null);
parentChannelThumb.setImageBitmap(null);
}
@Override
@ -1127,13 +1156,17 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
animateView(thumbnailPlayButton, true, 200);
videoTitleTextView.setText(name);
if (!TextUtils.isEmpty(info.getUploaderName())) {
uploaderTextView.setText(info.getUploaderName());
uploaderTextView.setVisibility(View.VISIBLE);
uploaderTextView.setSelected(true);
if (!TextUtils.isEmpty(info.getParentChannelName())) {
displayBothUploaderAndParentChannel(info);
} else if (!TextUtils.isEmpty(info.getUploaderName())) {
displayUploaderAsParentChannel(info);
} else {
parentChannelThumb.setVisibility(View.GONE);
uploaderTextView.setVisibility(View.GONE);
uploaderThumb.setVisibility(View.GONE);
}
parentChannelThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
if (info.getViewCount() >= 0) {
@ -1264,6 +1297,28 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
viewPager.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE);
}
private void displayUploaderAsParentChannel(final StreamInfo info) {
parentChannelTextView.setText(info.getUploaderName());
parentChannelTextView.setVisibility(View.VISIBLE);
parentChannelTextView.setSelected(true);
parentChannelThumb.setVisibility(View.GONE);
uploaderTextView.setVisibility(View.GONE);
}
private void displayBothUploaderAndParentChannel(final StreamInfo info) {
parentChannelTextView.setText(info.getParentChannelName());
parentChannelTextView.setVisibility(View.VISIBLE);
parentChannelTextView.setSelected(true);
if (!TextUtils.isEmpty(info.getUploaderName())) {
uploaderTextView.setText("By " + info.getUploaderName());
uploaderTextView.setVisibility(View.VISIBLE);
uploaderTextView.setSelected(true);
} else {
uploaderTextView.setVisibility(View.GONE);
}
}
public void openDownloadDialog() {
try {

View File

@ -251,28 +251,66 @@
android:focusable="true"
android:padding="6dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_uploader_thumbnail_view"
android:layout_width="@dimen/video_item_detail_uploader_image_size"
android:layout_height="@dimen/video_item_detail_uploader_image_size"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/buddy" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/detail_uploader_text_view"
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_uploader_thumbnail_view"
android:layout_width="@dimen/playlist_detail_uploader_image_size"
android:layout_height="@dimen/playlist_detail_uploader_image_size"
android:layout_gravity="bottom|right"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/buddy" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_parent_channel_thumbnail_view"
android:layout_width="@dimen/video_item_detail_uploader_image_size"
android:layout_height="@dimen/video_item_detail_uploader_image_size"
android:layout_gravity="bottom|right"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/buddy" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
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" />
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/detail_parent_channel_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_parent_channel_text_size"
android:textStyle="bold"
tools:ignore="RtlHardcoded"
tools:text="Channel" />
<TextView
android:id="@+id/detail_uploader_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
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" />
</LinearLayout>
<!--<Button
android:id="@+id/detail_uploader_subscribe"

View File

@ -245,29 +245,67 @@
android:orientation="horizontal"
android:padding="6dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_uploader_thumbnail_view"
android:layout_width="@dimen/video_item_detail_uploader_image_size"
android:layout_height="@dimen/video_item_detail_uploader_image_size"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/buddy"
tools:ignore="RtlHardcoded" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/detail_uploader_text_view"
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_uploader_thumbnail_view"
android:layout_width="@dimen/video_item_detail_uploader_image_size"
android:layout_height="@dimen/video_item_detail_uploader_image_size"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/buddy"
tools:ignore="RtlHardcoded" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_parent_channel_thumbnail_view"
android:layout_width="@dimen/video_item_detail_parent_channel_image_size"
android:layout_height="@dimen/video_item_detail_parent_channel_image_size"
android:layout_gravity="bottom|right"
android:contentDescription="@string/detail_parent_channel_thumbnail_view_description"
android:src="@drawable/buddy"
tools:ignore="RtlHardcoded" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
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" />
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/detail_parent_channel_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_parent_channel_text_size"
android:textStyle="normal|bold"
tools:ignore="RtlHardcoded"
tools:text="Channel" />
<TextView
android:id="@+id/detail_uploader_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
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" />
</LinearLayout>
<!--<Button
android:id="@+id/detail_uploader_subscribe"

View File

@ -25,7 +25,8 @@
<dimen name="video_item_detail_title_text_size">16sp</dimen>
<dimen name="video_item_detail_views_text_size">14sp</dimen>
<dimen name="video_item_detail_likes_text_size">13sp</dimen>
<dimen name="video_item_detail_uploader_text_size">16sp</dimen>
<dimen name="video_item_detail_uploader_text_size">12sp</dimen>
<dimen name="video_item_detail_parent_channel_text_size">16sp</dimen>
<dimen name="video_item_detail_upload_date_text_size">14sp</dimen>
<dimen name="video_item_detail_description_text_size">14sp</dimen>
<dimen name="video_item_detail_next_text_size">17sp</dimen>
@ -33,6 +34,7 @@
<dimen name="channel_rss_title_size">14sp</dimen>
<!-- Elements Size -->
<dimen name="video_item_detail_uploader_image_size">42dp</dimen>
<dimen name="video_item_detail_parent_channel_image_size">22dp</dimen>
<dimen name="video_item_detail_like_image_height">20sp</dimen>
<dimen name="video_item_detail_like_image_width">20sp</dimen>
<dimen name="channel_avatar_size">90dp</dimen>

View File

@ -8,12 +8,14 @@
<dimen name="video_item_detail_title_text_size">16sp</dimen>
<dimen name="video_item_detail_views_text_size">16sp</dimen>
<dimen name="video_item_detail_likes_text_size">14sp</dimen>
<dimen name="video_item_detail_uploader_text_size">16sp</dimen>
<dimen name="video_item_detail_parent_channel_text_size">16sp</dimen>
<dimen name="video_item_detail_uploader_text_size">12sp</dimen>
<dimen name="video_item_detail_upload_date_text_size">16sp</dimen>
<dimen name="video_item_detail_description_text_size">16sp</dimen>
<dimen name="video_item_detail_next_text_size">18sp</dimen>
<!-- Elements Size -->
<dimen name="video_item_detail_uploader_image_size">45dp</dimen>
<dimen name="video_item_detail_parent_channel_image_size">25dp</dimen>
<dimen name="video_item_detail_like_image_height">18sp</dimen>
<dimen name="video_item_detail_like_image_width">18sp</dimen>
<!-- Paddings & Margins -->

View File

@ -54,14 +54,16 @@
<dimen name="video_item_detail_title_text_size">15sp</dimen>
<dimen name="video_item_detail_views_text_size">13sp</dimen>
<dimen name="video_item_detail_likes_text_size">12sp</dimen>
<dimen name="video_item_detail_uploader_text_size">14sp</dimen>
<dimen name="video_item_detail_uploader_text_size">12sp</dimen>
<dimen name="video_item_detail_parent_channel_text_size">14sp</dimen>
<dimen name="video_item_detail_upload_date_text_size">13sp</dimen>
<dimen name="video_item_detail_description_text_size">13sp</dimen>
<dimen name="video_item_detail_next_text_size">15sp</dimen>
<dimen name="channel_subscribers_text_size">12sp</dimen>
<dimen name="channel_subscribers_text_size">12sp </dimen>
<dimen name="channel_rss_title_size">12sp</dimen>
<!-- Elements Size -->
<dimen name="video_item_detail_uploader_image_size">28dp</dimen>
<dimen name="video_item_detail_uploader_image_size">32dp</dimen>
<dimen name="video_item_detail_parent_channel_image_size">16dp</dimen>
<dimen name="video_item_detail_like_image_height">18sp</dimen>
<dimen name="video_item_detail_like_image_width">18sp</dimen>
<dimen name="channel_avatar_size">70dp</dimen>

View File

@ -651,4 +651,5 @@
<string name="feed_use_dedicated_fetch_method_disable_button">Disable fast mode</string>
<string name="feed_use_dedicated_fetch_method_help_text">Do you think feed loading is too slow? If so, try enabling fast loading (you can change it in settings or by pressing the button below).\n\nNewPipe offers two feed loading strategies:\n• Fetching the whole subscription channel, which is slow but complete.\n• Using a dedicated service endpoint, which is fast but usually not complete.\n\nThe difference between the two is that the fast one usually lacks some information, like the item\'s duration or type (can\'t distinguish between live videos and normal ones) and it may return less items.\n\nYouTube is an example of a service that offers this fast method with its RSS feed.\n\nSo the choice boils down to what you prefer: speed or precise information.</string>
<string name="content_not_supported">This content is not yet supported by NewPipe.\n\nIt will hopefully be supported in a future version.</string>
<string name="detail_parent_channel_thumbnail_view_description">Channel\'s avatar thumbnail</string>
</resources>

View File

@ -1 +1,7 @@
include ':app'
includeBuild('../NewPipeExtractor') {
dependencySubstitution {
substitute module('com.github.TeamNewPipe:NewPipeExtractor') with project(':extractor')
}
}