Fix PR review

Make all of the uploader section on stream page navigate to the channel page
Extract hard coded strings
Remove redundant spaces
Fix open streams from a channel
Rename "ParentChannel" to "SubChannel"
Config royosef:NewPipeExtractor in app/build.gradle
This commit is contained in:
Roy Yosef 2020-04-16 18:35:42 +03:00 committed by wb9688
parent 2d0bc05488
commit cc8874b687
11 changed files with 87 additions and 97 deletions

View File

@ -158,7 +158,7 @@ dependencies {
exclude module: 'support-annotations'
})
implementation 'com.github.TeamNewPipe:NewPipeExtractor:665c69b5306d335985d5c0692f5119b5172c1b7a'
implementation 'com.github.Royosef:NewPipeExtractor:a4086617719e53b293efa1e8873799ba7714cb14'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'

View File

@ -172,10 +172,11 @@ 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 subChannelTextView;
private ImageView subChannelThumb;
private TextView thumbsUpTextView;
private ImageView thumbsUpImageView;
@ -419,25 +420,16 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
this.openDownloadDialog();
}
break;
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");
case R.id.detail_uploader_root_layout:
if (TextUtils.isEmpty(currentInfo.getSubChannelUrl())) {
Log.w(TAG, "Can't open sub-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 {
openChannel(currentInfo.getUploaderUrl(), currentInfo.getUploaderName());
openChannel(currentInfo.getSubChannelUrl(),
currentInfo.getSubChannelName());
}
break;
case R.id.detail_thumbnail_root_layout:
@ -454,13 +446,13 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
}
}
private void openChannel(final String parentChannelUrl, final String parentChannelName) {
private void openChannel(final String subChannelUrl, final String subChannelName) {
try {
NavigationHelper.openChannelFragment(
getFragmentManager(),
currentInfo.getServiceId(),
parentChannelUrl,
parentChannelName);
subChannelUrl,
subChannelName);
} catch (Exception e) {
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
}
@ -541,10 +533,11 @@ 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);
subChannelTextView = rootView.findViewById(R.id.detail_sub_channel_text_view);
subChannelThumb = rootView.findViewById(R.id.detail_sub_channel_thumbnail_view);
appBarLayout = rootView.findViewById(R.id.appbarlayout);
viewPager = rootView.findViewById(R.id.viewpager);
@ -574,11 +567,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
protected void initListeners() {
super.initListeners();
uploaderTextView.setOnClickListener(this);
uploaderThumb.setOnClickListener(this);
parentChannelTextView.setOnClickListener(this);
parentChannelThumb.setOnClickListener(this);
uploaderRootLayout.setOnClickListener(this);
videoTitleRoot.setOnClickListener(this);
thumbnailBackgroundButton.setOnClickListener(this);
detailControlsBackground.setOnClickListener(this);
@ -627,8 +616,8 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS, onFailListener);
}
if (!TextUtils.isEmpty(info.getParentChannelAvatarUrl())) {
IMAGE_LOADER.displayImage(info.getParentChannelAvatarUrl(), parentChannelThumb,
if (!TextUtils.isEmpty(info.getSubChannelAvatarUrl())) {
IMAGE_LOADER.displayImage(info.getSubChannelAvatarUrl(), subChannelThumb,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
}
@ -993,7 +982,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
@NonNull final StreamInfo info,
@NonNull final Stream selectedStream) {
NavigationHelper.playOnExternalPlayer(context, currentInfo.getName(),
currentInfo.getParentChannelName(), selectedStream);
currentInfo.getSubChannelName(), selectedStream);
final HistoryRecordManager recordManager = new HistoryRecordManager(requireContext());
disposables.add(recordManager.onViewed(info).onErrorComplete()
@ -1126,9 +1115,9 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
}
IMAGE_LOADER.cancelDisplayTask(thumbnailImageView);
IMAGE_LOADER.cancelDisplayTask(parentChannelThumb);
IMAGE_LOADER.cancelDisplayTask(subChannelThumb);
thumbnailImageView.setImageBitmap(null);
parentChannelThumb.setImageBitmap(null);
subChannelThumb.setImageBitmap(null);
}
@Override
@ -1156,17 +1145,17 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
animateView(thumbnailPlayButton, true, 200);
videoTitleTextView.setText(name);
if (!TextUtils.isEmpty(info.getParentChannelName())) {
displayBothUploaderAndParentChannel(info);
if (!TextUtils.isEmpty(info.getSubChannelName())) {
displayBothUploaderAndSubChannel(info);
} else if (!TextUtils.isEmpty(info.getUploaderName())) {
displayUploaderAsParentChannel(info);
displayUploaderAsSubChannel(info);
} else {
parentChannelThumb.setVisibility(View.GONE);
subChannelThumb.setVisibility(View.GONE);
uploaderTextView.setVisibility(View.GONE);
uploaderThumb.setVisibility(View.GONE);
}
parentChannelThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
subChannelThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
if (info.getViewCount() >= 0) {
@ -1297,21 +1286,22 @@ 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);
private void displayUploaderAsSubChannel(final StreamInfo info) {
subChannelTextView.setText(info.getUploaderName());
subChannelTextView.setVisibility(View.VISIBLE);
subChannelTextView.setSelected(true);
subChannelThumb.setVisibility(View.GONE);
uploaderTextView.setVisibility(View.GONE);
}
private void displayBothUploaderAndParentChannel(final StreamInfo info) {
parentChannelTextView.setText(info.getParentChannelName());
parentChannelTextView.setVisibility(View.VISIBLE);
parentChannelTextView.setSelected(true);
private void displayBothUploaderAndSubChannel(final StreamInfo info) {
subChannelTextView.setText(info.getSubChannelName());
subChannelTextView.setVisibility(View.VISIBLE);
subChannelTextView.setSelected(true);
if (!TextUtils.isEmpty(info.getUploaderName())) {
uploaderTextView.setText("By " + info.getUploaderName());
uploaderTextView.setText(
String.format(getString(R.string.video_detail_by), info.getUploaderName()));
uploaderTextView.setVisibility(View.VISIBLE);
uploaderTextView.setSelected(true);
} else {

View File

@ -82,8 +82,8 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
private ImageView headerChannelBanner;
private ImageView headerAvatarView;
private TextView headerTitleView;
private ImageView headerParentChannelAvatarView;
private TextView headerParentChannelTitleView;
private ImageView headerSubChannelAvatarView;
private TextView headerSubChannelTitleView;
private TextView headerSubscribersTextView;
private Button headerSubscribeButton;
private View playlistCtrl;
@ -161,10 +161,10 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
headerSubscribersTextView = headerRootLayout.findViewById(R.id.channel_subscriber_view);
headerSubscribeButton = headerRootLayout.findViewById(R.id.channel_subscribe_button);
playlistCtrl = headerRootLayout.findViewById(R.id.playlist_control);
headerParentChannelAvatarView =
headerRootLayout.findViewById(R.id.parent_channel_avatar_view);
headerParentChannelTitleView =
headerRootLayout.findViewById(R.id.parent_channel_title_view);
headerSubChannelAvatarView =
headerRootLayout.findViewById(R.id.sub_channel_avatar_view);
headerSubChannelTitleView =
headerRootLayout.findViewById(R.id.sub_channel_title_view);
headerPlayAllButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_all_button);
headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button);
@ -175,8 +175,10 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
@Override
protected void initListeners() {
headerParentChannelTitleView.setOnClickListener(this);
headerParentChannelAvatarView.setOnClickListener(this);
super.initListeners();
headerSubChannelTitleView.setOnClickListener(this);
headerSubChannelAvatarView.setOnClickListener(this);
}
/*//////////////////////////////////////////////////////////////////////////
@ -408,28 +410,28 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
return ExtractorHelper.getChannelInfo(serviceId, url, forceLoad);
}
/*//////////////////////////////////////////////////////////////////////////
/*//////////////////////////////////////////////////////////////////////////
// OnClick
//////////////////////////////////////////////////////////////////////////*/
@Override
@Override
public void onClick(final View v) {
if (isLoading.get() || currentInfo == null) {
return;
}
switch (v.getId()) {
case R.id.parent_channel_avatar_view:
case R.id.parent_channel_title_view:
if (TextUtils.isEmpty(currentInfo.getParentChannelUrl())) {
Log.w(TAG, "Can't open parent's channel because we got no channel URL");
case R.id.sub_channel_avatar_view:
case R.id.sub_channel_title_view:
if (TextUtils.isEmpty(currentInfo.getSubChannelUrl())) {
Log.w(TAG, "Can't open sub-channel because we got no channel URL");
} else {
try {
NavigationHelper.openChannelFragment(
getFragmentManager(),
currentInfo.getServiceId(),
currentInfo.getParentChannelUrl(),
currentInfo.getParentChannelName());
currentInfo.getSubChannelUrl(),
currentInfo.getSubChannelName());
} catch (Exception e) {
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
}
@ -448,7 +450,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
IMAGE_LOADER.cancelDisplayTask(headerChannelBanner);
IMAGE_LOADER.cancelDisplayTask(headerAvatarView);
IMAGE_LOADER.cancelDisplayTask(headerParentChannelAvatarView);
IMAGE_LOADER.cancelDisplayTask(headerSubChannelAvatarView);
animateView(headerSubscribeButton, false, 100);
}
@ -461,7 +463,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
ImageDisplayConstants.DISPLAY_BANNER_OPTIONS);
IMAGE_LOADER.displayImage(result.getAvatarUrl(), headerAvatarView,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
IMAGE_LOADER.displayImage(result.getParentChannelAvatarUrl(), headerParentChannelAvatarView,
IMAGE_LOADER.displayImage(result.getSubChannelAvatarUrl(), headerSubChannelAvatarView,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
headerSubscribersTextView.setVisibility(View.VISIBLE);
@ -472,13 +474,15 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
headerSubscribersTextView.setText(R.string.subscribers_count_not_available);
}
if (!TextUtils.isEmpty(currentInfo.getParentChannelName())) {
headerParentChannelTitleView.setText(
"Created by " + currentInfo.getParentChannelName());
headerParentChannelTitleView.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(currentInfo.getSubChannelName())) {
headerSubChannelTitleView.setText(String.format(
getString(R.string.channel_created_by),
currentInfo.getSubChannelName())
);
headerSubChannelTitleView.setVisibility(View.VISIBLE);
} else {
headerParentChannelTitleView.setVisibility(View.GONE);
headerParentChannelAvatarView.setVisibility(View.GONE);
headerSubChannelTitleView.setVisibility(View.GONE);
headerSubChannelAvatarView.setVisibility(View.GONE);
}
if (menuRssButton != null) {

View File

@ -264,7 +264,7 @@
android:src="@drawable/buddy" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/detail_parent_channel_thumbnail_view"
android:id="@+id/detail_sub_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"
@ -280,7 +280,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/detail_parent_channel_text_view"
android:id="@+id/detail_sub_channel_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
@ -290,7 +290,7 @@
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_parent_channel_text_size"
android:textSize="@dimen/video_item_detail_sub_channel_text_size"
android:textStyle="bold"
tools:ignore="RtlHardcoded"
tools:text="Channel" />

View File

@ -40,7 +40,7 @@
tools:ignore="RtlHardcoded" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/parent_channel_avatar_view"
android:id="@+id/sub_channel_avatar_view"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="bottom|right"
@ -68,7 +68,7 @@
tools:text="Lorem ipsum dolor" />
<TextView
android:id="@+id/parent_channel_title_view"
android:id="@+id/sub_channel_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/channel_title_view"
@ -87,7 +87,7 @@
android:id="@+id/channel_subscriber_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/parent_channel_title_view"
android:layout_below="@id/sub_channel_title_view"
android:layout_alignLeft="@id/channel_title_view"
android:layout_alignRight="@id/channel_title_view"
android:ellipsize="end"

View File

@ -258,11 +258,11 @@
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:id="@+id/detail_sub_channel_thumbnail_view"
android:layout_width="@dimen/video_item_detail_sub_channel_image_size"
android:layout_height="@dimen/video_item_detail_sub_channel_image_size"
android:layout_gravity="bottom|right"
android:contentDescription="@string/detail_parent_channel_thumbnail_view_description"
android:contentDescription="@string/detail_sub_channel_thumbnail_view_description"
android:src="@drawable/buddy"
tools:ignore="RtlHardcoded" />
@ -276,7 +276,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/detail_parent_channel_text_view"
android:id="@+id/detail_sub_channel_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
@ -285,7 +285,7 @@
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_parent_channel_text_size"
android:textSize="@dimen/video_item_detail_sub_channel_text_size"
android:textStyle="normal|bold"
tools:ignore="RtlHardcoded"
tools:text="Channel" />

View File

@ -26,7 +26,7 @@
<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">12sp</dimen>
<dimen name="video_item_detail_parent_channel_text_size">16sp</dimen>
<dimen name="video_item_detail_sub_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>
@ -34,7 +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_sub_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,14 +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_parent_channel_text_size">16sp</dimen>
<dimen name="video_item_detail_sub_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_sub_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

@ -55,7 +55,7 @@
<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">12sp</dimen>
<dimen name="video_item_detail_parent_channel_text_size">14sp</dimen>
<dimen name="video_item_detail_sub_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>
@ -63,7 +63,7 @@
<dimen name="channel_rss_title_size">12sp</dimen>
<!-- Elements Size -->
<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_sub_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,5 +651,7 @@
<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>
<string name="detail_sub_channel_thumbnail_view_description">Channel\'s avatar thumbnail</string>
<string name="channel_created_by">Created by %s</string>
<string name="video_detail_by">By %s</string>
</resources>

View File

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