mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-30 23:03:00 +00:00 
			
		
		
		
	Merge pull request #3410 from wb9688/fix-restricted
Show error when video has age limit and setting is disabled
This commit is contained in:
		| @@ -103,6 +103,7 @@ import io.reactivex.disposables.Disposable; | |||||||
| import io.reactivex.schedulers.Schedulers; | import io.reactivex.schedulers.Schedulers; | ||||||
|  |  | ||||||
| import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS; | 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; | import static org.schabi.newpipe.util.AnimationUtils.animateView; | ||||||
|  |  | ||||||
| public class VideoDetailFragment extends BaseStateFragment<StreamInfo> | public class VideoDetailFragment extends BaseStateFragment<StreamInfo> | ||||||
| @@ -806,19 +807,25 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> | |||||||
|             currentWorker.dispose(); |             currentWorker.dispose(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); | ||||||
|  |  | ||||||
|         currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) |         currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) | ||||||
|                 .subscribeOn(Schedulers.io()) |                 .subscribeOn(Schedulers.io()) | ||||||
|                 .observeOn(AndroidSchedulers.mainThread()) |                 .observeOn(AndroidSchedulers.mainThread()) | ||||||
|                 .subscribe((@NonNull StreamInfo result) -> { |                 .subscribe((@NonNull final StreamInfo result) -> { | ||||||
|                     isLoading.set(false); |                     isLoading.set(false); | ||||||
|  |                     if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( | ||||||
|  |                             getString(R.string.show_age_restricted_content), false)) { | ||||||
|  |                         hideAgeRestrictedContent(); | ||||||
|  |                     } else { | ||||||
|                         currentInfo = result; |                         currentInfo = result; | ||||||
|                         handleResult(result); |                         handleResult(result); | ||||||
|                         showContent(); |                         showContent(); | ||||||
|                 }, (@NonNull Throwable throwable) -> { |                     } | ||||||
|  |                 }, (@NonNull final Throwable throwable) -> { | ||||||
|                     isLoading.set(false); |                     isLoading.set(false); | ||||||
|                     onError(throwable); |                     onError(throwable); | ||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void initTabs() { |     private void initTabs() { | ||||||
| @@ -1232,6 +1239,16 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     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() { |     public void openDownloadDialog() { | ||||||
|         try { |         try { | ||||||
|   | |||||||
| @@ -136,8 +136,9 @@ | |||||||
|     <string name="play_btn_text">Play</string> |     <string name="play_btn_text">Play</string> | ||||||
|     <string name="content">Content</string> |     <string name="content">Content</string> | ||||||
|     <string name="show_age_restricted_content_title">Age restricted content</string> |     <string name="show_age_restricted_content_title">Age restricted content</string> | ||||||
|     <string name="duration_live">Live</string> |  | ||||||
|     <string name="video_is_age_restricted">Show age restricted video. Future changes are possible from the settings.</string> |     <string name="video_is_age_restricted">Show age restricted video. Future changes are possible from the settings.</string> | ||||||
|  |     <string name="restricted_video">This video is age restricted.\n\nIf you want to view it, enable \"Age restricted content\" in the settings.</string> | ||||||
|  |     <string name="duration_live">Live</string> | ||||||
|     <string name="downloads">Downloads</string> |     <string name="downloads">Downloads</string> | ||||||
|     <string name="downloads_title">Downloads</string> |     <string name="downloads_title">Downloads</string> | ||||||
|     <string name="error_report_title">Error report</string> |     <string name="error_report_title">Error report</string> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 wb9688
					wb9688