Merge pull request #5974 from fynngodau/related-items
Rename related streams to related items
This commit is contained in:
commit
2af20d5c40
47 changed files with 91 additions and 91 deletions
|
|
@ -73,7 +73,7 @@ import org.schabi.newpipe.fragments.BackPressable;
|
|||
import org.schabi.newpipe.fragments.BaseStateFragment;
|
||||
import org.schabi.newpipe.fragments.EmptyFragment;
|
||||
import org.schabi.newpipe.fragments.list.comments.CommentsFragment;
|
||||
import org.schabi.newpipe.fragments.list.videos.RelatedVideosFragment;
|
||||
import org.schabi.newpipe.fragments.list.videos.RelatedItemsFragment;
|
||||
import org.schabi.newpipe.ktx.AnimationType;
|
||||
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
||||
import org.schabi.newpipe.local.dialog.PlaylistCreationDialog;
|
||||
|
|
@ -153,7 +153,7 @@ public final class VideoDetailFragment
|
|||
|
||||
// tabs
|
||||
private boolean showComments;
|
||||
private boolean showRelatedStreams;
|
||||
private boolean showRelatedItems;
|
||||
private boolean showDescription;
|
||||
private String selectedTabTag;
|
||||
@AttrRes @NonNull final List<Integer> tabIcons = new ArrayList<>();
|
||||
|
|
@ -280,7 +280,7 @@ public final class VideoDetailFragment
|
|||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
showComments = prefs.getBoolean(getString(R.string.show_comments_key), true);
|
||||
showRelatedStreams = prefs.getBoolean(getString(R.string.show_next_video_key), true);
|
||||
showRelatedItems = prefs.getBoolean(getString(R.string.show_next_video_key), true);
|
||||
showDescription = prefs.getBoolean(getString(R.string.show_description_key), true);
|
||||
selectedTabTag = prefs.getString(
|
||||
getString(R.string.stream_info_selected_tab_key), COMMENTS_TAB_TAG);
|
||||
|
|
@ -413,7 +413,7 @@ public final class VideoDetailFragment
|
|||
showComments = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
} else if (key.equals(getString(R.string.show_next_video_key))) {
|
||||
showRelatedStreams = sharedPreferences.getBoolean(key, true);
|
||||
showRelatedItems = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
} else if (key.equals(getString(R.string.show_description_key))) {
|
||||
showComments = sharedPreferences.getBoolean(key, true);
|
||||
|
|
@ -927,11 +927,11 @@ public final class VideoDetailFragment
|
|||
tabContentDescriptions.add(R.string.comments_tab_description);
|
||||
}
|
||||
|
||||
if (showRelatedStreams && binding.relatedStreamsLayout == null) {
|
||||
if (showRelatedItems && binding.relatedItemsLayout == null) {
|
||||
// temp empty fragment. will be updated in handleResult
|
||||
pageAdapter.addFragment(new EmptyFragment(false), RELATED_TAB_TAG);
|
||||
tabIcons.add(R.drawable.ic_art_track_white_24dp);
|
||||
tabContentDescriptions.add(R.string.related_streams_tab_description);
|
||||
tabContentDescriptions.add(R.string.related_items_tab_description);
|
||||
}
|
||||
|
||||
if (showDescription) {
|
||||
|
|
@ -974,14 +974,14 @@ public final class VideoDetailFragment
|
|||
}
|
||||
|
||||
private void updateTabs(@NonNull final StreamInfo info) {
|
||||
if (showRelatedStreams) {
|
||||
if (binding.relatedStreamsLayout == null) { // phone
|
||||
pageAdapter.updateItem(RELATED_TAB_TAG, RelatedVideosFragment.getInstance(info));
|
||||
if (showRelatedItems) {
|
||||
if (binding.relatedItemsLayout == null) { // phone
|
||||
pageAdapter.updateItem(RELATED_TAB_TAG, RelatedItemsFragment.getInstance(info));
|
||||
} else { // tablet + TV
|
||||
getChildFragmentManager().beginTransaction()
|
||||
.replace(R.id.relatedStreamsLayout, RelatedVideosFragment.getInstance(info))
|
||||
.replace(R.id.relatedItemsLayout, RelatedItemsFragment.getInstance(info))
|
||||
.commitAllowingStateLoss();
|
||||
binding.relatedStreamsLayout.setVisibility(
|
||||
binding.relatedItemsLayout.setVisibility(
|
||||
player != null && player.isFullscreen() ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,8 +1337,8 @@ public final class VideoDetailFragment
|
|||
super.handleError();
|
||||
setErrorImage(R.drawable.not_available_monkey);
|
||||
|
||||
if (binding.relatedStreamsLayout != null) { // hide related streams for tablets
|
||||
binding.relatedStreamsLayout.setVisibility(View.INVISIBLE);
|
||||
if (binding.relatedItemsLayout != null) { // hide related streams for tablets
|
||||
binding.relatedItemsLayout.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
// hide comments / related streams / description tabs
|
||||
|
|
@ -1432,12 +1432,12 @@ public final class VideoDetailFragment
|
|||
binding.detailTitleRootLayout.setClickable(false);
|
||||
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
|
||||
|
||||
if (binding.relatedStreamsLayout != null) {
|
||||
if (showRelatedStreams) {
|
||||
binding.relatedStreamsLayout.setVisibility(
|
||||
if (binding.relatedItemsLayout != null) {
|
||||
if (showRelatedItems) {
|
||||
binding.relatedItemsLayout.setVisibility(
|
||||
player != null && player.isFullscreen() ? View.GONE : View.INVISIBLE);
|
||||
} else {
|
||||
binding.relatedStreamsLayout.setVisibility(View.GONE);
|
||||
binding.relatedItemsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1849,8 +1849,8 @@ public final class VideoDetailFragment
|
|||
showSystemUi();
|
||||
}
|
||||
|
||||
if (binding.relatedStreamsLayout != null) {
|
||||
binding.relatedStreamsLayout.setVisibility(fullscreen ? View.GONE : View.VISIBLE);
|
||||
if (binding.relatedItemsLayout != null) {
|
||||
binding.relatedItemsLayout.setVisibility(fullscreen ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
scrollToTop();
|
||||
|
||||
|
|
|
|||
|
|
@ -15,38 +15,38 @@ import androidx.preference.PreferenceManager;
|
|||
import androidx.viewbinding.ViewBinding;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.databinding.RelatedStreamsHeaderBinding;
|
||||
import org.schabi.newpipe.databinding.RelatedItemsHeaderBinding;
|
||||
import org.schabi.newpipe.error.UserAction;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
||||
import org.schabi.newpipe.ktx.ViewUtils;
|
||||
import org.schabi.newpipe.util.RelatedStreamInfo;
|
||||
import org.schabi.newpipe.util.RelatedItemInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||
|
||||
public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInfo>
|
||||
public class RelatedItemsFragment extends BaseListInfoFragment<RelatedItemInfo>
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String INFO_KEY = "related_info_key";
|
||||
private final CompositeDisposable disposables = new CompositeDisposable();
|
||||
private RelatedStreamInfo relatedStreamInfo;
|
||||
private RelatedItemInfo relatedItemInfo;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Views
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
private RelatedStreamsHeaderBinding headerBinding;
|
||||
private RelatedItemsHeaderBinding headerBinding;
|
||||
|
||||
public static RelatedVideosFragment getInstance(final StreamInfo info) {
|
||||
final RelatedVideosFragment instance = new RelatedVideosFragment();
|
||||
public static RelatedItemsFragment getInstance(final StreamInfo info) {
|
||||
final RelatedItemsFragment instance = new RelatedItemsFragment();
|
||||
instance.setInitialData(info);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public RelatedVideosFragment() {
|
||||
public RelatedItemsFragment() {
|
||||
super(UserAction.REQUESTED_STREAM);
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInf
|
|||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
@Nullable final ViewGroup container,
|
||||
@Nullable final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_related_streams, container, false);
|
||||
return inflater.inflate(R.layout.fragment_related_items, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -80,8 +80,8 @@ public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInf
|
|||
|
||||
@Override
|
||||
protected ViewBinding getListHeader() {
|
||||
if (relatedStreamInfo != null && relatedStreamInfo.getRelatedItems() != null) {
|
||||
headerBinding = RelatedStreamsHeaderBinding
|
||||
if (relatedItemInfo != null && relatedItemInfo.getRelatedItems() != null) {
|
||||
headerBinding = RelatedItemsHeaderBinding
|
||||
.inflate(activity.getLayoutInflater(), itemsList, false);
|
||||
|
||||
final SharedPreferences pref = PreferenceManager
|
||||
|
|
@ -107,8 +107,8 @@ public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInf
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Override
|
||||
protected Single<RelatedStreamInfo> loadResult(final boolean forceLoad) {
|
||||
return Single.fromCallable(() -> relatedStreamInfo);
|
||||
protected Single<RelatedItemInfo> loadResult(final boolean forceLoad) {
|
||||
return Single.fromCallable(() -> relatedItemInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -120,7 +120,7 @@ public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInf
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleResult(@NonNull final RelatedStreamInfo result) {
|
||||
public void handleResult(@NonNull final RelatedItemInfo result) {
|
||||
super.handleResult(result);
|
||||
|
||||
if (headerBinding != null) {
|
||||
|
|
@ -145,23 +145,23 @@ public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInf
|
|||
|
||||
private void setInitialData(final StreamInfo info) {
|
||||
super.setInitialData(info.getServiceId(), info.getUrl(), info.getName());
|
||||
if (this.relatedStreamInfo == null) {
|
||||
this.relatedStreamInfo = RelatedStreamInfo.getInfo(info);
|
||||
if (this.relatedItemInfo == null) {
|
||||
this.relatedItemInfo = RelatedItemInfo.getInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull final Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putSerializable(INFO_KEY, relatedStreamInfo);
|
||||
outState.putSerializable(INFO_KEY, relatedItemInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(@NonNull final Bundle savedState) {
|
||||
super.onRestoreInstanceState(savedState);
|
||||
final Serializable serializable = savedState.getSerializable(INFO_KEY);
|
||||
if (serializable instanceof RelatedStreamInfo) {
|
||||
this.relatedStreamInfo = (RelatedStreamInfo) serializable;
|
||||
if (serializable instanceof RelatedItemInfo) {
|
||||
this.relatedItemInfo = (RelatedItemInfo) serializable;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout>
|
|||
Rect globalRect = new Rect();
|
||||
private boolean skippingInterception = false;
|
||||
private final List<Integer> skipInterceptionOfElements = Arrays.asList(
|
||||
R.id.detail_content_root_layout, R.id.relatedStreamsLayout,
|
||||
R.id.detail_content_root_layout, R.id.relatedItemsLayout,
|
||||
R.id.itemsListPanel, R.id.view_pager, R.id.tab_layout, R.id.bottomControls,
|
||||
R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton);
|
||||
|
||||
|
|
|
|||
|
|
@ -180,10 +180,10 @@ public final class PlayerHelper {
|
|||
* if a candidate next video's url already exists in the existing items.
|
||||
* </p>
|
||||
* <p>
|
||||
* The first item in {@link StreamInfo#getRelatedStreams()} is checked first.
|
||||
* The first item in {@link StreamInfo#getRelatedItems()} is checked first.
|
||||
* If it is non-null and is not part of the existing items, it will be used as the next stream.
|
||||
* Otherwise, a random item with non-repeating url will be selected
|
||||
* from the {@link StreamInfo#getRelatedStreams()}.
|
||||
* Otherwise, a random stream with non-repeating url will be selected
|
||||
* from the {@link StreamInfo#getRelatedItems()}. Non-stream items are ignored.
|
||||
* </p>
|
||||
*
|
||||
* @param info currently playing stream
|
||||
|
|
@ -198,7 +198,7 @@ public final class PlayerHelper {
|
|||
urls.add(item.getUrl());
|
||||
}
|
||||
|
||||
final List<InfoItem> relatedItems = info.getRelatedStreams();
|
||||
final List<InfoItem> relatedItems = info.getRelatedItems();
|
||||
if (Utils.isNullOrEmpty(relatedItems)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RelatedStreamInfo extends ListInfo<InfoItem> {
|
||||
public RelatedStreamInfo(final int serviceId, final ListLinkHandler listUrlIdHandler,
|
||||
final String name) {
|
||||
public class RelatedItemInfo extends ListInfo<InfoItem> {
|
||||
public RelatedItemInfo(final int serviceId, final ListLinkHandler listUrlIdHandler,
|
||||
final String name) {
|
||||
super(serviceId, listUrlIdHandler, name);
|
||||
}
|
||||
|
||||
public static RelatedStreamInfo getInfo(final StreamInfo info) {
|
||||
public static RelatedItemInfo getInfo(final StreamInfo info) {
|
||||
final ListLinkHandler handler = new ListLinkHandler(
|
||||
info.getOriginalUrl(), info.getUrl(), info.getId(), Collections.emptyList(), null);
|
||||
final RelatedStreamInfo relatedStreamInfo = new RelatedStreamInfo(
|
||||
final RelatedItemInfo relatedItemInfo = new RelatedItemInfo(
|
||||
info.getServiceId(), handler, info.getName());
|
||||
final List<InfoItem> streams = new ArrayList<>(info.getRelatedStreams());
|
||||
relatedStreamInfo.setRelatedItems(streams);
|
||||
return relatedStreamInfo;
|
||||
final List<InfoItem> relatedItems = new ArrayList<>(info.getRelatedItems());
|
||||
relatedItemInfo.setRelatedItems(relatedItems);
|
||||
return relatedItemInfo;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue