From 90f9819cbd1d10ffd2d649291873ed2eb01b7d95 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Fri, 10 Apr 2020 14:25:00 +0200 Subject: [PATCH 1/2] Show error when video has age limit and setting is disabled --- .../fragments/detail/VideoDetailFragment.java | 19 +++++++++++++------ app/src/main/res/values/strings.xml | 5 +++-- 2 files changed, 16 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 9ad734cb5..4ebe4b8f8 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 @@ -103,6 +103,7 @@ import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS; +import static org.schabi.newpipe.extractor.stream.StreamExtractor.NO_AGE_LIMIT; import static org.schabi.newpipe.util.AnimationUtils.animateView; public class VideoDetailFragment extends BaseStateFragment @@ -806,19 +807,25 @@ public class VideoDetailFragment extends BaseStateFragment currentWorker.dispose(); } + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); + currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull StreamInfo result) -> { + .subscribe((@NonNull final StreamInfo result) -> { isLoading.set(false); - currentInfo = result; - handleResult(result); - showContent(); - }, (@NonNull Throwable throwable) -> { + if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( + getString(R.string.show_age_restricted_content), false)) { + showError(getString(R.string.restricted_video), false); + } else { + currentInfo = result; + handleResult(result); + showContent(); + } + }, (@NonNull final Throwable throwable) -> { isLoading.set(false); onError(throwable); }); - } private void initTabs() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ea2202c58..48205d8f4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -136,8 +136,9 @@ Play Content Age restricted content - Live Show age restricted video. Future changes are possible from the settings. + This video is age restricted.\n\nIf you want to view it, enable \"Age restricted content\" in the settings. + Live Downloads Downloads Error report @@ -638,4 +639,4 @@ Disable fast mode 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. This content is not yet supported by NewPipe.\n\nIt will hopefully be supported in a future version. - \ No newline at end of file + From 70ede70ea8d157d78bed59463e25fa244a546511 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Sat, 11 Apr 2020 09:30:12 +0200 Subject: [PATCH 2/2] Hide tabs when a video is age restricted --- .../fragments/detail/VideoDetailFragment.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 4ebe4b8f8..0441e1ba1 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 @@ -816,7 +816,7 @@ public class VideoDetailFragment extends BaseStateFragment isLoading.set(false); if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( getString(R.string.show_age_restricted_content), false)) { - showError(getString(R.string.restricted_video), false); + hideAgeRestrictedContent(); } else { currentInfo = result; handleResult(result); @@ -1239,6 +1239,16 @@ public class VideoDetailFragment extends BaseStateFragment } } + private void hideAgeRestrictedContent() { + showError(getString(R.string.restricted_video), false); + + if (relatedStreamsLayout != null) { // tablet + relatedStreamsLayout.setVisibility(View.INVISIBLE); + } + + viewPager.setVisibility(View.GONE); + tabLayout.setVisibility(View.GONE); + } public void openDownloadDialog() { try {